Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Formula to extract string values from concatenated column value

Hello everyone,

I am trying to make formula where I have to break my data into parts on specific occurrence of characters. I worked on a formula and succeed in breaking the column in to new line. Now I want to extract these break lines of text to use it further.  I tried making the formula where my left first record is extracting before the character '-' for multiple row its not picking the second left first value.

For example :

my column: 1.00000-50000000.00000 : 50.00 |

on breaking :  1.00000-

                     50000000.00000:

                     50.00

but when my column value exceeds

my column : 1.00000-50000000.00000 : 50.00 | 50000001.00000-150000000.00000 : 70.00 |

on breaking : 1.00000-

                    50000000.00000 :

                    50.00

                    50000001.00000-

                    150000000.00000 :

                    70.00 

its not picking the next first left value:

                   

Formula on left I am using :

whileprintingrecords;

stringvar MANG_FEE := cstr({ds_MngFeeComm.MANGE_FEE});

stringVar y := Replace(Replace(Replace(MANG_FEE,'-','-'+CHR(10)),'|',CHR(10)),':',CHR(13));

extractstring(y,'','-');

formula on right I am using :

whileprintingrecords;

stringvar MANG_FEE := cstr({ds_MngFeeComm.MANGE_FEE});

stringVar y := Replace(Replace(Replace(MANG_FEE,'-','-'+CHR(10)),'|',CHR(10)),':',':'+CHR(13));

Please help.

Tags:
replied

Hi Sana,

Try this please:

local stringvar s := {string_field}

local stringvar s1 := Replace(Replace(Replace(s,'-','-'&CHR(13)),'|',CHR(13)),':',':'&CHR(13));

local stringvar array s2 := split(s1, chr(13));

local numbervar i;

for i := 1 to ubound(s2) do

(

    if instr(s2[i],'-') > 0 then

        local stringvar fin := fin + s2[i] + chr(13);

);

Replace(fin,'-','');

-Abhilash

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question