Friday, 3 December 2010

How to Manipulate String function in Dynamics AX

1.) Convert first charector in to Capital [str2Capital()]
        static void Job99(Args _args)
        {
            str source,desti;
            ;
            source  = 'dyanamics ax';
            desti   = str2Capital(source);
            info(strfmt("%1 : %2",source,desti));
        }
    Using str2CapitalWord() method can convert all first cherectors of the words in Sentence.
   
2.) Concatenate the word or sentence from specified charector. [str2Con()]
        static void Job99(Args _args)
        {
            str         source,desti;
            container   Con;
            int         i;
            ;
            source  = 'dyana,mic,s ax';
            Con   = str2Con(source,',');
            for (i = 1; i <= conlen(Con); i++)
            {
                info(strfmt("%1",conpeek(Con,i)));
            }
        }

3.) Format string type Date & return as Date type [str2Date()]
        static void Job99(Args _args)
        {
            str         input;
            Date        output
            ;
            input  = '05/30/2010';
            output  = str2Date(input,213);
            info(strfmt("%1",output));
        }
        123 : DMY
        213 : MDY
   
        Output will give as DMY format.
       
4.) Check a string which conatin integer value [strIntOk()]
   
        static void Job99(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.) Check whether end charectors are matching or not [strEndsWith()]
   
        static void Job99(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.) Concatanate string from Left side with fix no. of charectors [strLFix()]
   
        static void Job99(Args _args)
        {
            str         input;
            str         output;
            ;
            input  = 'dyanmics ax';
            output  = strLfix(input,5);
            info(strfmt("%1",output));
        }

No comments:

Post a Comment