‎2007 Jan 25 8:47 AM
Hi All,
I want to insert all the records of the table ls_outtab into table gt_outtab from position 1 onwards , the gt_outtab may or maynot have data,but I can not clear gt_outtab[].
Is there any way to do it.
I tried following but its not working.
loop at ls_outtab.
MODIFY gt_outtab FROM ls_outtab where tabix = sy-tabix .
endloop.
PLs suggest
Thanks
‎2007 Jan 25 8:50 AM
Hi Rahul
If both structures are same, you can try this way:
APPEND LINES OF ls_outtab TO gt_outtab.
If the structures are different:
LOOP AT ls_outtab.
MOVE-CORRESPONDING ls_outtab TO gt_outtab.
APPEND gt_outtab.
ENDLOOP.Hope this helps.
Kind Regards
Eswar
‎2007 Jan 25 8:50 AM
Use liek this -
Modify DBtab from table itab.
effects -
Mass modify: Inserts new lines or updates existing lines of a database table. The primary keys for identifying the lines to be inserted or updated and the relevant values are taken from the internal table itab. The lines of the internal table itab must satisfy the same conditions as the work area wa in addition 1 to variant 1.
If the internal table itab is empty, SY-SUBRC and SY-DBCNT are set to 0.
‎2007 Jan 25 8:50 AM
Hi Rahul
If both structures are same, you can try this way:
APPEND LINES OF ls_outtab TO gt_outtab.
If the structures are different:
LOOP AT ls_outtab.
MOVE-CORRESPONDING ls_outtab TO gt_outtab.
APPEND gt_outtab.
ENDLOOP.Hope this helps.
Kind Regards
Eswar
‎2007 Jan 25 8:53 AM
Hi,
MODIFY statement will modify only the existing lines of a table. If you want to insert new lines, then you should try with APPEND statement.
Regards,
Sharmila
‎2007 Jan 25 8:56 AM
Hello Rahul,
If both the tables have the same structure then,
<b>LOOP AT ITAB1.
MOVE CORRESPONDING ITAB1 to ITAB2.
APPEND ITAB2.
ENDLOOP.</b>
<b>If ITAB1[] is initial.
Clear: itab2.
refresh itab2.
ENDIF.</b>
Vasanth
‎2007 Jan 25 9:01 AM
Hi Rahul ,
If the structure of both the internal tables are the same user the command
<b>INSERT LINES OF ls_outtab INTO gt_outtab index 1.</b>
if they are not the same then use loop endloop and use the insert command index 1.
e.g
LOOP AT LS_OUTTAB INTO WA_OUTTAB.
MOVE-CORRESPONDING WA_OUTTAB TO WA_GT_OUTTAB.
INSERT WA_GT_OUTTAB INTO GT_OUTTAB INDEX 1.
ENDLOOP.
Regadrs
Arun
Assign points if reply is useful
‎2007 Jan 25 9:18 AM
Hi Rahul,
Try APPEND LINES OF ls_outtab TO gt_outtab.
Reward points if found useful...!
Cheers
Abhishek