Friday 22 January 2016

Ax Technical Interview Questions

   1. RunBase
                   The RunBase class is a framework for classes that need a dialog for user interaction and that need the dialog values to be saved per user. The RunBase application framework runs or batches an operation. An operation is a unit of work, such as the posting of a sales order or 
calculation of a master schedule.

  2RunBaseBatch
                    All jobs that must be able to run in a batch must inherit from this class. The RunBaseBatch framework extends the RunBase framework, and  X++ classes that extend this framework can have their operations enlisted in the batch queue.

3. What is the sequence of events while a report is generated?
                   Init, Run, Prompt, Fetch, Print

4. Name few X++ classes related to Queries?
                   Query, QueryRun, QueryBuildRange, QueryBuildDataSource, QueryBuildLink

5.What is an index?
                    An index is a table-specific database structure that speeds the retrieval of rows from the table. Indexes are used to improve the performance of data retrieval and sometimes to ensure the existence of unique records.

6. Difference between edit and display method?
                   Display Indicates that the method's return value is to be displayed on a form or a report.
Edit Indicates that the method's return type is to be used to provide information for a field that is used in  In a form. The value in the field can be edited. 

7. Define MorphX  
                  The MorphX Development Suite is the integrated development environment (IDE) in Microsoft Dynamics AX used to develop and customize both the Windows interface and the Web interface.
8. Define AOS  
                 The Microsoft Dynamics AX Object Server (AOS) is the second-tier application server in the Microsoft Dynamics AX three-tier architecture.
The 3-tier environment is divided as follows:

• First Tier – Intelligent Client 
• Second Tier – AOS 
• Third Tier – Database Server
                 In a 3-tier solution the database runs on a server as the third tier; the AOS handles the business logic in the second tier. The client is the first tier and handles the user interface and necessary program logic.

9.super()
               This method calls the system methods to execute.It is used to instantiating the variables at the parent class. Used for code redundancy.

10.types of Delete Actions
               None
              Cascade
              Restricted
              Cascade+Restricted.
11.different types of Table groups
               Miscellaneous
              Parameter
              Group
              Main
              Transaction
              WorkSheetHeader
              WorkSheetLine
12. Do we need to write main method, give reasons
              Yes, but to open the class from action menu item we have to create main method of class.

13.   What is difference between new & construct method
new(): used to create a memory to the object.
Construct():  You should create a static construct method for each class. The method should return an instance of the class.

View 
  •  Modification through a view (e.g. insert, update, delete) generally  not permitted.
  •  Views can be used to provide security mechanism.
  • Logical Subset of Tables
  • A view is only a mirror image of table which is used at places where large access to a table is required.
  • View doesn't contain any data

14. what precautions you need for overriding fetch() method for a report?
 Do not call super() when you override the fetch method in a report.

15.Difference between OCC (Optimistic concurrency control) and PCC (Pessimistic concurrency control)?

  • Optimistic Concurrency Control (OCC) helps increase database performance.
  • Pessimistic Concurrency Control locks records as soon as they are fetched from the database for an update. However, Optimistic Concurrency only locks records from the time when the actual update is performed.
  • Pessimistic concurrency was the only option available in Microsoft Axapta 3.0 (now a part of Microsoft Dynamics). You can now choose which concurrency model to use—optimistic or pessimistic.
16.Caching
                      Caches are used on both the client and the server. The Microsoft Dynamics AX run time manages the cache by removing old records when new records are added to the cache.
Client Cache
           A client-side cache can be used only by the client. The client cache is used when a select is executed from the client tier. If no record is found in the client cache, the client then searches the server cache for the record. If the record isn't located in the server cache, it's retrieved from the database. The maximum number of records maintained in a client cache is 100 records per table for a given company.
Server Cache
A server-side cache can be used by any connection to the server. The server cache is used when a select is executed on the server tier. If no record is found in the cache, it's retrieved from the database. The maximum number of records maintained in a server cache is 2,000 records per table for a given company.
Record Caching
Microsoft Dynamics AX database record caching is a performance-enhancing feature that helps avoid database access when it's not strictly necessary. Retrieving database records from memory instead of the database significantly speeds up data access. Caching can reduce the performance penalty for repetitively accessing the same database records.
 Types of Caching

Caching is transparent to the application; however, it's important to know how caching works to optimize its performance in Microsoft Dynamics AX. Following are the types of caching:
  • Single-record
  • Set-based
Single-record caching has the following characteristics:
  • Defined at design time
  • Moves records to the cache based on the table's CacheLookup property and the type of SELECT statement that is used to retrieve the record 
Set-based caching has the following characteristics:
  • Defined either at design time or in X++ code
  • Moves sets of records to the cache
  • Implemented either through the table's CacheLookup property or in code by using the RecordViewCache class
16. In which case delete_from and delete() have same result?
  Delete() will delete one record at a time.
  Delete_from can delete multiple records at a time.

17. Types of Item Dimensions & Storage Dimensions?
Item Dimension 
          Size,Color,Configuration
Storage Dimension
          Site,WareHouse,Location,Pallet id, Serial number, Batch Number

18. Where is the best place to write code to perform filter in a form
FormDataSource  - executeQuery() and call this method in the design field of the form.

19.Sequence of Method calls while saving the record in the Form
Form — Datasource — ValidateWrite ()
Table — ValidateWrite ()
Form — Datasource — write ()
Table — insert ()

20.Sequence of Methods calls while creating the record in the Form
Form — Datasource — create ()
Form — Datasource — initValue ()
Table — initValue ()
Form — Datasource — active ()

21.Layers
A layer system is used to manage elements. The USR layer is the top layer and the SYS layer is the bottom layer, and each layer has a corresponding patch layer above it.

There are two layers available to both partners and customers who have a license

to access the AX source code.

USR(User layer)
        The user layer is for user modifications, such as reports.

CUS(Customer layer)
        The customer layer is for modifications that are specific to a company.

There are three layers available to partners and ISVs.

VAR(Value Added Reseller layer)
        Includes multi-customer solutions developed by VAR's.

ISV(Independent Software Vendor layer)
      When an Independent Software Vendor (ISV) creates their own solution, their modifications are saved in the ISV layer.

SLN(Solution layer)
       The solution layer is used by distributors to implement vertical partner solutions.

There are three layers available only to Microsoft to deliver the base application.

FPK(Feature Pack layer)
    The FPK layer is an application object patch layer reserved by Microsoft for future patching or other updates

GLS(Globalization layer)
    Includes features developed for some countries that were not yet moved into the SYS layer.

SYS(System layer)
When the application is modified to match country or region specific legal demands, these modifications are saved in the GLS layer.

22. .NET Business Connector
       The .NET Business Connector is a client that has no user interface. It is
designed for other applications to access the Microsoft Dynamics AX business
logic. End-users can use another application as the user interface that interacts
with the AOS through the .net Business Connector

23.RecordSortedList 
The RecordSortedList class inserts multiple records in a single database trip,
and can hold a subset of data from a table in a particular sort order that does not
exist as an index.

RecordInsertList
The RecordInsertList class provides array insert capabilities in the kernel. This
allows you to insert more than one record into the database at a time, which
reduces communication between the application and the database.

RecordInsertList is similar to RecordSortedList, but it has built-in client/server
support (it automatically packs data from one tier to another when needed), and it

lacks the sort order features available in RecordSortedList.

24. Scenario Based
Code optimization, There is one class in Ax. If the client wants to reduce the execution time of that operation. Its a custom class. so what are all your steps to optimize the class and reduce the time of execution
Sol : 
  • Use trace and code pro filer to find out the process that take much time and optimize it
  • Use indexes, joins and Queries in code.


How call form from a class
    Args    args;
    FormRun formRun;
 
    args = new Args(formstr(CustTable));
    args.record(custTableLocal);
    formRun = classFactory.formRunClass(args);
    formRun.init();
    formRun.run();
    formRun.wait();
    formRun.detach();
FormRun.wait() (if you want to stop execution until the form is closed)
FormRun.detach() (if you want not to wait for the form), not both.
or
Using MenuFunction: void clicked() { Args args; args = new Args(); args.caller(this); args.parmObject(list); new MenuFunction(menuItemDisplayStr(SalesTable), MenuItemType::Display).run(args); }

Thursday 21 January 2016

How to add a validate method in AX 2012 SSRS report

1. Implement the contract class by SysOperationValidatable

public class ProjTransReportContract implements SysOperationValidatable

2. Add the validate method

public boolean validate()
{
    boolean             isValid = true;
    ;

    if (this.parmFiscalYear() == '')
    {
        // Fiscal year was not entered.
        isValid = checkFailed(strfmt("The fiscal year is required. Enter a defined fiscal year to continue."));
    }
    else if (this.parmProjId() == '')
    {
        // Project ID was not entered.
        isValid = checkFailed(strfmt("The Project Id is required. Enter a defined Project Id to continue."));
    }
    return isValid;
}


Wednesday 20 January 2016

Sales Order and Purchase Order Tables and Classes

Purchase Order classes and Tables:


PurchTableType and PurchTableLine classes will get called while creating the PurchaseOrders.
PurchFormLetter_PurchOrder
PurchFormLetter_ApproveJournal
PurchFormLetter_Invoice
PurchFormLetter_PackingSlip
PurchFormLetter_ReceiptsList
classes will be used to post the PurchaseOrder at various document status (packing, invoice etc).
Tables:
PurchTable contains all purchase order headers regardless whether they have been posted or not.
PurchParmTable and PurchParmLine contains detailed information regarding posting Purchase headers and Lines.
VendPackingSlipJour and VendPackingSlipTrans tables contains posted packingslip headers and lines.
VendInvoiceJour and VendInvoiceTrans tables contains all invoiced purchase order headers and Lines.
VendReceiptsJour and VendReceiptsTrans tables contains posted receipt header and lines.
VendPurchOrderJour and VendPurchOrderTrans tables contains Purchase requisition headers and lines.

SalesOrder Classes and Tables:

SalesTableType
 and SaleslineType classes will get called while creating the SalesOrders.
SalesFormLetter_Confirm
SalesFormLetter_Invoice
SalesFormLetter_PackingSlip
SalesFormLetter_PickingLlst
classes will be used to post the sales order at various document status (packing, invoice etc).
Tables:
SalesTable contains all SalesOrder headers regardless whether they have been posted or not.
The SalesParmTable and SalesParmLine contains detailed information regarding posting sales headers and Lines.
CustConfirmJour and CustConfirmTrans tables contains all Sales Confirmation headers and Lines posted in Dynamic Ax originating from Sales Orders and Lines.
CustPackingSlipJour and CustPackingSlipTrans tables contains all sales PackingSlip headers and Lines posted in Dynamic Ax originating from Sales Orders and Lines.
CustInvoiceJour and CustInvoiceTrans tables contains all sales all Sales Invoice headers and Lines posted in Dynamic Ax originating from Sales Orders and Lines.


Monday 18 January 2016

Progress Bars in Ax 2012

static void SysOperationProgress_PrimeNumber(Args _args)
{
    #avifiles
    boolean checkPrime,_showProgess = true;
    SysOperationProgress progressBar = new SysOperationProgress();
    int counter,num;
    ;
    counter = 1;
    num = 1000;
    while(counter < num)
    {
        checkPrime = ((counter mod 2)!=0 && (counter mod 3) !=0);

        if(checkPrime)
        {
            info(strfmt("its a prime number %1",counter));
        }
        progressBar.setCaption(strfmt("Generating the prime number for %1",counter));
        //progressBar.setAnimation(#aviUpdate);
        //progressBar.setAnimation(#AviFindFile);
        //progressBar.setAnimation(#AviPrint);
        progressBar.setAnimation(#AviTransfer);
       
        progressBar.setText(strfmt("Processing %1 out of %2",counter,num));
        counter++;
    }
}

Functions in Ax 2012

static void CON_functions(Args _args)
{
    int             i;
    real            r;
    str             s;
    container       con;
    date            d;
   // AifDocumentCreateAttribute
    //i = 1<<4;
    //i = 1>>4;
    //i = (100>101)?1:5;

    //i = abs(10*20.69544);    abs        Retrieves the absolute value of a real number.
    // i = acos(180);          acos       Retrieves the arc cosine of a real number.

    // i = 42373;
    //mydate = any2date(i);                                     any2date

    //s = 1;
    //st = any2enum(s);                                         any2enum
   // x = any2int(s);                                           any2int
   // x = any2int64(s);                                         any2int64
   // x = any2real(s);                                          any2real
   // x = any2str(s);                                           any2str
   // i = asin(1.2);                                            asin
   // i = atan(1/0);                                            atan
   // x = attributeStr(AifDocumentCreateAttribute);             attributeStr
   // beep();                                                   beep
   // x = char2num("RaJendra",1);                               char2num
   // x = classIdGet(obj);                                      classIdGet
   // x = classStr(Global);                                     classStr

                            //Container
    //con = ["Rajendra","chilukuri","410",9440078438];
    //info(strfmt("%1",conPeek(con,5)));                        conPeek
    //con = conPoke(con,2,"Chilukuri's");
    //info(strfmt("%1",conPeek(con,2)));                        conPoke
    //s = conLen(con);
    //info(strfmt("%1",s));                                     conLen
    //con = conIns(con,5,"Hello How are You ??????");
    //info(strFmt("%1",conPeek(con,5)));                        conIns
    //info(strFmt("%1",conFind(con,"410")));                    conFind
    //con = conNull();
    //info(strFmt("%1",conPeek(con,1)));                        conNull
    //con = conDel(con,1,1);
    //info(strFmt("%1" ,conPeek(con,1)));                      // conDel

    //i = corrflagset(0.369,2);

    //i = cos(900);             cos         Retrieves the cosine of a real number.

    //i = cosh(0);              cosh        Argument values outside of the range –250 to 250 result in the following run-time error: "Argument for trigonometric function out of range."

    //i = cTerm(10,100,50);     cTerm       Calculates the number of periods required for the current investment value to yield a target value.

    //x = curext();             curext      Retrieves the extension that is used for the current company.

    //x = curUserId();          curUserId   Retrieves the nonnumeric ID that represents the current user.

    //x = datasetStr(CustomerList);  datasetStr           Retrieves the name of a dataset as a string.
    //d = today();
   // s = date2num(d);          date2num    Converts a date to an integer that corresponds to the number of days since 1 January, 1900.
   // date2Str                  Converts the specified date to a string.


    //utcDateTime         utc2 = 1959-06-17T15:44:33;
    //x = datetime2str(utc2);
    //formStr                   Retrieves the name of a form.

    // i = frac(1.3658);        Retrieves the decimal part of a real number.


    //info(strFmt("%1",funcName())); //Retrieves a string that contains the current function context.  o/p con_functions
    //setPrefix("Hai");
    //setPrefix("Hello");           Retrieves the current execution prefix after successive calls to the setPrefix function.
    //setPrefix("Namaskaram");
    //setPrefix("Whole Ax Team");

    //info(getPrefix());

    //date refDate = str2Date("4/9/2007", 213);
    //date inputDate = str2Date("10/5/2007", 213);
    //int numberOfIntervals;
    //;
    //numberOfIntervals = intvMax(inputDate, refDate, intvScale::YearMonth);
    //info(strFmt("%1",numberOfIntervals));

    //i = logn(100);            Retrieves the natural logarithm of the specified real number.

    //s = match("<abc","abcdef");       Searches for a string or expression within another string.

    //s = min(12,15,19);
    //d = maxDate();            Retrieves the maximum value allowed for a variable of type date.
    //i   = maxInt();

    //x = methodStr(Calculator,exponent);   Validates that the specified method exists in the specified class; if not, a compiler error occurs.

    //d = mkDate(11,1,2016);      Creates a date based on three integers, which indicate the day, month, and year, respectively.

    //str x1 =mthName(1);           Retrieves the name of the specified month

    //s = mthOfYr(today());

    //d = prevyr(today());

    //x = num2char(67);             Converts an integer to the corresponding ASCII character.

    //d = num2date(364);             // Retrieves the date that corresponds to the specified number of days after 01\01\1900.

    //s = power(5,2);

    //i = round(15,4.00);
    //info(strFmt("%1",sessionId()));
    //int seconds = 10;
    //int i1;
    //i = sleep(60);

    //d = str2Date("31/02/2010",213);

    //s = strAlpha("?a*bc123.");        Copies only the alphanumeric characters from a string.

    //i = strCmp("Raj","Raj");

    //strColSeq                         Converts all uppercase characters to lowercase characters and converts all characters with accents to the corresponding unaccented lowercase characters.


    //info(strFmt("%1", strDel("abcdef",2,3)));  Creates a copy of a string with the specified substring removed.

    //info(strFmt("%1",strKeep("Hellohainamastehi","hai"))); returns str2 values based on str1

    //info(strFmt("%1",strRep("Rajendra ",3)));   Repeats a string of characters.
    //info(strFmt("%1",timeNow()));             The number of seconds that have elapsed since midnight.

    //r = trunc(3.12);
    //print strFmt("r = %1",  r);               Truncates a real number by removing any decimal places.

    //pause;

    //info(strFmt("%1",year(today())));         Retrieves the year from a date value.
    info(strFmt("%1",yearDiff(today(),today()-7)));
}