Showing posts with label AX2009. Show all posts
Showing posts with label AX2009. Show all posts

Saturday, March 3, 2012

Implementing the Account and Financial Dimensions Framework for Microsoft Dynamics AX 2012 Applications

Hi there!

As you probably already know, in AX 2012, the account and financial dimensions framework has been modified from its previous version (AX 2009). It is really interesting to see an evolution in the financial dimensions framework since AX 2009.

Let's go back a little bit. In AX 2009, a ledger account was represented by a single string value and was considered to be separate from the financial dimensions. In addition, Ledger accounts were stored in the LedgerTable table.

For example, financial dimensions. (Financial dimensions were referenced as an array of up to 10 array elements that each held the string value of a foreign key to the Dimensions table. All financial dimension values were stored in the Dimensions table.)

Based on my recent research, Microsoft has dramatically enhanced the account and financial framework to provide substantially more functionality. Further, to support this new functionality, the data model has also been completely redesigned. Ok, sounds great and impressive but what does this means for us?

Well, our job is about to get more interesting. Why? Because...

  1. We will need to update every reference to ledger accounts and financial dimensions in existing applications to reference the new data model.
  2.  
  3. Each of the account and financial dimensions patterns has a corresponding AX form control.
  4. Form controls provide a consistent implementation of the functionality across the application and a simplified programming model for the framework.
  5. Account form controls combine the Segmented Entry control and a controller class. Further. the Segmented Entry control is a general-purpose Microsoft Dynamics AX client control that is being introduced in AX 2012.
  6. The controller class is an X++ class that handles the events raised by the Segmented Entry control.
  7. The combination of a control and an underlying class allows the user to see a dynamic number of segments, based on the values the user provides.

This is indeed a great opportunity for us to keep learning, adjusting and evolving around this new changes. However, this opportunity comes with great challenges, lots of study, and practice. Well, let's not be too worried about it as AX 2012 still has ledger accounts and financial dimensions, but the definition of these terms has changed slightly to account for the new functionality.

Anyhow, there is great white paper that goes over all the new changes in great detail. You can download the white paper here

Take care!

Monday, September 26, 2011

Code to refresh system tables in AX 2009 - SysClientSession Table

The following code will refresh the system tables in AX 2009. I had an issue with the SysClientSession table this morning and I found some documentation about from Microsoft where they suggest running a script to allow the syscronozation of systables.

The kernel uses the SYSTABVERSION parameter value in the SQL SystemVariables table to synchronize its list with the DataBase

The following were the errors I got:

1- The database reported (session 1 (-AOS-)): [Microsoft][SQL Native Client][SQL Server]Invalid object name 'SYSCLIENTSESSIONS'.. The SQL statement was: "SELECT A.SESSIONID,A.SERVERID,A.VERSION,A.LOGINDATETIME,A.LOGINDATETIMETZID,A.STATUS,A.USERID,A.SID,A.USERLANGUAGE,A.HELPLANGUAGE,A.CLIENTTYPE,A.SESSIONTYPE,A.CLIENTCOMPUTER,A.RECVERSION,A.RECID FROM SYSCLIENTSESSIONS A WHERE (SERVERID=?)"

2- Internal Error occurred executing stored procedure when creating session for the AOS.

Please backup your DB before running this script.

update SqlSystemVariables set value = value - 1 where parm = 'systabversion'

Once you do this please restart your AOS and the problem should be fixed.

Wednesday, September 14, 2011

AX 2009 Data Import / Export

The following post is about shows how to:
1-   Export data from a company in AX using a definition Group
2-   Creating a new company that will take the new data
3-   Importing the data exported from step 1 into the new company created in step 2 using a definition group as well.
In a current project, I needed to freeze the Test1 environment due to some focus testing of a certain functionality we implemented. At the same time, we needed to allow the uses to keep testing other customizations without affecting Test1.
In addition, to make the user’s lives easier, we decided to have the same data that they were using in Test1 in our Test2 instance. So, we exported the data from our Test1 environment, and then imported it to a new company in our Test2 environment.
The following steps will show this process step by step:

1-   First select the company you want to export the data from as the AX current company by clicking in company name in the right lower corner of your AX interface.

2-   This would open the “Select Company” form as shown;
3-   Select  Administration (module)
4-   Under periodic->Data exports /import ->Click Export to
5-   The “Export options” form will appear
6-   Select a definition group. You can either create a new definition group to include what you need, or just choose ALL to get all the tables.

NOTE: In some cases, the already defined “ALL” definition group will not have all the tables, so in this case you would have to create a new definition group. In my case I created a new one name “ALL_NewDef” that included the latest tables.

7-   Enter a file name and select where to save it
8-   Click OK. At this point the company date export process should be done (after processing of course), and the files (.dat & .def) should have be saved on your computer.

Now, let’s create a new company

9-   Make sure that the selected company empty and click area node Administration
10- Click company Accounts under Common forms
11-   Press (Ctrl + N) in order to Create new company
12-   Make sure you select the newly created company as the current company

Import company file already exported in the prior steps and click Administration


13- Under periodic->Data exports /import ->Click import; The “Import options” screen will appear
14- Select the “import definition group” drop down list and choose ALL (otherwise create your own)
15-   Select the .dat file (exported before) and Click Ok to start the process

The import process may take some time according to the size of transactions in the original (exported) company.
In addition, you can choose to delete all the transaction data before the import when you are importing a .dat file o an existing company account to update the data.

Tuesday, August 16, 2011

Ax 2009 SSRS Videos

While looking for some information related to AX 2009 SSRS I found a bunch of videos related to SSRS and AX 2009.

Here is the link:

http://youtu.be/ZIoEZWaiBXI

Wednesday, July 20, 2011

Create Electronic Invoice to Text File Format - Ax 2009 -

 The following code is to create a company country specific requirement. In addition, the logic is specific to the needs of my customer, but I'm sure you will be able to find great examples on how to create directories with WinApi and manipulate text files with the TextIO function.

The project flow is as follow:

1- The user posts an invoice
2- After the invoice has been posted, the KMN_eInvoiceCreation class is called with parameters  (This call is not posted here)
3- The class has several methods from creating the path file name, to writing a very specific logic into a text file.
4- The class saves the file into a specific location

The project produces the following text file contents:

DC|3.0|||15/07/2011|Pago en una sola exhibición||150.22|||||270.02||I
EM|KIE9512187VA|Compania de Ventanas S.A.

DF|Juytyu|130|Piso 7 y 8, Desp.801|Lostre|||MiguelHidalgo|DF|Mexico|999
RC|TORE621221HP9|Elizabeth Araya Reyes
DM|Teaneck|308||Warrrr|||Guadalupe|NL|Mexico|986589

CN|1.00|||Libro de Respuestas 3A/2A/A|25.00|25.00
CN|1.00|||Diploma de Finalización 7A|2.61|2.61
CN|1.00|||Diploma de Finalización 6A|2.61|2.61
CN|1.00|||Flashcards 1-50|120.00|120.00
IA|102433660003476|08/10/2010|Laredo
IT|IVA|33.80|16.00
TI||33.80


This project uses a custom table to store all the SalesParmTable data as we needed to provide a way for the user to re-run a posted invoice.

The following are the base enums I'm using.

Friday, July 15, 2011

SubStr function - Axapta

str SubStr (str _text, int _position, int _chars)

SubStr("MyString",20,3);  // Returns ""
SubStr("MyString ",4,50);  // Returns "tring"

Monday, July 11, 2011

Create loop from an AX form DataSet - Ax 2009

Sometimes we need to loop through values at the form level. The following code loops (for loop) the SalesParmTable in the CloseOk() Form method.        


        //Create Lines
        for (localSalesParmTable = salesParmTable_ds.getFirst();
              localSalesParmTable;
              localSalesParmTable = salesParmTable_ds.getNext())
        {

              ....Implementation....
        }

Code to check for "garbage" in the ReleaseUpdateScripts table - AX 2009

ReleaseUpdateScripts    releaseUpdateScripts;
Counter                 total;
Counter                 invalid;
;
while select ClassID
    from    releaseUpdateScripts
    group by ClassID
{
    total++;
    if (classid2name(releaseUpdateScripts.ClassID) == '')
    {
        info(int2str(releaseUpdateScripts.ClassID));
        invalid++;
    }
}
info(strfmt(@"Found %1 invalid classIds out of %2", invalid, total));

Wednesday, July 6, 2011

Workaround to Exception::CLRError using System.IO.StreamWriter

In one of my projects I was using the System.IO.StreamWriter to write data into a text file in X++. Everything went well until I started testing for exception in order to handle them (the System.IO is a .Net class that allows us to maniluplate file operations, including folders. So, I though in catching the exception with the Exception::CLRError one. )

The problem I was having was that when an exception was raised by a problem creating the file (Incorrect file name), the operation will not fall into the Exception::CRLError exception, Instead, it would just crash and I wasn't able to properly handle the exception.

The reason for this is that when using an AX class that runs on the server, the exception never comes back to the client and therefore cannot be handled correctly. I'm using the SalesFormLetter class main method to call my own class after an invoice is generated, and this class (SalesFormLetter) is (1) an abstract class and (2) runs on the server and I really did not want to do this.

A workaorund is to use the TextIO class in AX along with the FileIoPermission. For example, when using the TextIo to create (and/or overwrite) a file, we get a null value when the file could not be created (and/or overwritten). Then, we can throw an exception when the object is null.

In my case I have a central class that handles all errors, so when the TextIO object is null, I call this class and I throw an error, then the error comes back to my method and falls into the Exception::Error exception.

The following is the code