Application Development 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: 

Concatenate table fields ..

Former Member
0 Kudos

Dear memebers,

I have a internal table with 2 fields,

1 AAA

2 BBB

3 CCC

I want to concatenate column 2 values, So that my result will be AAABBBCCC.

how can I achieve this. Thanks for looking into.

Regards

madhu

1 ACCEPTED SOLUTION

david_carballido
Active Participant
0 Kudos

Hi, try this.

TYPES: BEGIN OF itab,
        car1 TYPE c,
        car2(3) TYPE c,
       END OF itab.

... appear itab

DATA: l_string TYPE string,

LOOP AT itab INTO w_itab.
  CONCATENATE l_string w_itab INTO l_string.
ENDLOOP.

Your output will be AAABBBCCC.

Thanks and Regards.

David Carballido

7 REPLIES 7

david_carballido
Active Participant
0 Kudos

Hi, try this.

TYPES: BEGIN OF itab,
        car1 TYPE c,
        car2(3) TYPE c,
       END OF itab.

... appear itab

DATA: l_string TYPE string,

LOOP AT itab INTO w_itab.
  CONCATENATE l_string w_itab INTO l_string.
ENDLOOP.

Your output will be AAABBBCCC.

Thanks and Regards.

David Carballido

0 Kudos

Thanks David and others,

got answer !! closing thread. allotting points for all the contributors.

Thanks

Madhu

Former Member
0 Kudos

Concatenate itab-f1 itab-f2 itab-f3 into itab-f4.

rahul2000
Contributor
0 Kudos

What is your internal table structure?Mention it plz so that we can give an exact answer

Former Member
0 Kudos

Hello,

Try this.

types: begin of ty_itab,

f1 type i,

f2 type string,

end of ty_itab.

Data: itab type standard table of ty_itab,

wa_tab type ty_itab,

ws_c_result type string.

wa_tab-f1 = 1.

wa_tab-f2 = 'AAA'.

Append wa_tab to itab.

clear wa_tab.

wa_tab-f1 = 2.

wa_tab-f2 = 'BBB'.

Append wa_tab to itab.

clear wa_tab.

wa_tab-f1 = 3.

wa_tab-f2 = 'CCC'.

Append wa_tab to itab.

clear wa_tab.

sort itab by f2 descending.

LOOP AT itab into wa_tab .

Concatenate wa_tab-f2 ws_c_result into ws_c_result.

ENDLOOP.

Write:/ 'Result ',

ws_c_result.

You'll get the desired result.

Thanks and Regards,

Venkat Phani Prasad Konduri

Former Member
0 Kudos

Hello Madhu totikonda,

Concatenating means joining which can be achieved by combining the relevant fields for the final output.

Use this understand this concept

ITAB1 = value.

ITAB2 = value.

ITAB3 = value.

CONCATENATE ITAB1 VALUE INTO COMB1.

CONCATENATE ITAB2 VALUE INTO COMB2.

CONCATENATE ITAB3 VALUE INTO COMB3.

CONCATENATE ITAB1 ITAB2 ITAB3 INTO ITAB1.

Cheers!!

Former Member
0 Kudos

Hi ,

here i am writing code. U can use this.

DATA: BEGIN OF itab OCCURS 0,

f1 TYPE i,

f2 TYPE string,

END OF itab.

DATA: result TYPE string.

CLEAR itab,result.

REFRESH itab.

itab-f1 = 1.

itab-f2 = 'AAA'.

APPEND itab.

CLEAR itab.

itab-f1 = 2.

itab-f2 = 'BBB'.

APPEND itab.

CLEAR itab.

itab-f1 = 3.

itab-f2 = 'CCC'.

APPEND itab.

CLEAR itab.

LOOP AT itab.

CONCATENATE itab-f2 result INTO result.

ENDLOOP.

WRITE: / result.

regards,

Surendra babu vemula