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

query on write statement

Former Member
0 Likes
650

Hi

How can i split a string literal into two lines

for a single statement.

i.e. write:/ 'some string

continuing here '.

This gives error how to over come this other than

write: 'some string',

'continuing here'.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
623

Hi abhimanyu,

1. The system won't understand

the broken string.

Hence, it will always give error.

2. Other option

is not to use the 72 length setting in

abap editor.

3. in se38 program source code,

click the menu

UTILITIES---->SETTINGS

4. untick the checkbox for

'Downward compatible line length(72)'

regards,

amit m.

4 REPLIES 4
Read only

Former Member
0 Likes
623
Hi

  You can use this method.

data: l_text(200) type c.

  concatenate 'some string' 
              'continuing here'
              into l_text separated by space.

  write:/ l_text.

Kind Regards
Eswar
Read only

Former Member
0 Likes
624

Hi abhimanyu,

1. The system won't understand

the broken string.

Hence, it will always give error.

2. Other option

is not to use the 72 length setting in

abap editor.

3. in se38 program source code,

click the menu

UTILITIES---->SETTINGS

4. untick the checkbox for

'Downward compatible line length(72)'

regards,

amit m.

Read only

0 Likes
623

To split a character string into two or more smaller strings, use the SPLIT statement as follows:

SPLIT <c> AT <del> INTO <c1> ... <cn>.

The system searches the field <c> for the separator <del>. The parts before and after the separator are placed in the target fields <c1> ... <cn>.

To place all fragments in different target fields, you must specify enough target fields. Otherwise, the last target field is filled with the rest of the field <c> and still contains delimiters.

If all target fields are long enough and no fragment has to be truncated, SY-SUBRC is set to 0. Otherwise it is set to 4.

DATA: STRING(60),

P1(20) VALUE '++++++++++++++++++++',

P2(20) VALUE '++++++++++++++++++++',

P3(20) VALUE '++++++++++++++++++++',

P4(20) VALUE '++++++++++++++++++++',

DEL(3) VALUE '***'.

STRING = ' Part 1 *** Part 2 *** Part 3 *** Part 4 *** Part 5'.

WRITE STRING.

SPLIT STRING AT DEL INTO P1 P2 P3 P4.

WRITE / P1.

WRITE / P2.

WRITE / P3.

WRITE / P4.

The output appears as follows:

Part 1 *** Part 2 *** Part 3 *** Part 4 *** Part 5

Part 1

Part 2

Part 3

Part 4 *** Part 5

Note that the contents of the fields P1 ...P4 are totally overwritten and that they are filled out with trailing blanks.

You can also split a string into the individual lines of an internal table as follows:

SPLIT <c> AT <del> INTO TABLE <itab>.

The system adds a new line to the internal table <itab> for each part of the string.

Read only

Former Member
0 Likes
623

data : v_char(100) type c.

v_char = 'some string continuing here'.

now use OFFSET to get some no of characters from V_CHAR.

WRITE 😕 V_CHAR+0(11) ,

V_CHAR+11.

This will print your 1 variable value in 2 lines.

Regards

srikanth