Tuesday, April 21, 2015

Dimension in Ax 2012

Understanding the dimensions on ledgerJournalTrans

LedgerJournalTrans has 4 dimensions fields: LedgerDimension, DefaultDimension, OffSetLedgerDimension and offSetDefaultDimension.

You can think of LedgerDimension and OffSetLedgerDimension as holding an account and the dimensions for that account, both in one field. Where as the DefaultDimension and the OffSetDefaultDimension only holds the dimension.

The Fields LedgerDimension and OffSetLedgerDimension are shown in the form as “Account” and “Offset account”. The fields DefaultDimension and OffSetDefaultDimension are shown in the form under the button “Financial Dimension/Account” and “Financial Dimension/Offset Account”.



Which of the fields you have to fill out, depends on the fields Accounttype and OffSetAccountType:
AccountType = Ledger  a fill out LedgerDimension with a mainAccount and dimensions
AccountType = not Ledger a fill out ledgerDimentin with an account (ex CustAccount) and fill out DefaultDimension with dimensions.
OffSetAccountType = Ledger a fill out OffSetLedgerDimension with a mainAccount and dimensions
OffSetAccountType = not Ledger a fill out OffSetledgerDimentin with an account (ex CustAccount) and fill out OffSetDefaultDimension with dimensions.

Look at the example below. The Customer DAT-000001 has dimension show in the form “Enter account financial dimension”. DAT-000001 is info stored in the LedgerDimension and the dimensioninformation is stored in the DefaultDimension. The offset ledgeraccount is 1000 and both this information and the dimensions are shown in the “Offset account” field and stored in the OffSetLedgerDimension. OffSetDefaultDimension is blank.


Upgrading the dimensions in LedgerJournalTrans
Then upgrading the code concerning ledgerJournalTrans it is important to remember, that you need to make sure that both the account and the offset account have there dimensionsfields filled out and that the dimensions are the same, as this is how it was in Ax 4.0.

Ex:
Old code
newJournalTrans.Dimension[6]           = TUSParameter::find().FinDep_DimTransactionTypeId;
newJournalTrans.OffsetAccountType =  LedgerJournalACType::Ledger;
newJournalTrans.OffsetAccount         =  tusFinDepEntrySetup.PreliminaryDebtAccount;

New code:
//old code - newJournalTrans.Dimension[6] = TUSParameter::find().FinDep_DimTransactionTypeId;

//newJournalTrans.DefaultDimension   = newJournalTrans.DefaultDimension merged with TUSParameter::find().FinDep_DimTransactionTypeId as the TransactionType attribute

tusTransactionsType=transactionsType::find(TUSParameter::find().FinDep_DimTransactionTypeId);
newJournalTrans.DefaultDimesion= TUSDimensionServices::addOneTusDimToADefaultDimension
(newJournalTrans.DefaultDimension, DimensionAttribute::getDimAttributeTUSTransactionType(), tusTransactionsType.TransactionType, tusTransactionsType.RecId);
newJournalTrans.OffsetAccountType   = LedgerJournalACType::Ledger;

//old code - newJournalTrans.OffsetAccount  = tusFinDepEntrySetup.PreliminaryDebtAccount;

newJournalTrans.OffSetledgerDimension = DimensionDefaultingEngine::getLedgerDimensionFromAccountAndDim(
                                               mainAccountRecId,
                                               DimensionHierarchy::getAccountStructure(mainAccountRecId),
                                               newJournalTrans.DefaultDimension);

How to add dimension on forms

Table - we need to create defaultdimension field with Edt as DimensionDefault and create relation with DimensionAttributeValueSet (Recid) to the DefaultDimension field.

Form - we need to add the table to the datasource part. In the Design side we need to create FinancialDimension Tab with Empty Fields.

Code - we need to write the code in following Methods

Class Declaration

public class FormRun extends ObjectRun
{
    DimensionDefaultingController       dimensionDefaultingController;
}
This object does the work in handling the dimensions. And it does it without that much work from our site.
init
public void init()
{
    boolean financialsDimensionsEnabled = true;
    super();
    dimensionDefaultingController = DimensionDefaultingController::constructInTabWithValues(false, true, financialsDimensionsEnabled, 0, this, tabFinancialDimensions, "@SYS138491");
    dimensionDefaultingController.parmAttributeValueSetDataSource(KbDimensionTab_ds, fieldStr(KbDimensionTab, defaultdimension));
    dimensionDefaultingController.parmValidateBlockedForManualEntry(true);

    tabFinancialDimensions.enabled(financialsDimensionsEnabled);
}
The first line instantiates the object which takes – among others – the formRun and the empty tab page as parameters.
The second line tells the class what data source and which field on the table it should use when handling the financial dimensions.
The third activates the class. If you have the dimensions on a separate tab page on your form you can call the pageActivated method when that tab page is activated to increase performance.
write
public void write()
{
    super();
     dimensionDefaultingController.writing();
}
active
public int active()
{
    int ret;

    ret = super();
    dimensionDefaultingController.activated();

    return ret;
}
delete
public void delete()
{
    super();
    dimensionDefaultingController.deleted();
}
pageactivated
public void pageActivated()
{
    dimensionDefaultingController.pageActivated();

    super();
}

DAVS- it stores recid of dimension
DAVSI - recid of value .
how to add dimensions on tables

1) Create New table and EDT of Dimension Default to your table.
2) Set the relation of DimensionAttributValueSet table (Recid field) to your table of DimensionDefault.



once create the table as shown above. we need to create View for your table
3) Create View for your table named as DimensionAttributeKbDimension
4) Change the Datasource name as BackingEntity
5) drag the Itemname,Tracking no and Recid to the Field and changed name as Name,Value and Key for the 3 fields.


5) Create and run the following  job to clear the dimension cache:
static void clearCache(Args _args)

{
DimensionCache::clearAllScopes();
info("done");
}


6)GL--Setup--FinancialDimension.Click new and select your table name from the use values from field.


7) enter the dimension name for your table.e.g KbDimension
8) click the financial dimension button for your KbDimension.

9) see the financial dimension form for your table.here we can see yourtable data of itemname and trackingno field.

10) Goto GL--Setup---Chart of Accounts--configure account structures.
11) select anyone of structure. i have selected Account structure P&L and click the edit button.
select the ADD Segement.


12) once selected the value and click ADD Segement button. automatically coloumn will added to the form as shown below

13) finally, click the activate button.


https://sumitsaxfactor.wordpress.com/2011/12/16/getting-individual-dimension-combination-valuesdimension-storage-class-ax-2012/








Friday, April 17, 2015

Number Sequence

1) we need to create EDT as string KBNumSeqCustGroupNum.
2) we need to add code for the particular module. so we have to choose which module we are going to add number sequence.in this case ,am going to add in customer module.Class--NumberSeqModuleCustomer--LoadModule Method






3) Go to OA-Common-Number Sequence . Click Generate Button



Click the details button below and set or change the value as you like in the number sequence, highest and lowest and format.


Click finish button


Go to the Custgroup table and added KBNumSeqCustGroupNum edt to the field and set the allow edit as NO. add the KBNumSeqCustGroupNum edt to overviewgroup in the table.



open the custgroup form. add the following codes .

  1. Write the following code on the Class declaration node
     NumberSeqFormHandler numberSeqFormHandler;

  2. Create a new method on the form and write the following code
    NumberSeqFormHandler numberSeqFormHandler(){
    if (!numberSeqFormHandler){
    //create a reference of number sequence form handler class specifying the         EDT, Data source name and the field of the table
    numberSeqFormHandler =NumberSeqFormHandler::newForm(NumberSeqReference::findReference(extendedtypenum(KBNumSeqCustGroupNum)).NumberSequenceId, element,CustGroup_DS,fieldnum(CustGroup,KBNumSeqCustGroupNum));}return numberSeqFormHandler;
    }

  3. Override the close method of the form and write the following code
    public void close()
    {
        if (numberSeqFormHandler)
        {
            numberSeqFormHandler.formMethodClose();
        }
        super();
    }

  4. Override the create method on the CustGroup data source and add the following code
    public void create(boolean _append = false){
    element.numberSeqFormHandler().formMethodDataSourceCreatePre();
    super(_append);
    element.numberSeqFormHandler().formMethodDataSourceCreate(true);}

  5. Override the write method on the CustGroup data source and add the following code
    public void write(){
    super();
    element.numberSeqFormHandler().formMethodDataSourceWrite();}

  6. Override the validateWrite method on the CustGroup data source and add the following code
    public boolean validateWrite(){
    boolean ret;
    ret = super();
    ret = element.numberSeqFormHandler().formMethodDataSourceValidateWrite(ret) && ret;
    return ret;}

  7. Override the delete method on the CustGroup data source and add the following code
    public
    void delete()
    {
    element.numberSeqFormHandler().formMethodDataSourceDelete();
    super();}

  8. Override the linkActive method on the CustGroup data source and add the following code
    public
    void linkActive()
    {
    element.numberSeqFormHandler().formMethodDataSourceLinkActive();
    super();}
  9.  once we complete the above procedure, just open the custGroup form and click new button automatically number sequence field is added as well as number filled.
http://www.dynamics101.com/2014/09/creating-custom-number-sequences-microsoft-dynamics-ax-2012/

Query in X++ code and AOT

  1. There are two ways to create queries:
  2. 1. Create Static Query using a graphical interface.
  3. 2. Dynamic queries by x++ code using System class.


Statics Query


How to add select button on RunBaseBatch Using Static Query on class.using RunBaseQueryDialog to display the select button on form.


 Simple class.

1) HrmAbsenceCreateTables- is a query.
    HRMAbsenceCreateTables - is a class
    HCMWorker,HCMEmployment,DirPerson - tables are used in the query.

2) WorkCalendarDelete,WmsOrderFinish


3) RunbaseBatch Class without Select button
    Class - EventJobDueDate

4) Inheritance Class
    HcmSkillChartDepartment,HcmSkillGapByJobSkill


Example

5) Table - EcoResColor-lookupProductVariantColor

6) SSRS Class - AssetBalancesPeriodDP, BankAccountStatementDp ,SalesOrderEntryStatisticsDP,
SalesOrderEntryStatisticsContract, SalesOrderEntryStatisticsController.
7) Forms - VendSearchCriterion,VendSearchAddCategory.
.

Dynamic Query

  1. construct query by using X++ code.
JmgPayEventsExport(Method :BuildEmployeeQuery) class is the example of query.

InventUpdate class implements Query to wrire Business logic.

https://community.dynamics.com/ax/b/daxmusings/archive/2011/09/27/query-and-new-related-objects-in-ax-2012.aspx

Wednesday, April 15, 2015

Types Of Lookup In Ax 2012

EDT Lookup

First we need to create table
VetSpeciesTable
1) SpeciesID
2) Name
second we need to create primary index for speciesID , so set allow duplicate vale as No
third we need to set Primary index as speciesid

Create EDT for the Species and set the referencetable. for clear idea , i ill show the below screen shot.





once we have complete the procedure, if we use the above edt speciesID to any  table automatically foreignkey relation will create to current table.we ill get lookup of the table.



Create lookup in form without creating a method from table

Standard Example of code

Lookup in queries

\Forms\DirPartyQuickCreateForm\Data Sources\LogisticsPostalAddress\Fields\CountryRegionId\Methods\lookup


Output of the above code

AR-- All Customers-- Create customers


Creating Custom Lookup Dynamically by using Queries


VendTable we ill write one lookup method to display the additional with the existing lookup.

now we are going to write one lookup method and after that we are going to call this method in form.


Code
public void lookupVendorByCurrency(FormControl _formControl, Currencycode _currency)
{
    Query               query;
    QueryBuildDataSource qbds;
    QueryBuildRange      qbr;
    SysTableLookup      sysTableLookup;

    query = new Query();
    sysTableLookup = SysTableLookup::newParameters(tableNum(VendTable), _formControl,true);
    query.addDataSource(tableNum(VendTable));
    qbr = qbds.addRange(fieldNum(VendTable,Currency));
    qbr.value(queryValue(_currency));
    sysTableLookup.addLookupfield(fieldNum(VendTable,AccountNum),true);
    sysTableLookup.addLookupfield(fieldNum(VendTable,Party));
    sysTableLookup.addLookupfield(fieldNum(VendTable,Currency));
 

    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

Go to the Cust table form and click datasource custtable and field vendaccount .create lookup method for thgat field

public void lookup(FormControl _formControl, str _filterStr)
{
    VendTable::lookupVendorByCurrency(_formControl,CustTable.Currency);
}



Output

AR-- All customers--edit button-- Miscellaqneous Details group--vendor account filed

Previously it used to disaplay vendaccount and name.. now we added the currency field in the existing lookup.




Lookup by args

Standard Form Name :AssetDepBookLVPTransferProposal(\Forms\AssetDepBookLVPTransferProposal\Designs\DesignList\TransferToAssetId\Methods\lookup)

Table:Assettable(lookupAccountNumLVP Method)

Tuesday, April 14, 2015

Table properties - Support Inheritance,Extends,Abstract

Example

If you want to set the supportinhertiance to the table,
Step 1;
Create table
set the property as yes to SupportInheritance(before create any filed to the table)
Set yes to Abstract
create new filed as InstanceRelationType by the datatype as Int64
set the InstanceRelationType to the property InstanceRelationProperty

EcoResProduct - Base Table
EcoResProductMaster - Child Table
EcoResDistinctProduct -Child table


In the child table we need to set the property Base table  to Extend and set yes to support inheritance.
You cant create the same name of field in the child table which is already exist in the parent table.



http://axdaily.blogspot.com/2011/04/table-inheritance.html

Thursday, April 9, 2015

Info part in Form

How to create infor part in form

First we need to create query. in this query we need to add tables anf fields.
second we need to add info part in AOT.

Data Dicitionary- Index and Relations

Index
Unique Index
Non Unique Index

Unique Index
 To set an index as a unique index, you can set the index property called allow duplicates to no.  Fields should not to allow edit.To set an index as the alternate key, you can set the alternate key property of the index to yes.Set the primary Index property to the unique index.When a primary index is not specified, AX uses a surrogate key as the primary index. 


The ClusterIndex value is given to the underlying Microsoft SQL Server database system as a performance tuning choice. This choice generally controls the physical sequence in which the records are stored in the underlying database.


Relations
Normal 

 Normal specifies related fields in another table.  Multiple fields can be included in this relation.






Field Fixed

Field fixed and related field fixed are conditional relations.  Conditional relationships can be created by adding a condition to a table relation.  Only records that fulfill the condition are included in the relation. A condition on a relation filters the records on either the table that contains the relation or the related table, depending on the type of condition.  Field fixed specifies that the condition is on the table that contains the relation

https://dynamicsaxinsight.wordpress.com/2014/01/23/conditional-relations-with-field-fixed-and-related-field-fixed/

Related Field Fixed







In the above example you can see the related field example. first one relations is created in the cust table for custvenditemgroup table and field of module.

Module is Enum data type, so invent is first value, so if we create new record in the custvenditemgroup table automatically 1 value is assigned to Module field.

Foreign Key

http://axdaily.blogspot.com/2011/05/surrogate-keys-in-ax-2012.html



Wednesday, April 8, 2015

Create Active Directory in windows server 2008

if you want to add user in the ax, but he isnot in the active directory folder to give the access for AX.

first we need to select the administrative tools --> Active Directory users and computers
we need to select user tab.
there you need to add user name.
if you want to give access like administrator just duplicate of administrator and rename of ur user name.

we need to give password ,user anme and expiration of pwd details from the properties.



Once you have completed this , now ypou can add the user name SA-->Users -->Import directory wizard.


Data Import/Export

Data Import/Export framework

Microsoft Dynamics AX Import:

Dynamics AX Import:
The primary mechanism for transferring Data between the different instances of Dynamics AX is the standard Import method. The utility is available in System Administration--Common--Data Export/Import--Import.
In order to use the functionality of this feature, Definition groups have to be created which include the tables involved in importing of Data. This utility cannot be used for migrating data from one ERP system to another or to import data into the older versions of Dynamics AX 2012.
Following are the steps to use an existing legal entity as a template for other legal entities.
 1. Create a legal entity to use as a template. 
2. Set all configuration data for the source legal entity. 
3. Create a definition group which can be used to export data.
a) To create a definition group, open your AX client.

 Go to System Administration module--Common--Data export/import--Definition groups.
Click on New button or Ctrl + N. On General tab of Create table definition group form, provide your Definition group and Description.


b) On Options tab of above form check Include shared tables check box as shown below.

You should not check Include system tables check box, Include database log tables, Include cross-reference tables. For example if you include system tables it may stop you to access AX client.

c) This part is important: To export configuration data, include the following table groups: Reference, Parameter, Group, Framework, and Miscellaneous as shown below.


d) To export master data, you must include the tables that are in the Main table group.

e) Do not include the tables that are in the Transaction, Transaction header, Transaction lineWorksheet, Worksheet header, and Worksheet line table groups. These tables include transaction data. It can be difficult to create a duplicate environment for transaction data if the SaveDataPerCompany property of tables is set to No. For transaction date Microsoft SQL Server backup and restore mechanism is one of best option but a minor configuration changes can be made to illustrate specific Microsoft Dynamics AX features.

f) Now click on OK button to create definition group.


4. Now you are ready with Definition group to export data for a legal entity (Company). 










Select Table button is used to select the particular table to Export the data between the companies in AX. Here i have choosed the two table to import the data to CEC from CEU company.

Go to System Administration module--Common--Data export/import--Export to. Select your Definition group from drop down and provide the file Name (and location). Remaining things are up to your choice.  




Click on OK button. This will create a .dat file with your given name using the Microsoft Dynamics AX data export .


Data Import 

In the new environment, create new legal entities, and then import the .dat file that you created into each entity individually (in step 4). Go to System Administration module--Common--Data export/import--Import

Select your Definition groups from the drop down and provide file Name (and location). Remember if you have different environment create a same definition group in your new environment where you are support to import data for a legal entity. OnAdvance tab there are different options but you may go for Include shared tables.



After filled the all details click ok button. Finally it used to display info like how many records are imported totally in the company



Microsoft Excel Add-in for Microsoft Dynamics AX:

Steps: 

Installing Dynamics Ax Excel ADD IN


Another powerful option to import Data in Dynamics AX is the Excel Add-in. Data has to be organized in a specific pattern and some basic requirements are need to be met in order to import data successfully. Only the Excel documents which meet the below mentioned requirements can be used to create or update Data in AX tables.
  • Replacement Keys: Parent Data source must have unique indexes other than RecId.
  • Related Replacement Keys: Each RecId-based foreign key must be related to a table that specifies a replacement key
  • Relationship Direction: Relationships pointing towards parent from child element should be used only
  • Query and Service Consistency: Query and service must be synchronized in order to ensure consistency
  • View Support: Services using views must be properly implemented using the specified methods only
http://www.slideshare.net/murrayfife/using-the-dynamics-ax-2012-excel-addin-to-import-and-publish-data

RapidStart Services:

RapidStart services are used to populate basic configuration data along with some master data. The services cannot be used to import transactional data. These services can, however, be used to manage data.

AIF:

AIF has the ability to exchange external data in the form of XML with Microsoft Dynamics AX. To call an AIF service, System administration > Setup >Services and Application Integration Framework > Inbound ports, and then click New. Enter a Port name and description. Select service operations under Service Operations. Click on Activate and use the system generated WSDL URI to import Data externally.

Microsoft Import Export Framework:

We have recently released the new version for Microsoft Dynamics AX 2012 Data Import/Export Framework as part of Microsoft Dynamics AX 2012 R2 CU7. We received lot of requests to get the new version for AX 2012 R2 (Base R2 and/or CU1, CU6, hotfixes) without taking full CU7. To make this happen, we have released an application hotfix for DIXF which can be installed on AX 2012 R2 (Base R2 and/or CU1, CU6, hotfixes).  The hotfix does not contain the binary files for the Data Import/Export Framework. You must install the binary files for the Data Import/Export Framework by using the CU7 update installer.

The Microsoft Import Export Framework is a very powerful tool for importing and exporting Data. It has predefined entities which map the data to the desired fields and validates the data. The data is at first migrated to a staging environment where it can be validated once again. After that, it is finally transferred to the AX tables and new records are created or existing records are updated. There are 5 main steps to import Data using the Framework:
  1. Prepare Data Source
  2. Select an AX entity
  3. Map and Validate Data
  4. Transfer to Staging Tables
  5. Transfer from Staging Tables to final AX destinations.
The framework also allows creating customized entities. I will be writing in detail much more about data migration scenarios in Dynamics AX 2012 so visit us frequently if this is something of your interest!