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

Multiline string in ABAP

Former Member
0 Likes
6,120

Hi,

I want to have string value as multiline i.e. if I print it output should be in multiline.

Example:

write anystring

output:

hi

how

are you

possible method would be to concatenate function with separater as newline character. I have very limited knowledge of abap hence need your help

regards,

Gourav

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,160

Hi

Split the string into 3 different strings of your length and display them in individual lines and display.

SPLIT STR INTO STR1 STR2 STR3.

OR DO OFFSETTING OF THE STRING into 3 strings and display

Reward points for useful Answers

Regards

Anji

9 REPLIES 9
Read only

Former Member
0 Likes
3,161

Hi

Split the string into 3 different strings of your length and display them in individual lines and display.

SPLIT STR INTO STR1 STR2 STR3.

OR DO OFFSETTING OF THE STRING into 3 strings and display

Reward points for useful Answers

Regards

Anji

Read only

0 Likes
3,160

Hi Anji,

The question is not related to printing it is about getting multiline string. I am not going to print this string but it will be use for passing value somewhere else.

Is there any newline character in ABAP??/

regards,

Gourav

Read only

0 Likes
3,160

for new line

CL_ABAP_CHAR_UTILITIES=>NEWLINE

if its with carriage return

CL_ABAP_CHAR_UTILITIES=>CR_LF

you can use split string at CL_ABAP_CHAR_UTILITIES=>CR_LF into ......

Read only

Former Member
0 Likes
3,160

Hello,

Do like this.


DATA: LV_CHAR(132) VALUE
'I want to have string value as multiline'.
DATA: BEGIN OF ITAB OCCURS 0,
        FIELD1(20),
        END OF ITAB.

SPLIT LV_CHAR AT SPACE INTO TABLE ITAB.
LOOP AT ITAB.
  WRITE:/ ITAB-FIELD1.
ENDLOOP.

Vasanth

Read only

athavanraja
Active Contributor
0 Likes
3,160
data: stringtab type standard table of string .
data: wa_string type string .

split <sorucestring> at <separator> into table stringtab .

loop at stringtab into wa_string .
write:/ wa_string .

endloop .
Read only

former_member784222
Active Participant
0 Likes
3,160

Hi,

The following code could help:



Data: begin of itab occurs 0,
          text(100),
        end of itab.

data: c_string type string value 'Hi How are you'.

Split c_string at space into itab.

loop at itab.
  write:/ itab-text.
endloop.

Thanks and regards,
S. Chandra Mouli.


Read only

Former Member
0 Likes
3,160

Thanks to all, My question is solved and points are rewarded....

Read only

Clemenss
Active Contributor
0 Likes
3,160

Hi Gourav,

something like this?


data:
  lv_multiple_lines type string.
concatenate
  'line1'
  'line2'
  'line3'
  'line4'
  'line5'
  into lv_multiple_lines
separated by CL_ABAP_CHAR_UTILITIES=>NEWLINE

Regards,

Clemens

Read only

Former Member
0 Likes
3,160

Hi Clemens,

I did same.

Regards,

Gourav