Interview Questions

Thursday, May 8, 2014

Dynamics AX 2012 - X++ code to create & post General Journal

static void Gulshan_CreateGLJournalPost(Args _args)
{
    AxLedgerJournalTable    journalTable;
    AxLedgerJournalTrans    journalTrans;
    container               acctPattern;
    container               offSetAcctPattern;
    LedgerJournalTable      ledgerJournalTable;
    ledgerJournalCheckPost  ledgerJournalCheckPost;
    ;

    journalTable = new AxLedgerJournalTable();
    journalTrans = new AxLedgerJournalTrans();

    //Journal Name
    journalTable.parmJournalName("GenJrn");
    journalTable.save();

    journalTrans.parmJournalNum(journalTable.ledgerJournalTable().JournalNum);
    journalTrans.parmTransDate(systemDateGet());
    journalTrans.parmCurrencyCode("USD");
    journalTrans.parmAmountCurDebit(200);
   
    journalTrans.parmAccountType(LedgerJournalACType::Ledger);
    acctPattern = ["211345-Disp","211345"2"Department","00000014""CostCenter","00000007"];
   journalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(acctPattern));       
   
    journalTrans.parmOffsetAccountType(LedgerJournalACType:: Ledger );
    offSetAcctPattern = ["401100-Disp","401100"4"Department","00000014""CostCenter","00000007""CustomPurposeA","Nile""CustomPurposeB""Site2" ];    
    journalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId( offSetAcctPattern));   
   
    journalTrans.save();   
   
    ledgerJournalCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(journalTable.ledgerJournalTable(),NoYes::Yes);
    ledgerJournalCheckPost.run();  
   

    info(strFmt("Journal No. %1.", journalTable.ledgerJournalTable().JournalNum));
}

Key tasks: Create and share an Excel template by using the Office Add-ins [AX 2012]

Microsoft Dynamics AX 2012 integrates automatically with Microsoft Excel. You can use tools and functionality in Excel to work with data in AX 2012. You can export data from AX 2012 to Excel, work with the data there, and then import the data back into AX 2012.
You can create an Excel workbook as a template that is structured so that it works with fields and tables in AX 2012. For example, you can create a budgeting template that lists the financial accounts and dimensions from your organization’s chart of accounts in AX 2012. You can then send a copy of the template to the individuals who are responsible for preparing a budget. When the budget information is complete, it can be imported into AX 2012.
If your system administrator creates a template library, you can save the Excel template to the library, and then reuse the template or copy it for a future budget period.
The data that you can include in a template is limited by the permissions that are associated with your assigned role. In general, if you can view and modify specific data in the Microsoft Dynamics AX client, you can view, add, and modify the same data in a template. If you share a template with other workers, those workers must also have permission to view and modify the data in the shared template.
Before you create a template, your system administrator must configure your personal settings so that you can update the data in the Excel template. For more information about how to view your settings for Excel, see About using the Microsoft Dynamics AX Add-in for Excel.
To modify a template that was created by another person, you must save a copy of the template to your computer. If you use a template that was created by a system administrator, the template might contain columns and rows that you cannot modify. If you want to modify the design of a template, contact the person who created the template.

  1. On a list page in Microsoft Dynamics AX, on the Action Pane, click Export to Excel.
  2. Enter a file name for the Excel workbook.
    Caution noteCaution
    If you select an existing file, the content is overwritten.
  3. Save the file as an Excel template on a local computer.
  4. In Excel, on the ribbon, on the Dynamics AX tab, select the fields to include in the workbook:
    1. Click Field chooser, select the field to add, and then click the > button. To select multiple fields, hold down the CTRL key, select each field, and then click the >button.
      If you want the template to use fields that do not appear in the left pane, click Add data > Add tables.
      Beginning with cumulative update 7 for Microsoft Dynamics AX 2012 R2, if you add financial dimensions, only the dimensions that are specified in the Financial dimension configuration for integrating applications form are available.
    2. To add objects, in the Selected objects pane, select the table, and then click the > button. To select multiple tables, hold down the CTRL key, select each table, and then click the > button.
    3. To remove all objects that were previously selected, click the << button.
  5. In the left pane, select the fields to add to the template.
  6. Save the file to your computer. If your system administrator has created a template library for AX 2012, you can send the template to the system administrator to save to the library.
If you create an Excel workbook to import information into AX 2012, you can save the workbook as a template and then share the template with other workers. For example, your organization completes an annual budget by department, and the departments are set up in AX 2012 as financial dimensions. You can create a budgeting template that lists the financial accounts, and then make a copy of the workbook template for each department or dimension. Each department can then use its copy of the workbook template to prepare the departmental budget.
After you create and save the workbook on a local computer, a system administrator can save it to a template library or other file sharing location.
If you are using Microsoft Dynamics AX 2012 R3 or cumulative update 6 or later for AX 2012 R2, a system administrator can set the export location to a Microsoft Office 365 SharePoint folder. After the template is saved to the SharePoint Online folder, you can open the template from the SharePoint folder if you are using the Office 365 version of Excel. To determine the location that is set up for exported files, click File > Tools > Options. In the Options form, on the General tab, in the Miscellaneous section, theExport location field displays the location.

Update Microsoft Dynamics AX data by using Microsoft Excel [AX 2012]

  1. Start Excel.
  2. On the ribbon, on the Dynamics AX tab, click Connection, select the Microsoft Dynamics AX server to connect to, and then click OK.
  3. Click Add Data, select the check box for the data source query to use, and then click OK.
  4. In the left pane, select a default header value to include in your data query.
    You can select the header and then click Insert value, or you can drag the header to the appropriate cell in the Excel worksheet.
    Repeat this step until you have added all the header fields for this data query.
  5. In the left pane, select the field to include in your data query.
    You can select the field and then click Insert column, or you can drag the field to the appropriate cell in the Excel worksheet.
    Repeat this step until you have added all the fields for this data query.
  6. Click Choose parameters, and then select the parameters for the fields that you selected for your data query.
    For example, to create a data query to view all Time and material projects, select Expense.Project.Project type = Time and material.
  7. Click Publish data.
After you save the workbook, the data is updated for recent transactions the next time you open the workbook.

How to distinguish between the different layers of Microsoft Dynamics AX

Microsoft Dynamics AX Layered Architecture. You can think of the layered architecture of Microsoft Dynamics AX as the layers of an onion. Microsoft Dynamics AX begins with a SYS layer, in which the Core code is written. Nothing and no one can affect the code written in the SYS layer except for Microsoft Dynamics AX development itself. 
Surrounding the SYS layer is the GLS (global), layer. Microsoft development teams have built country specific localizations and other special customizations into these two layers.  Most localizations now exist in the SYS layer, which helps simplify implementations, especially across multi country deployements.  There are also GLS layers for Central and Eastern Europe, Iceland, India, Turkey, China, Brazil and Japan. 

In the BUS (business) and VAR (Value Added Reseller) layers, your chosen ISVs and implementation partners will build customizations that solve the specific needs of your business. The CUS (customer) layer is reserved for your own customizations, while every user at your site can customize their user experience using the USR (user) layer.


Dynamics AX 2009 consists of sixteen application object layers that contain all theelements you see in the AOT.
These layers can be looked at as an onion with multiple layers. In the middle is the core application in the SYS layer and the outermost layer is the user layer USR.
Therefore, when any application element is being executed the system will look at the outermost code layer first to see if there is any code for that element; if not, it peels a layer off the onion, and tries the next layer. When it hits a layer where the element exists, it will use the code from this layer, and will not continue to peel off layers to find code for that element in the innermost layers. 

Layers with their description

SYS The standard application is implemented at the lowest level, 
the SYS layer.The application objects in the standard 
application can never be deleted.

GLS Country/region specific changes will be developed in GLS 
Layer.For e.g as you all know that Tax structure differs 
from country to country.So such localization functionality 
can be developed in GLS layer.

HFX HFX is an application object patch layer reserved by 
Microsoft for future patching or other updates.

SL1, SL2,or SL3 A layer where the distributor can implement 
vertical partner solutions. 

BUS When a business partner creates their own generic solution, 
their modifications are saved in the BUS layer and the top-
level application objects are used.

VAR Value Added Resellers (VAR) can make modifications or new 
developments to the VAR layer as specified by the customers 
or as a strategy of creating an industry-specific solution. 
Such modifications are saved in the VAR layer.

CUS The supervisor or administrator of an end user installation 
might want to make modifications that are generic to the 
company. Such modifications are saved in the CUS (CUStomer) 
layer.

USR End users might want to make their own modifications, such 
as in their reports.These modifications are saved in the USR 
layer.  

Inventory Costing in AX 2009

I wanted to explore some scenarios that illustrate a few important concepts related to inventory costing-- look at differences between physical and financial inventory, and how this affects inventory values. Please reply to the post if you have questions or comments, or if you are interested in additional posts on this topic. This is not intended to be a comprehensive look at AX inventory costing, but just a few concepts that I view as important to understanding the big picture of AX costing logic.
For my test, I created a new item, using a FIFO costing model. The Inventory model group has three settings I want to point out and illustrate:
  • Physical negative inventory
  • Financial negative inventory
  • Include physical value 
Note that the test item has physical and financial negative inventory unmarked, and 'include physical value' is marked:
























To start, I create a purchase order line for the item and post the packing slip for a quantity of 10 at $1 each. The PO packing slip is considered a 'physical' inventory update. You'll see the inventory transaction and the item's on hand reflect the physical cost amount:






































This is an important concept as you'll see the separation of physical and financial inventory throughout AX. Understanding the impact is important when defining your setup and processes. Below is a list of the transactions that result in physical inventory value and those that result in financial inventory value.
Transactions that affect physical value
Purchase order Packing Slip
Sales order Packing Slip
Production order Report as Finished
Production picking list journal
Transactions that affect financial value
Purchase order Invoice
Sales order Invoice
Production order End (This will move the RAF and the Picking List transactions into a financial status)
Inventory Journal (All inventory journals affect financial value only)
Next, I entered a sales order line for the item, quantity 10, and attempt to post the invoice. Although I have physically received 10 units of this item into stock, my sales invoice posting fails with an error message: "Item consumption for 10.00 cannot be updated because the cost price is known only for 0.00 in stock."
The error is thrown because of the model group setting 'negative financial inventory', which is unmarked for our item, meaning that we don't allow negative Financial inventory. If the sales order was for a quantity of 15, I would receive an error message:  "15.00 cannot be picked because only 10.00 is/are available from the inventory"
This error message is driven by the 'Physical negative inventory' checkbox, which does a validation against the current 'total available' on hand inventory for the item. In order to post this invoice, we need to have sufficient financial inventory in stock. To satisfy this requirement, you would have to financially update an outstanding order, or create and post a new order. For our test, I created a separate purchase order for quantity of 10, unit cost $2, and post the Invoice for this purchase order (financially updated). Note that this is a different unit cost, than was used on the previous purchase order($1).
Reviewing the inventory transaction for this new purchase order, you see that a financial cost amount was updated. Additionally, the on-hand for the item now reflects the $10 from the packing slip updated purchase order, as well as the $20 from the invoiced purchase order.






































Now that I have sufficient financial inventory, I posted my sales order invoice. There are two important concepts to point out on the sales order inventory transaction after I post the invoice. First, you'll see that the cost of the quantities sold is an average of the two receipts that have been posted: (10@ $1 + 10@ $2) / 20 =  $1.50 per unit. Take a look at the previous screenshot and you'll see that in the On Hand form, the 'Cost price' field holds the calculated average cost. Although we defined this item as a FIFO item, the value of the outbound quantities are valued at the current running average for the item. You'll see this approach used for all issue transactions, except for items using a standard cost valuation model.
*Note - Marking may also impact these outcomes.
The second thing is that our model group setting for 'include physical value' has made an impact on the outcome. Since we have it marked for this item, the physically updated purchase order was used in the calculation of the running average. The setting simply tells AX whether or not to use physically updated receipts when calculating the running average for the item. If we had this setting unmarked, only the financially updated receipt would have been used in the calculated value of the issued quantities. We now know that this will have a significant impact on the valuation of outbound quantities at the time of posting.
















Since this is a FIFO item, we know that the $15 used to value our sold quantities is incorrect. AX requires that a periodic 'inventory close' be processed in order to align the cost of goods sold with the items' assigned valuation models. After running the close, notice that the sales order transaction now reflects a cost amount $10 with the adjustment of $5. Another thing to point out is that no 'settlement' occurs. Typically, the inventory close process will settle receipts against issues. However, since this sales transaction aligns with a physically updated receipt, no settlement occurs. Once the purchase order is invoiced, the close process will settle the transactions against each other.















Recap:
  • AX tracks inventory value in two separate buckets: Physical and Financial
  • All issue transactions are valued at the current running average cost price for the item
  • You can select whether physically updated receipts are included in the running average calculation
  • A periodic inventory close must be run to align the COGS with the item's valuation model

More about the 'include physical value' setting:
This should only be used for certain scenarios. Weighted average models should not use the setting due to the following scenario:

1. Receive 10 @ $100 each (Financial/Invoice posted)
2. Receive 10 @ $200 each (Physical/packing slip post)
3. Issue 15 @ $150 each (Financial/invoice post). $150 each is due to the fact that 'include physical' is marked for the item. Also, this transaction requires that negative financial inventory is allowed for the item.
4. Run inventory close

Results:
10 of the 15 issue quantities are settled against the $100 receipt and the other 5 remain unsettled at the $150 cost price. This leaves us with 5 on hand, valued at $250 each (which is higher than any single receipt cost we have)
  

Filtering The records in a Form

1)Create a Table Named “FilterDemo” and add some fields like Name, Eid, Salary and Add one Base Enum Like Gender.
2) Enter some Data into  the Table.
3) Create a form Name “FiletrDemoForm”.Drag the FilterDemo Table to the DataSource of the form.
4) Under the Design node of the Form.Create  a New Control àTabàTab Page.
Change the properties of the TabPage Like this
Name:- General
Caption:-General
5) Now Add a new controlàGrid to the TabPage. Now Drag the Fields Which should Appear in the Form to the Grid control from Data Source.
6) Under the Same Tab Page Add a NewGroup. Under the New Group add a new control called ComboBox. Change the property AutoDeclaration of the comboBox to YES and BaseEnum to Gender.
7) Now the form creation is complete. Now We need to see the filtering the Record.
8) Now Declare the range In the classDeclaration of the form.
public class FormRun extends ObjectRun
{
    QueryBuildRange range;
}
9) Add a Range in init() method of the DataSource.
public void init()
{
    super();
range=this.query().dataSourceNo(1).addRange(fieldNum(FilterDemoTable,Gender));
}
10) Override the executeQuery() method of the DataSource.
public void executeQuery()
{
range.value(ComboBox.valueStr());
super();
}
11) Call the executeQuery method in the SelectionChanged method of the ComboBox.
public int selectionChange()
{
    int ret;
    ret = super();
   FilterDemoTable_ds.executeQuery();
    return ret;
}

How to set Fixed Asset in Project through Project Module in AX 2009

Create one project, then select Fixed Asset Number in Setup Tab.