December 29, 2013

Available Courses For Dynamics AX 2012

Here are available Axapta certifications courses.
However there are limited certification are available till date, but study materials are available as resources/references.
Have a look on below table.



Course Code Course name
80163A What's New - Application in Microsoft Dynamics® AX 2012 for Supply Chain Management and Manufacturing

80164A What's New - Application in Microsoft Dynamics® AX 2012 for Finance, PA, Case Mgmt., HRM and Public

80165A What's New - Technical in Microsoft Dynamics® AX 2012 for Implementation

80219A Financials I in Microsoft Dynamics® AX 2012

80220A Financials II in Microsoft Dynamics® AX 2012

80221A Installation and Configuration for Microsoft Dynamics® AX 2012

80299A What's New - Technical in Microsoft Dynamics® AX 2012 for Development

80300A Introduction to Microsoft Dynamics® AX 2012

80302A Fixed Assets in Microsoft Dynamics® AX 2012

80303A Development I in Microsoft Dynamics® AX 2012

80304A Development II in Microsoft Dynamics® AX 2012

80305A Supply Chain Foundation in Microsoft Dynamics® AX 2012

80306A Distribution and Trade in Microsoft Dynamics® AX 2012

80307A Enterprise Portal Development in Microsoft Dynamics® AX 2012

80308A Procurement in Microsoft Dynamics® AX 2012

80309A Microsoft Dynamics® AX 2012 Process Manufacturing Production and Logistics

80310A LEAN Manufacturing in Microsoft Dynamics® AX 2012

80311A Service Industries in Microsoft Dynamics® AX 2012

80312A Development III in Microsoft Dynamics® AX 2012

80313A Development IV in Microsoft Dynamics® AX 2012

80314A Discrete Manufacturing Basics in Microsoft Dynamics® AX 2012

80315A Discrete Manufacturing Advanced in Microsoft Dynamics® AX 2012

80316A Project Essentials in Microsoft Dynamics® AX 2012

80317A Project Advanced in Microsoft Dynamics® AX 2012

80318A Reporting in Microsoft Dynamics® AX 2012

80338A Microsoft Dynamics® AX 2012 Public Sector – Financials

80339A Bill of Materials in Microsoft Dynamics® AX 2012

80414A Service Management in Microsoft Dynamics® AX 2012

80415A Public Sector Procurement and Payables in Microsoft Dynamics® AX 2012

80416A Application Integration Framework and Services in Microsoft Dynamics® AX 2012

80419A Manufacturing Execution in Microsoft Dynamics® AX 2012

80420A Data Upgrade and Code Upgrade to Microsoft Dynamics® AX 2012

80421A Sales and Marketing in Microsoft Dynamics® AX 2012

80422A Intercompany Setup and Order Processing in Microsoft Dynamics® AX 2012

80423A Master Planning in Microsoft Dynamics® AX 2012

80424A Product Configuration in Microsoft Dynamics® AX 2012

80427A Warehouse Management in Microsoft Dynamics® AX 2012




-Harry

November 16, 2013

Error: An unbalanced X++ TTSBEGIN/TTSCOMMIT pair has been detected.

Error: An unbalanced X++ TTSBEGIN/TTSCOMMIT pair has been detected.



Error:

When trying to create a new record(s) in any table system sows following error
eg. Sales Order and this error always appear.
clip_image001


Possible Reason(s):
TTS level '1' usually leaves your Ax session in an unusable state
that you can't close properly.
Check all code for form or class from where this error comes and count the ttsbegin and ttscommit there must be same like if u write 2 ttsbegin u must have to write 2 ttscommit.

Solution:
To resolve this error this TTS level should be ZERO, Run this job to get rid of that error, this job will find the tts level where its greater than zero and make it zero by calling TTSABORT.
static void TheAxaptaResetTTS(Args _args)
{
    while (appl.ttsLevel() > 0)
    {
        info(strfmt("Level %1 aborted",appl.ttsLevel()));
        ttsAbort;
    }
}


Other Info: 
ttsBegin: marks the beginning of a transaction. This ensures data integrity, and guarantees that all updates performed until the transaction ends (by ttsCommit or ttsAbort) are consistent (all or none).
ttsCommit: marks the successful end of a transaction. This ends and commits a transaction. MorphX guarantees that a committed transaction will be performed according to intentions.











October 17, 2013

How to delete all the transaction inside any company in the AXapta

How to delete all the transaction inside any company in the AXapta


1. Open AOT (Ctrl +  D)

2- Open the class Node

3- Search for SysDatabaseTransDelete Class
4-Right click on the this class  select Open

6-Click yes on the message box appears
7-Info message will appear to you "operation completed"

Here we are.... All transaction data is now deleted from database.


-Harry

Method Modifiers Supported by X++

 Method Modifiers Supported by X++


Method Modifiers Supported by X++
Modifier
Description
static
Static methods are accessed via class declarations. Fields can’t be accessed from within a static method.
final
Final methods can’t be overridden by methods with the same name in derived classes.
abstract
Abstract methods have no implementation. Derived classes must provide definitions for abstract methods.
server
Server methods can execute only on an Application Object Server. The server modifier is allowed only on static methods.
client
Client methods can execute only on a MorphX client. The clientmodifiers are allowed only on static methods.
display
Display methods are invoked each time a form or report is redrawn. The display modifier is allowed only on table, form, form data, report, and report design methods.
edit
The edit method is invoked each time a form is redrawn or a user provides input through a form control. The edit modifier is allowed only on table, form, and form data source methods.


For More Details on the same check below link

Abstract Class and Abstract Method in AXapta

     Abstract Class and Abstract Method

Abstract Class:
When we declare a class as abstract, this class cannot initiate in X++ code. To use this class or its method we have to first extend this class than only we are able to use this class or its method. To understand the abstract class consider following example
We have three classes
     1.      absClass  (it’s an abstract class)
     2.      normalClass (an another class which will use the absClass methods)
     3.      extendAbsClass (this class will extends the absClass)

    1.      abstract class absClass
     {
     }

    void printName()
   {
    ;    info("AbsClass... Deepak"); 
   }


    2.      class extendAbsClass extends absClass
{
}

    3.      class normalClass
{
}

  void accessAbsClass()
{
    absClass        absClass;
    extendAbsClass  extendAbsClass;
    ;
 //   absClass = new absClass();    // this declaration will throw error “Object could not be created because class absClass is abstract” so first we extend absClass into extendsAbsClass and further use extendsAbsClass to access absClass methods.
    extendAbsClass  = new extendAbsClass();
    extendAbsClass.printName();
}


Abstract Method:

When we declare a method as abstract , this method should be overload in child class or we can say , this method  should be declare/initiate in child class, than only we can use this class or its method.
Note:
a.      Abstract methods may only be declared in abstract classes.
b.      No code or declarations are allowed in abstract methods.

We have three classes
i.                    absMethodClass
ii.                  extendAbsClass
iii.                NormalClass

1.      abstract class absMethodClass
{
}

abstract void absPrintName()
{
                        // we cannot declare any code in abstract method
}

2.      class extendAbsClass extends absMethodClass
{
}

void absPrintName()
{
    ; // we have to initiate abstract method here as this class extends the abstract class.
    info("abstract method declaration in derived class");
}
3.      class childClass_1
{
}

void accessAbsClass()
{
    extendAbsClass  extendAbsClass;
    ;
    extendAbsClass  = new extendAbsClass();
    extendAbsClass.absPrintName();

}


- Harry

October 02, 2013

Connecting to Databases through X++ PART -IV

Connecting to Databases through X++ PART -IV


Connection Class:
Connection class is mainly used for accessing the database in which a user has logged into AX i.e. Current Database and carry out the operations. This class is exetensively used in ReleaseUpdateDB classes, the classes used in data upgrades. This class cannot be run on client and should always be run on server. One more unique thing that I noticed is that the statements that you want to execute should be asserted first for permissions and then passed on to other method where they are executed. Create a class with following methods and set its RunOn property to Server.
class TestSQLExecuteClass
{
}




//This method tests the permissions for statement and then calls the method that will execute the statement
static void dbConnectionClass()
{
    ResultSet   rs;
    SqlStatementExecutePermission perm;
    ;
    perm = new SQLStatementExecutePermission("select * from CustTable where DATAAREAID = ‘CEU’");
    perm.assert();
    rs = TestSQLExecuteClass::statementExeQuery("select * from CustTable where DATAAREAID = ‘CEU’");
    while (rs.next())
    {
        info(rs.getString(1));
    }
    CodeAccessPermission::revertAssert();
}
//Executes the passed statement
private static ResultSet statementExeQuery(str _sql, Connection _con = null)
{
    ResultSet   resultSet;
    Statement   statement;
    ;
    try
    {
        if(!_con)
        {
            _con = new Connection();
        }
        statement = _con.createStatement();
// Do not call assert() here, do it in the caller
        // BP deviation documented
        resultSet = statement.executeQuery(_sql);
    }
    catch (Exception::Error)
    {
        throw error("@SYS99562");
    }
    return resultSet;
}
Now you can call the method in a job as shown below:
static void dbConnectionClass(Args _args)
{
    ;
    TestSQLExecuteClass::dbConnectionClass();
}
These examples shown here are pretty simple and easy to understand and start with. Hope it helps you in building ‘connections’

Related posts, 


-Harry

October 01, 2013

Microsoft MVP (Most Valuable Professorial) Award 2013

Hi All,

:) :) Microsoft awarded me by MVP 2013......... :)  :)


This award is given to exceptional technical community leaders who actively share their high quality, real world expertise with others. I would like to say thanks to Microsoft ,MVP  team members and all blog readers who make this possible for me.
Thanks again to all of you.

To read more about MVP follow below link


Regards
Deepak Agarwak aka Harry

September 16, 2013

Connecting to Databases through X++ PART -III

Connecting to Databases through X++ PART -III

      OLEDB Connection:

OLEDB is a set of APIs designed by Microsoft and used for accessing different types of data stored in a uniform manner. Dynamics AX as such doesn’t have any specific classes built for this purpose. But one can make use of .Net Framework’s System.Data.OleDb namespace through AX’s COM Interoperability feature and use it in AX.
Below is an example code that depicts this scenario:




static void dbOLEDBConnection(Args _args)
{
    System.Exception                    e;
    System.Data.OleDb.OleDbConnection   objConn;
    System.Data.OleDb.OleDbCommand      cmdSelect;
    System.Data.OleDb.OleDbDataReader   reader;
    InteropPermission                   perm;
    str connectStr = "Provider=SQLNCLI.1;Integrated Security=SSPI;"+
                     "Persist Security Info=False;Initial Catalog=AX2009;Data Source= theAxapta ";
    str exceptionStr;
    ;
    try
    {
        perm = new InteropPermission(InteropKind::ClrInterop);
        if (perm == null)
        {
            throw error("Error with file permissions");
        }
        perm.assert();
        objConn = new System.Data.OleDb.OleDbConnection(connectStr);
        objConn.Open();
        cmdSelect   = objConn.CreateCommand();
        cmdSelect.set_CommandText("SELECT * FROM CustTable where DATAAREAID = ‘CEU’");
        reader      = cmdSelect.ExecuteReader();
        while (reader.Read())
        {
            info(reader.GetString(0));
        }
    }
    catch(Exception::CLRError)
    {
        CodeAccessPermission::revertAssert();
        perm = new InteropPermission(InteropKind::ClrInterop);
        if (perm == null)
        {
            return;
        }
        perm.assert();
        e = ClrInterop::getLastException();
        CodeAccessPermission::revertAssert();
        while( e )
        {
            exceptionStr += e.get_Message();
            e = e.get_InnerException();
        }
        info(exceptionStr);
    }
    catch
    {
        error("An Exception has occurred");
    }
    if(objConn)
        objConn.Close();
}


Other related posts:



-Harry

September 12, 2013

AX 2012 R2 VPC And Materials Download


AX 2012 R2 VPC And Course Materials Download

You must have Partner Source credentials to access the following links.

Dynamics AX2012 R2 VPC
VPCLink

Dynamics AX2012 R2 Course
 Materials


-Harry

X++ code to create & post General Journal

X++ code to create & post General Journal

Some time we need to generate a General Journal through X++ code rather than go to GL module. For eg. WE are creating a journal after completion of some particular condition.
Try following code to create a General Journal and than post in in the same code through X++.

static void theaxapta_CreateGLJournalPost(Args _args)
{
AxLedgerJournalTable journalTable; // class
AxLedgerJournalTrans journalTrans; // class
container acctPattern;
container offSetAcctPattern;
LedgerJournalTable ledgerJournalTable; // table
ledgerJournalCheckPost ledgerJournalCheckPost;// table
;
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(1200);
journalTrans.parmAccountType(LedgerJournalACType::Ledger);
acctPattern = ["21345-Disp","211345", 2, "Department","0000114","CostCenter", "0000087"];
journalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(acctPattern));
journalTrans.parmOffsetAccountType(LedgerJournalACType:: Ledger );
offSetAcctPattern = ["40100-Disp","40100", 4, "Department","0000114","CostCenter", "0000087", "CustomPurposeA","Nile", "CustomPurposeB", "Site1"];
journalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId( offSetAcctPattern));
journalTrans.save();
ledgerJournalCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(journalTable.ledgerJournalTable(),NoYes::Yes);
ledgerJournalCheckPost.run();
info(strFmt("Journal No. %1.", journalTable.ledgerJournalTable().JournalNum));
}


Other Related Posts:
Inventory Transfer Journal through X++ code

-Harry

September 11, 2013

How to use Complex Query Ranges in Dynamics AX

Use of Complex Query Ranges in Dynamics AX

     1.  Adding a query with a datasource.


query = new Query();
dsInventTable = query.addDataSource(tableNum(InventTable));
// Add our range
queryBuildRange = dsInventTable.addRange(fieldNum(InventTable, DataAreaId));

    2.  Simple criteria


Lets find the record where the value of ItemId field is Item1. Take note of the single quotes and parenthesis surrounding the entire expression.

queryBuildRange.value(strFmt('(ItemId == "%1")', queryValue("Item1")));
Find records where the ItemType is Service. Note the use of any2int().
queryBuildRange.value(strFmt('(ItemType == %1)', any2int(ItemType::Service)));


Find records where the ItemType is Service or the ItemId is Item1. Note the nesting of the parenthesis in this example.

queryBuildRange.value(strFmt('((ItemType == %1) || (ItemId == "%2"))', any2int(ItemType::Service), queryValue("Item1")));

Find records where the modified date is after 1st January 2000. Note the use of Date2StrXpp() to format the date correctly.

queryBuildRange.value(strFmt('(ModifiedDate > %1)', Date2StrXpp(01012000)));

    3.  Complex criteria with combined AND and OR clauses


We need to find those records where the ItemType is Service, or both the ItemType is Item and the ProjCategoryId is Spares. This is not possible to achieve using the standard QueryRange syntax.


queryBuildRange.value(strFmt('((%1 == %2) || ((%1 == %3) && (%4 == "%5")))',fieldStr(InventTable, ItemType),any2int(ItemType::Service),any2int(ItemType::Item),fieldStr(InventTable, ProjCategoryId),queryValue("Spares")));

-Harry

Connecting to Databases through X++ PART -II

Connecting to Databases through X++ PART -II


    ADO Connection:
ADO is a set of COM objects for accessing databases or data stores. In AX we have following Classes/Objects which help to implementing ADO concept.

Class Name
Description
Helps in establishing a connection to the target database.
Helps in executing a command (a Text type or a Stored procedure)
Stores the data
A collection of all fields in CCADORecordSet
A single field from the collection of fields
A class that helps in passing parameters that a command needs or demands

Here is an example:

static void dbCCADOConnection(Args _args)
{
    CCADOConnection connection = new CCADOConnection();
    CCADOCommand    ccADOCommand;
    CCADORecordSet  record;
    str connectStr = "Provider=SQLNCLI.1;Integrated Security=SSPI;"+
                     "Persist Security Info=False;Initial Catalog=AXDEVDB;Data Source= theAxapta";
    COM     recordSet;  /*This is required to call moveNext method to parse the record set. In AX 4.0 this method was there in the CCADORecordSet class but in AX 2009 this has been deleted*/
    ;
    // Executing a SQL Statement
    try
    {
        connection.open(connectStr);
        ccADOCommand = new CCADOCommand();
        ccADOCommand.commandText("Select * from CustTable where DataAreaId = ‘CEU’");
        ccADOCommand.activeConnection(connection);
        record = ccADOCommand.execute();
        recordSet = record.recordSet();
        while (!record.EOF())
        {
            info(any2str(record.fields().itemIdx(0).value()));
            recordSet.moveNext();
        }
    }
    catch
    {
        error("An Exception has occurred");
    }
    connection.close();
}





Previous Post:


-Harry