Split Strings in Navision

Hi Experts,

I need to split the Strings,but i don’t no whether this is possible…as i tried for all String functions…[:(]

E.g. String = Dear “Name” Your balance is “Balance”

I need the result as:

String1 = Dear

String2 = “Name”

String3 = Your

String4 = balance

String5 = is

String6 = “Balance”

Can anyone tried of this…or help me…



Hi VKunj,

welcome to DUG…!!!

You can use string functions…

Find the space and copy the string… save it to STRING 1 and also Delete STRING1 from the Original String

Repeat the same thing till you get the last word of your string…!!!


In addition to what Kashyap said, you can use STRPOS for finding out substring:

Position := STRPOS(String, SubString)
And then  COPYSTR and DELCHR for copying and then deletion of sub-string.

Hi Kashyap,

Thanks for your reply.

But i cannot take the space alone, as for E.g if i have a word say “Balance (LCY)” field, in this case i want the full word.

Actually the line will be looking like this…

E.g: Dear “Customer” the balance is “Balance (LCY)”

So the total splitted string should be 6 and not 7… “Balance (LCY)” is a 1 word.



Hi Aswini,

Is your line have fixed format…??? i mean “(LCY)” will be there just after Balance.???

In this case, Either you can fix it (I dont suggest this ever…) or if these are the last words of your sentence then you can combine them after splitting…!!!

Can you tell me why you want to split this way…???

Hi Kashyap,

The format will be like that… its not that LCY will be there… Double quotes will be there in the middle of a string as given in my example.

So i want the result as :

String 1 = Dear String 2 = “Customer” String 3 = the String 4 = balance String 5 = is String 6 = “Balance (LCY)”

Actually i want the value to be replaced in the string which is in with double quotes from a table… so i need to be splitted…

Any idea???




You have to use different string functions to fulfill the requirement…

As you have mentioned its having double quotes, then first collect those words by finding double quotes…

update the original string, and then collect rest of words finding space…

See, you have DB, you have Data, you have entries, you have requirements and you have scenairos…

So ultimately its you who have to decide how to use these functions to achieve this…

coz when you are working with strings, it can be tricky…!!!

If you have any doubt, you can ask again…!!!

Thanks Kashyap… But how to get the start and end of double quotes… from a single line…


the easiest way is to replace those double quotes with comma… coz we have function SELECTSTR(position,commastring)

else again find position of first " then find position of second " and then copy that string…!!! (dont go for this if you can get result through comma string…!!!)

I have a small function for this:

Token(VAR Text : Text[1024];Separator : Text[1]) Token : Text[1024]
Pos := STRPOS(Text,Separator);
Token := COPYSTR(Text,1,Pos-1);
IF Pos+1 <= STRLEN(Text) THEN
Text := COPYSTR(Text,Pos+1)
Text := '';
Token := Text;
Text := '';

This function can be used as follows:

String := 'Dear "Name" Your balance is "Balance"';
String1 := Token(String,' ');
String2 := Token(String,' ');
String3 := Token(String,' ');

Or simpler:

String := 'Dear "Name" Your balance is "Balance"'; WHILE STRLEN(String) > 0 DO BEGIN i := i + 1; String[ i ] := Token(String,' '); END; String := ‘Dear “Name” Your balance is “Balance”’;

Hi Thomas,

Thanks, but my String can be

String := ‘Dear “Name” Your balance is “Balance (LCY)”’; So I cannot split by space alone, where the last string is a single word which will get broken.

i couldn’t get either with space or with special characters alone… [:(]

So now you know about the string functions. You now know how to find spaces, finding other characters works exactly the same. Use that knowledge to figure out an efficient way to program your requirement.

Hi Kashyap,


Selectstr() works for option strings… so in this case it wont work…

And StrPos() in help - it is given as

// The STRPOS function is case-sensitive. Furthermore, it only // returns the position of the 1st occurrence of the substring.

i m trying it with all string functions…let me see…

Dear VKunj, in order to get qualified replies it would be very helpful in what context you need this. There has been lots of answers on how to split strings, and by extending this it can be done.

To me it sounds like you are trying to parse out some field names in a text string, so you can insert database values instead, is that correct?

Nothing will be broken because if no more spaces are found, the function will return the complete remaining string.

I have tried and tested with your string for myself development, and i got the 6 strings…

I cant give you that solution because you have to develop it but here is the hints…

Create a Text Variable STRING to store your original string…

other 6 text variables to split and store…

integer i to use in loop

pos an integer variable with dimension (based on how many double quotes can be there…)

use FOR loop with increasing i,

store the position of double quotes in your pos[i] array…

then using delstr and pos[i] delete the double quotes,

then again use for loop to insert comma at the pos[i] (pos[i] indicates the position of double quotes]

Now your string has comma and you can use SELECTSTR

Just make the codes based on my above description…

You will get that double quote phrases, but to split remaining parts you have to use STRPOS to find space and DELSTR and COPYSTR…


Dear SNielsen,

That is what is exactly needed… like i have to display the values in between the strings…which has Double Quotes(for identification)…



Hi Guys… Thanks for all your replies… and i have got the solution using string functions…



Hey Aswini,

Thats good that you get what you were looking for…!!!

Hi Thomas,

My String is X|Y|Z

The string is dynamic, i tried your common function by unfortunately , its picking up last value.

I wrote the function as:

Where Split : Text[1024], i used as return type.

SplitString(Text : Text[1024];Separator : Text[1]) Split : Text[1024]

Pos := STRPOS(ltxtroutingNo,Separator);


Split := COPYSTR(ltxtroutingNo,1,Pos-1);

IF Pos+1 <= STRLEN(ltxtroutingNo) THEN

Text := COPYSTR(ltxtroutingNo,Pos+1)


Text := ‘’


Split := Text;

Text := ‘’;

Am i writing the function in wrong manner? :frowning: