AX Consulting

Just another WordPress.com site

Sample to manipulate string Function in Dynamics AX

 

1 – str2Capital () : Convert first character in to Capital
static void Jobtest(Args _args)
        {
            str source,desti;
            ;
            source  = ‘dynamics ax’;
            desti   = str2Capital(source);
            info(strfmt(“%1 : %2”,source,desti));
        }
    Using str2CapitalWord() method convert the first character of the first word in Sentence to Capital.

2- str2Con () : Concatenate the word or sentence from specified character
static void Jobtest(Args _args)
        {
            str         source,desti;
            container   Con;
            int         i;
            ;
            source  = ‘dyna,mics, ax’;
            Con   = str2Con(source,’,’);
            for (i = 1; i <= conlen(Con); i++)
            {
                info(strfmt(“%1”,conpeek(Con,i)));
            }
        }

3-  str2Date() : Date in string type & return it as Date type
static void Jobtest(Args _args)
        {
            str         input;
            Date        output
            ;
            input  = ’05/30/2010′;
            output  = str2Date(input,213);
            info(strfmt(“%1”,output));
        }
        123 : DMY
        213 : MDY

4- strIntOk () : Check a string which contain integer value
static void Jobtest(Args _args)
        {
            str         input;
            boolean     output;
            ;
            input   = ‘1294’;
            output  = str2IntOk(input);
            if(output)
                info(strfmt(“Integer Value”));
            else
                info(strfmt(“Not a Integer Value”));
        }

5- strEndsWith () : Check whether end characters are matching or not

static void Jobtest(Args _args)
        {
            str         input1,input2;
            boolean     output;
            ;
            input1  = ‘dyanmics ax’;
            input2  = ‘ax’;
            output  = strEndsWith(input1,input2);
            if(output)
                info(strfmt(“OK”));
            else
                info(strfmt(“Not OK”));
        }

6- strLFix  :  strLfix(str _str, int _lenght [, char _char])

Add character _char after string _str to obtain a string long _leng.

Default filler chararcer is ‘ ‘.

strLfix(‘aaa’, 5, ‘_’) //returns the text string ‘aaa__’.

If _str is longer than _leght function return a substring of _str.

strLfix(‘dynamics ax’,5);

//returns the text string ‘dynam’.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

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: