2011 Oct 03 6:59 PM
HI ALL
I have table type any <fs_tab1> and another table type any <fs_tab2> and i need to move all the
data from table <fs_tab1> to table <fs_tab2> but the issue here that i have table itab3 (mapping table with the fields names ) that
just the fields that mapped there and are in itab3 need to be insert to table <fs_tab1>.
I try but i have some issues
LOOP AT <fs_tab1> ASSIGNING <ls_tab1>.
LOOP AT itab3 INTO ls_flat_map.
* DO.
* ASSIGN COMPONENT ls_map-target OF STRUCTURE <ls_output> TO <lv_field>.
*
ENDDO.
IF sy-subrc = 0.
MOVE-CORRESPONDING <ls_outpu> TO <ls_itab2>.
INSERT <ls_itab2 INTO TABLE <ls_itab2>..
ENDIF.
ENDLOOP.
ENDLOOP.
2011 Oct 03 8:34 PM
Hi,
Here you go:
FIELD-SYMBOLS: <tab1> TYPE ANY TABLE,
<tab2> TYPE ANY TABLE,
<rec1> TYPE any,
<rec2> TYPE any,
<rec3> TYPE ty_fldname,
<fld1> TYPE any,
<fld2> TYPE any.
DATA: go_data TYPE REF TO data.
CREATE DATA go_data LIKE LINE OF <tab2>.
IF go_data IS BOUND.
ASSIGN go_data->* TO <rec2>.
ENDIF.
LOOP AT <tab1> ASSIGNING <rec1>.
LOOP AT gt_tab3 ASSIGNING <rec3>.
ASSIGN COMPONENT <rec3>-target OF STRUCTURE <rec1> TO <fld1>.
CHECK sy-subrc = 0.
ASSIGN COMPONENT <rec3>-target OF STRUCTURE <rec2> TO <fld2>.
CHECK sy-subrc = 0.
<fld2> = <fld1>.
ENDLOOP.
INSERT <rec2> INTO TABLE <tab2>.
CLEAR <rec2>.
ENDLOOP.
Kr,
m.
HI ALL
I have table type any <fs_tab1> and another table type any <fs_tab2> and i need to move all the
data from table <fs_tab1> to table <fs_tab2> but the issue here that i have table itab3 (mapping table with the fields names ) that
just the fields that mapped there and are in itab3 need to be insert to table <fs_tab1>.
I try but i have some issues
LOOP AT <fs_tab1> ASSIGNING <ls_tab1>.
LOOP AT itab3 INTO ls_flat_map.
* DO.
* ASSIGN COMPONENT ls_map-target OF STRUCTURE <ls_output> TO <lv_field>.
*
ENDDO.
IF sy-subrc = 0.
MOVE-CORRESPONDING <ls_outpu> TO <ls_itab2>.
INSERT <ls_itab2 INTO TABLE <ls_itab2>..
ENDIF.
ENDLOOP.
ENDLOOP.
2011 Oct 03 8:34 PM
Hi,
Here you go:
FIELD-SYMBOLS: <tab1> TYPE ANY TABLE,
<tab2> TYPE ANY TABLE,
<rec1> TYPE any,
<rec2> TYPE any,
<rec3> TYPE ty_fldname,
<fld1> TYPE any,
<fld2> TYPE any.
DATA: go_data TYPE REF TO data.
CREATE DATA go_data LIKE LINE OF <tab2>.
IF go_data IS BOUND.
ASSIGN go_data->* TO <rec2>.
ENDIF.
LOOP AT <tab1> ASSIGNING <rec1>.
LOOP AT gt_tab3 ASSIGNING <rec3>.
ASSIGN COMPONENT <rec3>-target OF STRUCTURE <rec1> TO <fld1>.
CHECK sy-subrc = 0.
ASSIGN COMPONENT <rec3>-target OF STRUCTURE <rec2> TO <fld2>.
CHECK sy-subrc = 0.
<fld2> = <fld1>.
ENDLOOP.
INSERT <rec2> INTO TABLE <tab2>.
CLEAR <rec2>.
ENDLOOP.
Kr,
m.
2011 Oct 04 3:16 PM
HI Manu,
Thanks you very much,
One question , do you think I can use something different instead of CHECK ?
Regards
Joy
2011 Oct 04 3:23 PM
Hi,
Well, this was just a basic form of algorithm...
You could of course handle exceptions with a TRY-CATCH block or an IF sy-subrc NE 0...
All depends on what you are expecting.. e.g. if a field from tab3 does not exist in tab1 or in tab2 or in both, ...
Kr,
m.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |