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: 

Concatenating the table fields

Former Member
0 Kudos

Hi,

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.

7 REPLIES 7

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

Hi,

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.
  endif.      
endloop.

Regards

Marcin

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.
      endif.
    
    endat.

    clear is_item.
endloop.

hope this helps.. self explanatory,...

Former Member
0 Kudos

hi

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

endloop.

Thanks

former_member555112
Active Contributor
0 Kudos

Hi,

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.

Regards,

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...
Endloop.

Append Table C.
Endloop.

Thanks & regards,

Dileep .C