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

Going to dump

Former Member
0 Likes
785

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.

8 REPLIES 8
Read only

naimesh_patel
Active Contributor
0 Likes
755

Hello,

You need to pass some where condition because system is not knowing which line you want to delete.

Regards,

Naimesh

Read only

0 Likes
755

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

Read only

Former Member
0 Likes
755

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.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
755

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

Read only

Former Member
0 Likes
755

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

Read only

Former Member
0 Likes
755

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

Read only

Former Member
0 Likes
755

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

Read only

Former Member
0 Likes
755

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