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.
Showing results for 
Search instead for 
Did you mean: 

Concatenating the table fields

Former Member
0 Kudos


In my req I have to concatenate the header and item details, during concatenating I have to concatenate one header and one line item and push it as one line(Single Line), I am unable to concatenate the values into a single line they are coming in two lines, how to achive this.


Former Member
0 Kudos

how are u having those header and item details??? two internal tables or in same or how?

depending upon this i can suggest

0 Kudos


Both are in different tables.Any updates ?

Edited by: Varun on Jun 16, 2009 8:01 PM

0 Kudos

Assuming header_data is table which holds header names as rows, whereas item_data is a table which stores one item value in each row, then the following would apply:

data: itab type string occurs 0.
loop at header_data.
  read table item_data index sy-tabix. "read it by index if i.e first row in ITEM_DATA has value for first row in HEADER_DATA
  if sy-subrc = 0.
    concatenate header_data item_data into itab separeted by ';' ."line would look like MATNR;045678031
   append itab.



0 Kudos
clear : gv_concat_line, is_item.

loop at it_item into is_item.
    concatenate gv_concat_line is_item-desc into gv_concat_line.  

    at end of key. "-------->key field separating records in header table which is in item table also
       clear: is_header .
       read table it_header into is_header with key key = is_item-key.
       if sy-subrc = 0.
          gs_final-line = gv_concat_line.
          append gs_final to gt_final.
          clear : gv_concat_line.

    clear is_item.

hope this helps.. self explanatory,...

Former Member
0 Kudos


check this

loop at header into wa_header

Read table lt_line into wa_line with key <COndition>

loop in lt_line ito wa_line

concatenate wa_head-field wa_line-field into temp.

'append temp



Active Contributor
0 Kudos


Loop on the item table and read the header table by matching the key fields in both.

Then concatenate both into some variable and append it to a new internal table.


Ankur Parab

Former Member
0 Kudos

Hi Varun,

First Lets sat Table A(header), Table B(Items), Table C(Final after concatineing,,)

Table A--- Contains 4 records,,,,

Table B--- Contains 4 records,,,,(Or more records based on line Items)

Loop at Table A.

Loop at Table B (based on Work Area of Table A--- Where clause)
Concatinate (Table A - Field) (Table B - Field) into (Table C- Field). "Gives you First header at the end available no of items, one by one...

Append Table C.

Thanks & regards,

Dileep .C