Search This Blog

Thursday, May 31, 2012

AX2012 StrSplit Function with list Iterator in X++


May be this is useful for lot of persons while importing or exporting for splitting the string and get the string of the required position

private str strSplit(str _splitString,str _splitchar,int _pos)
{
    List strlist=new List(Types::String);
    ListIterator    iterator;
    container       packedList;
    ;
    strlist=strSplit(_splitString,_splitchar);
    iterator = new ListIterator(strlist);
    while(iterator.more())
    {
        packedList += iterator.value();
        iterator.next();
    }
    return conPeek(packedList,_pos);
}

To call you can use like following


str strvalue="Test|Test2|Test3|Test4";
info(createProduct.strSplit(strvalue,"|",2));

2 comments:

  1. Giving Error as StrSplit Function not defined!

    ReplyDelete
    Replies
    1. create the above function in global,may be globalclass already having this method, give your own name and add it into global

      Delete

Thanks for visiting my blog,
I will reply for your comment within 48 hours.

Thanks,
krishna.