2006 Aug 23 3:30 PM
Hi,
Below is my code.
LOOP AT gt_temp_bkpf.
READ TABLE gt_fxentries WITH KEY belnr = gt_fxentries-belnr
bukrs = gt_fxentries-bukrs
gjahr = gt_fxentries-gjahr.
IF sy-subrc NE 0.
DELETE gt_fxentries.
CLEAR gt_fxentries.
ENDIF.
ENDLOOP.
It is going to dump at delete statement
Please help me out.
Thanks,
Pavan.
Hi,
Below is my code.
LOOP AT gt_temp_bkpf.
READ TABLE gt_fxentries WITH KEY belnr = gt_fxentries-belnr
bukrs = gt_fxentries-bukrs
gjahr = gt_fxentries-gjahr.
IF sy-subrc NE 0.
DELETE gt_fxentries.
CLEAR gt_fxentries.
ENDIF.
ENDLOOP.
It is going to dump at delete statement
Please help me out.
Thanks,
Pavan.
2006 Aug 23 3:33 PM
Hello,
You need to pass some where condition because system is not knowing which line you want to delete.
Regards,
Naimesh
2006 Aug 23 3:35 PM
hi!
first of all, you can delete from gt_fxentries if sy-subrc 0 0, if it doesn´t exist you can´t delete it, and second, you have to put the index condition(for example)
DELETE gt_fxentries index sy-tabix.
regards
2006 Aug 23 3:35 PM
Make the highlighted change.
LOOP AT gt_temp_bkpf.
READ TABLE gt_fxentries WITH KEY belnr = gt_fxentries-belnr
bukrs = gt_fxentries-bukrs
gjahr = gt_fxentries-gjahr.
IF sy-subrc NE 0.
DELETE gt_fxentries <b>index sy-tabix</b>.
CLEAR gt_fxentries.
ENDIF.
ENDLOOP.
2006 Aug 23 3:36 PM
Your code doesn't really make sense.
LOOP AT gt_temp_bkpf.
READ TABLE <b>gt_fxentries</b>
WITH KEY belnr = <b>gt_fxentries</b>-belnr
bukrs = <b>gt_fxentries</b>-bukrs
gjahr = <b>gt_fxentries</b>-gjahr.
IF sy-subrc <b>NE</b> 0.
DELETE gt_fxentries.
CLEAR gt_fxentries.
ENDIF.
ENDLOOP.
what you have here is it looks like you are trying to read the GT_FXENTRIES table with values from the GT_FXENTRIES table. This does not make sense.
Also, you are saying that you want to delete GT_FXENTRIES when sy-subrc <> 0, this means that you are trying delete a line that doesn't exist. Again this doesn't make sense.
Regards,
Rich Heilman
2006 Aug 23 3:43 PM
LOOP AT gt_temp_bkpf.
READ TABLE gt_fxentries WITH KEY belnr = gt_fxentries-belnr
bukrs = gt_fxentries-bukrs
gjahr = gt_fxentries-gjahr.
IF sy-subrc NE 0.
DELETE gt_fxentries.
CLEAR gt_fxentries.
ENDIF.
ENDLOOP.
--The above code does not make sense as you are trying to read the table gt_fxentries with its values and if not found deleting it ...I think you need is the below code
LOOP AT gt_temp_bkpf.
READ TABLE gt_fxentries WITH KEY belnr = gt_temp_bkpf-belnr.
bukrs = gt_fxentries-bukrs
gjahr = gt_fxentries-gjahr.
IF sy-subrc NE 0.
DELETE gt_temp_bkpf.
ENDIF.
ENDLOOP.
the above code would read through the table gt_temp_bkpf and check if the corresponding entry exists for the particular belnr in gt_fxentries, If yes than initialise the bukrs and gjahr fields otherwise delete the record from gt_temp_bkpf.
Regards
Anurag
2006 Aug 23 3:44 PM
Hi Pavan,
use DELETE gt_fxentries index sy-tabix that too when sy-subrc = 0.
i.e. if there is some record in gt_fxentries then only u r going to delete that record.
if sy-subrc <> 0 that means there is no record with ur belnr so how can you delete some record which is not existing?
-Anu
2006 Aug 23 3:49 PM
Hi ,
As a good practice never delete a internal table inside a loop try to put a flag and mark the flag for deletion after loop apply delete command on the internal table where the flag = X , in this way you can delete all your required records which are marked for deletion. You can improve your performance also.
BR,
Raghav
2006 Aug 23 3:54 PM
I think you are trying to delete entries from gt_fxentries if they do not have a match in gt_temp_bkpf.
check this code:
LOOP AT gt_temp_bkpf.
READ TABLE gt_fxentries WITH KEY belnr = gt_temp_bkpf-belnr
bukrs = gt_temp_bkpf-bukrs
gjahr = gt_temp_bkpf-gjahr.
IF sy-subrc NE 0.
DELETE gt_fxentries index sy-tabix.
ENDIF.
ENDLOOP.
Regards,
Ravi
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |