Application Development and Automation 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: 
Read only

Query with Modify statement

Former Member
0 Likes
745

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
709

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

6 REPLIES 6
Read only

Former Member
0 Likes
709

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.

Read only

Former Member
0 Likes
710

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

Read only

Former Member
0 Likes
709

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

Read only

Former Member
0 Likes
709

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

Read only

Former Member
0 Likes
709

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

Read only

Former Member
0 Likes
709

Hi Rahul,

Try APPEND LINES OF ls_outtab TO gt_outtab.

Reward points if found useful...!

Cheers

Abhishek