Application Development and Automation 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: 
Read only

Single String into Multiple rows in SAP-ABAP.

Former Member
0 Likes
3,124

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
Read only

aferngas
Active Participant
0 Likes
1,815

You can use SPLIT statement.

DATA lt_substr TYPE STANDARD TABLE OF string.

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

Cheers,

Alex

Read only

Former Member
0 Likes
1,815

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.

Read only

Former Member
0 Likes
1,815

Can you please elabrate by coding.

Read only

Former Member
0 Likes
1,815

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.,

Read only

Former Member
0 Likes
1,815

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.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,815

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

Read only

0 Likes
1,815

Can you please elabrate by coding.

Read only

0 Likes
1,815

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

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

Regards,

Raymond