2007 Feb 01 1:55 AM
hi! can some one help me how i move data from one dynamic internal table to another dynamic internal table. structures are different. dyn_table1 has only one field and dyn_table2 has 3 fields but both have one field in common. i want to populate that common field in dyn_itab2 from dyn_itab1.
ex:
dyn_itab1 dyn_ itab2
field3 field1 field2 field3 field4
i did assign component 1 of structure <dyn_table0> to <dyn_table>.
got sy-subrc '4'.
hi! can some one help me how i move data from one dynamic internal table to another dynamic internal table. structures are different. dyn_table1 has only one field and dyn_table2 has 3 fields but both have one field in common. i want to populate that common field in dyn_itab2 from dyn_itab1.
ex:
dyn_itab1 dyn_ itab2
field3 field1 field2 field3 field4
i did assign component 1 of structure <dyn_table0> to <dyn_table>.
got sy-subrc '4'.
2007 Feb 01 4:00 AM
HI,
You need to loop through one table and then populate the other table as follows.
LOOP AT <dyn_table0> ASSIGNING <dyn_table_line>.
READ TABLE <dyn_table1> INDEX sy-tabix ASSIGNING <dyn_table1_line>.
ASSIGN COMPONENT 1 OF STRUCTURE <dyn_table_line> to <fs_1>.
ASSIGN COMPONENT 1 OF STRUCTURE <dyn_table1_line> to <fs_2>.
<fs_1> = <fs_2>.
ENDLOOP.
Regards,
Sesh
2007 Feb 01 4:31 AM
Hi Priya,
U need to create a line type of second internal table. Check this program. Check the code in bold.
REPORT YDYNAMIC .
data : it_fcat type lvc_t_fcat.
data : new_table type ref to data.
field-symbols : <i_tab> type standard table,
<i_tab1> type standard table,
<i_line> type any,
<i_line1> type any,
<fs> type any,
<fs1> type any.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'VBAK'
CHANGING
ct_fieldcat = it_fcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fcat[]
IMPORTING
EP_TABLE = new_table
EXCEPTIONS
GENERATE_SUBPOOL_DIR_FULL = 1
others = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
assign new_table->* to <i_tab>.
clear new_table.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fcat[]
IMPORTING
EP_TABLE = new_table
EXCEPTIONS
GENERATE_SUBPOOL_DIR_FULL = 1
others = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
assign new_table->* to <i_tab1>.
select * from vbak into table <i_tab>.
<b>data : tdref TYPE REF TO data.
CREATE DATA tdref LIKE LINE OF <i_tab1>.
assign tdref->* to <i_line1>.</b>
<b>loop at <i_tab> assigning <i_line>.
assign component 'VBELN' of structure <i_line> to <fs>.
assign component 'VBELN' of structure <i_line1> to <fs1>.
<fs1> = <fs>.
append <i_line1> to <i_tab1>.
endloop.</b>
-SatyaPriya
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |