‎2007 Aug 24 5:53 AM
Hello Friends,
I have one internal table Loop like......
Loop at Itab.
Write : / itab-matnr,itab-maktx.
Endloop.
Now i want to insert This Matnr and Maktx in to one Ztable. and later i want to Update it fro internal table loop.
SO can any one help me that how to use insert n update data in to Ztable from Internal table loop.
Give me an example of code.
Thanks in advance.
Points awarded soon.
-nmz
‎2007 Aug 28 12:29 PM
Hi Nimesh,
Below code will insert as well as update your database table <b>ZTABLE</b> with respect to data present in internal table <b>itab.</b>
Loop at Itab.
Write : / itab-matnr,itab-maktx.
Endloop.
Modify ztable from table itab.
Note:- If the internal table itab is empty, SY-SUBRC and SY-DBCNT are set to 0.
<b>Reward with points if it helps.</b>
Thanks and regards,
Amit
‎2007 Aug 24 5:54 AM
Hi,
If you want to INSERT if the data is not there and UPDATE if the data is already there in Ztable then use MODIFY instead.
Populate your data into internal table and use like this.
MODIFY ztable FROM table itab. " The data in itab will be inserted/updated into ztable.
Regards,
Sesh
‎2007 Aug 24 9:15 PM
Hello,
We have 3 basic operations for your scenario
1) insert....
can be used to insert a new record with a new key to a table
if the insert fails...sy-subrc not equal to zero
2)Update
can be used to update an existing record with the same key
if update fails again sy-subrc will be non-zero
3)Modify
if a record already exists with the same key.-->the record updates the non-key fields of the table
if a record with the same key does not exists -->new record is inserted
if fails nonzero is returned to sy-subrc
you can choose based on your requirement....
for syntax,use SAP information key
Hope it proved useful....
Reward all helpful answers
Regards
Byju
‎2007 Aug 28 12:29 PM
Hi Nimesh,
Below code will insert as well as update your database table <b>ZTABLE</b> with respect to data present in internal table <b>itab.</b>
Loop at Itab.
Write : / itab-matnr,itab-maktx.
Endloop.
Modify ztable from table itab.
Note:- If the internal table itab is empty, SY-SUBRC and SY-DBCNT are set to 0.
<b>Reward with points if it helps.</b>
Thanks and regards,
Amit