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: 

one table's column contents into another table's single row

Former Member
0 Kudos

Hi ABAP Experts,

my requirement is to transfer data from one tables column into another tables single row.

my data is in one internal table's column.

& i want all the records from this column into another table's single row .

how can it be done??

any function module??

Regards,

Ashish

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos
l_tabix type sy-tabix.
LOOP AT itab1.
l_tabix = l_tabix + 1.
ASSIGN COMPONENT l_tabix OF STRUCTURE itab2 TO <fs1>.
IF sy-subrc = 0.
<fs1> = itab-filed1.
ENDIF.
APPEND itab2.
ENDLOOP.

try this..

vijay

5 REPLIES 5

former_member188685
Active Contributor
0 Kudos
l_tabix type sy-tabix.
LOOP AT itab1.
l_tabix = l_tabix + 1.
ASSIGN COMPONENT l_tabix OF STRUCTURE itab2 TO <fs1>.
IF sy-subrc = 0.
<fs1> = itab-filed1.
ENDIF.
APPEND itab2.
ENDLOOP.

try this..

vijay

0 Kudos

hey vijay ,

thanks for responding so quickly.

my data is coming from a function module , which is an internal table without header line.

so <b>LOOP AT itab1</b> will not work in this case.

can you help me out in this.

0 Kudos

data:

wtab like line of itab1,

l_tabix type sy-tabix.

LOOP AT itab1 into wtab.

l_tabix = l_tabix + 1.

ASSIGN COMPONENT l_tabix OF STRUCTURE itab2 TO <fs1>.

IF sy-subrc = 0.

<fs1> = wtab-filed1.

ENDIF.

APPEND itab2.

ENDLOOP.

0 Kudos
l_tabix type sy-tabix.
LOOP AT itab1 into wa.
l_tabix = l_tabix + 1.
ASSIGN COMPONENT l_tabix OF STRUCTURE itab2 TO <fs1>.
IF sy-subrc = 0.
<fs1> = wa-filed1.
ENDIF.
APPEND itab2.
ENDLOOP.

0 Kudos

hi ashish,

Try this,

field-symbol: <fs_field> type any.

LOOP AT itab1.

*assign the values to internal table1 to second internal table.

ASSIGN COMPONENT itab1-fieldname

OF STRUCTURE structure1

TO <fs_field>.

IF sy-subrc EQ 0.

itab2-field_name1 = <event_field>.

*append to internal table2

APPEND itab2.

ENDIF.

ENDLOOP.

The 'Fieldname' is a entry in a table itab1.

The same is a column in structure1.

this will assign the field value to the corresponding field to internal table2 where internal table2 has the same field name as a column(which can be assigned from the structure1).

i have tried this and this is working fine.

Regards,

Padmini