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

Concatenate

madan_ullasa
Contributor
0 Likes
1,110

hi frnds,

my requirement is like this...

i have 2 variables..

C1(10) type c, C2(10) type c, c3(20) type c.

C1 = 'SAP'.

C2 = 'ABAP'.

concatenate c1 c2 to c3.

now my problem is that the concatenation occurs like 'SAPABAP. but i want it with spaces between sap and abap and the no.of spaces should be 7. ( 10 - no. of characters ). like ' SAP ABAP' . IF i use 'seperated by' it gives just 1 space. more ever the values of C1 and C2 are dynamic..

i tried substrings also. butno use..

any suggestins??

points for each and every reply......

regards,

Madan.

1 ACCEPTED SOLUTION
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,080

Hi,

Try this.

data : v1(10) type c value 'SAP',

v2(10) value 'ABAP',

v3(20).

v3+0(10) = v1.

v3+10(9) = v2.

write v3.

hi frnds,

my requirement is like this...

i have 2 variables..

C1(10) type c, C2(10) type c, c3(20) type c.

C1 = 'SAP'.

C2 = 'ABAP'.

concatenate c1 c2 to c3.

now my problem is that the concatenation occurs like 'SAPABAP. but i want it with spaces between sap and abap and the no.of spaces should be 7. ( 10 - no. of characters ). like ' SAP ABAP' . IF i use 'seperated by' it gives just 1 space. more ever the values of C1 and C2 are dynamic..

i tried substrings also. butno use..

any suggestins??

points for each and every reply......

regards,

Madan.

7 REPLIES 7
Read only

Former Member
0 Likes
1,080

Madan,

Use like this

CONCATENATE C1 C2 INTO C3 SEPARATED BY SPACE.

REGARDS,

RAVI

Read only

Former Member
0 Likes
1,080

HI ,

use

data : sep(7).

data : dat(3) value 'SAP' , dat1(4) value 'ABAP',dat2(20).

concatenate dat dat1 into dat2 separated by sep.

write : dat2.

this works well

regards

satesh

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,081

Hi,

Try this.

data : v1(10) type c value 'SAP',

v2(10) value 'ABAP',

v3(20).

v3+0(10) = v1.

v3+10(9) = v2.

write v3.

Read only

0 Likes
1,080

Tanx a lot ... seems to work now... will get back to u if any issues :)-..

regrds,

Madan..

Read only

Former Member
0 Likes
1,080

Madan this will work out...

If you want a space between both fields:

CONCATENATE STRING1 STRING2 INTO STRING3 SEPARATED BY ' '.

regards

Srikanth

Read only

0 Likes
1,080

If you need seven spaces between the words...try this...


STRING1 = 'SAP'.
STRING2 = '///////'.
STRING3 = 'ABAP'.

CONCATENATE STRING1 STRING2 STRING3 INTO STRING4.
WHILE SY-SUBRC EQ 0.
REPLACE '/' WITH SPACE INTO STRING4.
ENDWHILE.

Greetings,

Blag.

Read only

Former Member
0 Likes
1,080

MOVE: ' Find out the string length in a fast way'

TO SY-TITLE.

PARAMETERS: P_STRING(10) DEFAULT 'abitrary string 1 ...... '

LOWER CASE.

PARAMETERS: P_STRNG1(10) DEFAULT 'abitrary string 2 ...... '

LOWER CASE.

PERFORM STRINGLAENGE.

FORM STRINGLAENGE.

IF P_STRING CP '*# '. ENDIF. " SY-FDPOS is set

  • |||

  • |||----> ' ' = only blanks up to end of line

  • ||-----> # = character for blanks

  • |------> * = any character

IF P_STRNG1 CP '*# '. ENDIF. " SY-FDPOS is set

  • |||

  • |||----> ' ' = only blanks up to end of line

  • ||-----> # = character for blanks

  • |------> * = any character

WRITE: /1 p_string ,' ',p_strng1.

ENDFORM.