2015 Dec 28 12:31 PM
Hi All,
I try to modify or insert data to database table but the code just modify only 1 row.
I just added only 1 data to ztable.
Do you know why i cant add data to ztable.
Thanks for help.
LOOP AT IT_REPORT INTO WA_REPORT WHERE TEDARIK IS NOT INITIAL.
READ TABLE GT_TEDRK_TESM WITH KEY KUNET = WA_REPORT-KUNET
KUNWE = WA_REPORT-KUNWE
RMATNR = WA_REPORT-RMATNR
NAMET = WA_REPORT-NAMET
TARIH = WA_REPORT-TARIH
SFRTR_TX = WA_REPORT-SFRTR_TX.
IF SY-SUBRC IS NOT INITIAL.
MOVE-CORRESPONDING WA_REPORT TO WA_TEDRK_TESM.
INSERT ZPP_T_TEDRK_TESM FROM WA_TEDRK_TESM.
ENDIF.
ENDLOOP.
LOOP AT IT_REPORT INTO WA_REPORT WHERE TEDARIK IS NOT INITIAL.
READ TABLE GT_TEDRK_TESM WITH KEY KUNET = WA_REPORT-KUNET
KUNWE = WA_REPORT-KUNWE
RMATNR = WA_REPORT-RMATNR
NAMET = WA_REPORT-NAMET
TARIH = WA_REPORT-TARIH
SFRTR_TX = WA_REPORT-SFRTR_TX.
IF SY-SUBRC IS NOT INITIAL.
MOVE-CORRESPONDING WA_REPORT TO WA_TEDRK_TESM.
MODIFY ZPP_T_TEDRK_TESM FROM WA_TEDRK_TESM.
ENDIF.
ENDLOOP.
LOOP AT IT_REPORT INTO WA_REPORT WHERE TEDARIK IS NOT INITIAL.
READ TABLE GT_TEDRK_TESM WITH KEY KUNET = WA_REPORT-KUNET
KUNWE = WA_REPORT-KUNWE
RMATNR = WA_REPORT-RMATNR
NAMET = WA_REPORT-NAMET
TARIH = WA_REPORT-TARIH
SFRTR_TX = WA_REPORT-SFRTR_TX.
IF SY-SUBRC IS NOT INITIAL.
MOVE-CORRESPONDING WA_REPORT TO WA_TEDRK_TESM.
APPEND GT_TEDRK_TESM.
ENDIF.
ENDLOOP.
MODIFY ZPP_T_TEDRK_TESM FROM WA_TEDRK_TESM.
THANKS FOR YOUR HELP
2015 Dec 28 1:04 PM
Hi Erm,
The data will be modified based on key fields. It check with the key fields of structure to the database table and modifies accordingly. Please check the key fields.
And also Your question is not clear. If it doesnot help, make sure you give enough clarification or detail to understand your issue.
Regards,
Ajit
2015 Dec 28 1:04 PM
Hi Erm,
The data will be modified based on key fields. It check with the key fields of structure to the database table and modifies accordingly. Please check the key fields.
And also Your question is not clear. If it doesnot help, make sure you give enough clarification or detail to understand your issue.
Regards,
Ajit
2015 Dec 28 1:19 PM
2015 Dec 28 8:32 PM
The INSERT command adds lines to the DB table as long as there are no duplicate keys present, if there are it will throw an ABAP DUMP.
The MODIFY command changes behavior depending on the existence or not of the record when comparing key fields:
In your code, you only do a straight insert in the first loop, the other two will most likely change the same existing DB record when finding the same key values.
2015 Dec 29 3:03 PM
The last MODIFY statement is outside of the LOOP. Is that correct? This will Change the DB Data only with the last valid data from the LOOP.
Did you check already the sy-dbcnt?
2015 Dec 29 5:02 PM
Hi Erm,
Try,
Declare a internal table as like ztable.
Append the internal tables instead of updating ztable in loop.
Ater endloop.
MODIFY ZTABLE FROM TABLE it_upd. ( new internal table).
COMMIT WORK.
Hope it helpful,
Regards,
Venkat.
2015 Dec 30 1:53 AM
If inside the loop, Use MODIFY ztable from work_area TRANSPORTING field1 field2.
Outside loop, use MODIFY ztable From table it_table WHERE <condition>.