Skip to Content

Splitting the String

Hi All,


I hope there no key word in SDK for splitting the string. Here i am sharing my attempt for splitting the string. If any improvement required in code or logic. If any of you have any alternate thought or any other technique which already exist in SDK. please let me know.


I hope SDK Experts Horst Schaude, Alessandro Iannacci, @Stefan Krauth …… has better coding or technique then this 🙂 .


Step 1: Reuse library for splitting the string. It has two importing parameters(STRING_QU_RE -> String to be split, SPLIT_QU_RE -> Splitting Variable, Return will be collection split strings ).



Step 2: Logic for splitting the string.


Step 3: Business object for testing the Reuse Library for splitting the string.

Business Object.png

Step 4: Script for executing the Reuse Library.


Step 5: Testing the Business Object for splitting the string.


5.a: Input the String and Split Key


5.b: Click on Split String.



If this blog is help full. Please Share it, Like it and Comment it below 🙂 😆 😆 .




You must be Logged on to comment or reply to a post.
  • /
      • Hi Ludger,


             I debug it, when the function is running, the result is Ok.


        But at the end of the fuction run, it raise 4 errors at con.Find() and 4 errors at con.Substring(), every time is not success?

        • Hi Bin,

          for some reason, the script calls the substring method with a negative substring length: -16.

          So there is some bug or missing length/string validity check in the script causing this error.

          Please ask McQuddus to check and update the code.

          Best regards,


  • /
  • If anybody wants to copy & paste, this is my approach ? .

    I did it a bit differently, because the original approach assumes that your split character is only 1 character long and that there is never a split character at the end of the string. (In the first case, that would leave you with the rest of your split character in the next line; in the second case, it would leave you with an extra line in the result.)

    My import variables are:


    Also, the reuse function should be read-only so it can be used cross-deployment unit.

    import ABSL;
    import AP.Common.GDT;
    // takes the import string IV_STRING and returns a list of strings that was split
    // at the IV_SPLIT_AT character
    var result : collectionof DataType::LANGUAGEINDEPENDENT_EXTENDED_Text;
    // this converts IV_SPLIT_AT to "String" data type (otherwise there's an activation error)
    var split_at = IV_SPLIT_AT;
    var length_at = split_at.Length();
    // 1) if any of the strings are empty, return an empty result
    if (IV_STRING.Length() == 0 || length_at == 0)
    	return result;
    // 2) go through the string and split it
    var start = 0;
    while (true)
    	// check if start is out of bounds
    	// find next match
    	var pos = IV_STRING.Find(split_at, start);
    	// no further occurence found?
    	if (pos == -1)
    		// check if any characters remain at end of string
    		if (IV_STRING.Length() > start)
    			var remainder = IV_STRING.Substring(start);
    		// abort loop
    	// otherwise add found string to result
    	var sub_length = pos - start;
    	var substring = IV_STRING.Substring(start, sub_length);
    	// set new start position for next loop
    	start = pos + length_at;
    // 4) return result
    return result;

    Kind regards