11-04-2013 2:19 PM
HI all,
I need to convert a single string into multiple rows using abap.
"ABC#DEF#GHI" this string has to be converted into
ABC
DEF
GHI
can anyone help me in this.
Thanks,
Vinod.
11-04-2013 2:21 PM
You can use SPLIT statement.
DATA lt_substr TYPE STANDARD TABLE OF string.
SPLIT 'ABC#DEF#GHI' AT '#' INTO TABLE lt_substr.
Cheers,
Alex
11-04-2013 2:37 PM
In addition of Alex, Now LT_sunstr will have 3 row 1 will have ABC 2nd DEF and 3rd GHI. now if you want to show them on UI.
** demo code.
loop LT_sunstr to wa. (wa type string)
write wa.
skip.
endloop.
11-04-2013 3:01 PM
11-04-2013 3:08 PM
you need to know 2things in ABAP.
Split statement in ABAP... Splitting Character Strings (SAP Library - ABAP Programming (BC-ABA))
Please read both before doing anything.,
11-04-2013 2:29 PM
Hello,
use the following line.
replace all occurrence of '#' IN line with CL_ABAP_CHAR_UTILITIES=>NEWLINE.
By using this CL_ABAP_CHAR_UTILITIES=>NEWLINE , your data will be visible to you in ABC#.. etc format but that # will be symbol of new line. so data will store in DB in ABC#... format and on UI
abc
bcd
format.
** Line, string input.
11-04-2013 2:47 PM
First check actual value of # in your string, # can be any non-displayable character, once you are sure, then you may use SPLIT statement.
Regards,
Raymond
11-04-2013 2:57 PM
11-04-2013 3:29 PM
Would be considered as spoon feeding, (Read the Rules of Engagement)
(And a code for a single statement....)
Regards,
Raymond