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 into the same string field

Former Member
0 Likes
838

Hi,

I want concatenate two string but target field is one of them.

The sentence:

CONCATENATE A B INTO A

doesn't works because of the length of field A.

How to do that?

Thanks,

7 REPLIES 7
Read only

Former Member
0 Likes
797

Declare A length as addition of A&B

data: A(8) type c value 'abcdef',

B(2) type c value 'gh'.

concatenate A B into A.

write:/ A.

Regards,

Maha

Read only

Former Member
0 Likes
797

Hi,

is this really a problem?

I tried this without a problem:

-


DATA: a TYPE string,

b TYPE string.

a = 'AB'.

b = 'AP'.

CONCATENATE a b INTO a.

WRITE a.

-


Output ist ABAP

-


Kindly regards,

Stefan

Read only

Former Member
0 Likes
797

Hi Carme,

Stefan is right...

data: a type string value 'abcdef',

b type string value 'gh'.

concatenate a b into a.

write:/ a

O/P: abcdefgh

Regards,

Maha

Read only

0 Likes
797

hi,

data: A(8) type c value 'efghi',

B(2) type c value 'abcd'.

concatenate B A into B

write:/ B.

Execute this.

Regards,

sandeep

Read only

0 Likes
797

hi,

data: A(8) type c value 'efghi',

B(4) type c value 'abcd'.

concatenate B A into a.

write:/ a.

Execute this.

Regards,

sandeep

Read only

0 Likes
797

hi Genious,

REPORT ZSAN4.

DATA: ITAB LIKE ZSTUDENT OCCURS 0 WITH HEADER LINE.

READ TABLE ITAB WITH KEY ROLLNO = 1001.

WRITE:/ ITAB-FNAME, ITAB-LNAME, ITAB-CLASS.

Regards,

sandeep

Read only

Former Member
0 Likes
797

Hi,

Check below example:


data: l_a(5) type c value 'ABC',
      l_b(3) type c value 'DEF',
      l_c(10) type c,
      l_d type string.

" concatenating l_a and l_b results in a length of 8 = 5 + 1

concatenate l_a l_b into l_d.

write:/ l_d. " l_d is of type string so it can hold 8 characters

concatenate l_a l_b into l_c.

write:/ l_c. " l_c is of type char with length 10 so it can hold 8 characters from concatenate stmt

concatenate l_a l_b into l_a.

write:/ l_a. " l_a is of type char with length 5, so the maximum length it can hold is 5 characters so there is truncation of the other char(s)

Hope this helps...

Kind Regards

Eswar