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

Howto span a constant string over multiple lines

Former Member
0 Likes
3,272

Hi experts,

I need to pre-define a constant string with over 100 characters, so I want to split and span it over multiple lines. In Java-like languages I can do so with a backslash as last character in the line. Is there any similar technique in ABAP?

Kind regards, Matthias

1 ACCEPTED SOLUTION
Read only

Former Member
1,614

Well i didnt understand your question .

If you are using a pre-defined constant and if your intention is to split it into multiple lines, why do you have to use one single constant for it? At the definition itself, can't you split it into multiple constants?

9 REPLIES 9
Read only

Former Member
1,615

Well i didnt understand your question .

If you are using a pre-defined constant and if your intention is to split it into multiple lines, why do you have to use one single constant for it? At the definition itself, can't you split it into multiple constants?

Read only

0 Likes
1,614

No, it's the other way round: I want to create one constant with over 100 characters in length. But I don't want do write all those 100+ characters into one single line in the ABAP editor. So I want to do something like this:

CONSTANTS: lc_string TYPE string VALUE 
           'this is the first line of the constant' \
           'and this is the second line, but still the same constant'.

Kind regards, Matthias

Read only

0 Likes
1,614

u can use a string table.

Read only

0 Likes
1,614

Yes I know about the string table. I could also just create two constants and then concatenate them.

But I would prefer the solution as I know it from other programming languages ...

Read only

0 Likes
1,614

Hi,

Try this , use &

CONSTANTS: lc_string TYPE string VALUE
           'this is the first line of the constant' &
           'and this is the second line, but still the same constant'.

data var1 type string.

var1 = lc_string.

write var1.

Regards

Read only

0 Likes
1,614

thanks, that did the trick!

Read only

0 Likes
1,614

Hi,

Please try like below: Each line ends with 70 char's so if u want to print from second line use Offset like below (71, 142)

CONSTANTS: lc_string TYPE string VALUE

'this is the first line of the constant

and this is the second line, but still the same constant

second line'.

write : lc_string+71(3).

Rgds,

Pavan

Read only

0 Likes
1,614

Hi ravi ... its not working for me !!!!!!

Read only

Former Member
0 Likes
1,614

hi you can use

cl_abap_char_utilities=>newline.

see other special characters...

http://erpbuzz.com/abap-new-line-tab-space-backspace-characters-char-util-class.php