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

String Operatoin

sap_cohort
Active Contributor
0 Likes
447

Hi, How to output field1 C(10) and field1 C(10) into a string field and maintain the lengths of the individual fields?

FIELD1 C(10) is 'ABCD'

FIELD2 C(10) is '0123456789'

MYSTRING should be 'ABCD 0123456789'

I get errors using the write and concatenate doesn't preserve the field lengths.

How to do this?

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
419

You must use place holders.



report zrich_0002.

data:
     field1(10) type c value 'ABCD',
     field2(10) type c value '0123456789'.

data: mystring type string.

translate field1 using ' %'.
translate field2 using ' %'.

concatenate field1 field2 into mystring.

translate mystring using '% '.

write:/ mystring.

Regards,

Rich Heilman

3 REPLIES 3
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
420

You must use place holders.



report zrich_0002.

data:
     field1(10) type c value 'ABCD',
     field2(10) type c value '0123456789'.

data: mystring type string.

translate field1 using ' %'.
translate field2 using ' %'.

concatenate field1 field2 into mystring.

translate mystring using '% '.

write:/ mystring.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
419

Hi,

Use TRANSLATE then

Concatenate FIELD1 FIELD2 into MYSTRING separeted by SPACE.

Regards

Sudheer

Read only

Former Member
0 Likes
419

Hi kenneth,

use

DATA : MYSTRING(25) TYPE C.

CONCATENATE FIELD1 FIELD2 INTO MYSTRING SEPERATED BY ' '.

Regards,

Ajith

Mark if useful.