Interview Questions

Thursday, May 8, 2014

Sample to manipulate string Function in Dynamics AX

1 – str2Capital () : Convert first character in to Capitalstatic 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 characterstatic 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'.

No comments:

Post a Comment