Home > X++ stuffs > System Classes in Dynamics AX

System Classes in Dynamics AX

 

I have provided few sample examples of System Class function which are really useful in development of X++.

 

RandomGenerate Class:

 

This class generates random numbers.

static void RandomGenerateEg(Args _args)

{

    RandomGenerate objRG     = new RandomGenerate();

    Random         objRandom = new Random();

    ;

    //This generates random numbers specified within the given range

    info(int2Str(objRG.randomInt(10,55)));

 

    //This generates random numbers

    info(int2Str(objRandom.nextInt()));  

}

Executing this job generates random numbers. But it doesn’t guarantee that the numbers will not be repeated. So if the user needs unique number, he has to provide explicit check for that

 

Sequence Class:

 

Contrary to above class is Sequence class which generates the numbers in order.

 

static void SequenceEg(Args _args)

{

    Sequence objSeq = new Sequence("Test Sequence",8,10,250,1);

    print objSeq.currval(); // Displays the current value of the object

    while(1)

    {

     print objSeq.nextval(10);

     pause;

    }

}

Sequence class takes the following parameters: SequenceName which can be a string of your choice, Identification No for the sequence, Initial Value, Maximum value

and a flag which indicates whether the cycle has to be repeated if maximum value is reached.

 

The method “nextVal” takes the value to be incremented for next number as parameter.

 

LastAOTSelection Class:

 

This class prints the last accessed AOT object by the user.

 

static void LastAOTSelectionEg(Args _args)

{

    LastAOTSelection LS = new LastAOTSelection();

    ;

    print LS.first().toString();

    pause;

}

 

Keywords Class:

 

Class to list the available functions and keywords in Axapta.

 

static void KeywordsFunction(Args _args)

{

    Keywords objKG = new Keywords();

    str strOutput;

    ;

    print Keywords::isValidIdentifier(‘dddd34’);  // This method checks if the identifier is valid or nor

    print Keywords::isValidIdentifier(‘*4532’);

    pause;

 

    strOutput =  objKG.firstFunction();

    while(objKG.nextFunction()!= ”)

    {

        strOutput = objKG.nextFunction();

        info(stroutput);

    }

}

 

static void KeywordsSymbol(Args _args)

{

    Keywords objKG = new Keywords();

    str strOutput;

    ;

    strOutput =  objKG.firstSymbol();

    while (objKG.nextSymbol ()!=”)

    {

        strOutput = objKG.nextSymbol();

        info(stroutput);

    }

}

Advertisements
Categories: X++ stuffs
  1. Anitha
    February 17, 2010 at 5:25 pm

    Awesome work.. There are no examples for such classes in Developers Help .. As usual,INFORMATIVE !!!Keep rocking…

  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: