Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Single String into Multiple rows in SAP-ABAP.

Former Member
0 Kudos

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.

8 REPLIES 8

aferngas
Active Participant
0 Kudos

You can use SPLIT statement.

DATA lt_substr TYPE STANDARD TABLE OF string.

SPLIT 'ABC#DEF#GHI' AT '#' INTO TABLE lt_substr.

Cheers,

Alex

Former Member
0 Kudos

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.

Former Member
0 Kudos

Can you please elabrate by coding.

Former Member
0 Kudos

you need to know 2things in ABAP.

New line character in ABAP ..

Split statement in ABAP... Splitting Character Strings (SAP Library - ABAP Programming (BC-ABA))

Please read both before doing anything.,

Former Member
0 Kudos

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.

raymond_giuseppi
Active Contributor
0 Kudos

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

0 Kudos

Can you please elabrate by coding.

0 Kudos

Would be considered as spoon feeding,  (Read the Rules of Engagement)

(And a code for a single statement....)

Regards,

Raymond