Application Development 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: 

getting dump in my Z program

Former Member
0 Kudos

hi,

i am getting dump in my below code in the delete statement line.actually previously it worked fine but now suddenly we r getting dump in the second delete statement below.can some body tell me the reason.

error analysis: You attempted to change, delete or create a line in the

internal table "\PROG=YBDISEMAT\DATA=INT_MARC", but no valid cursor exists

for the table.

Possible reasons:

1. The relevant ABAP/4 statement does not include the addition

"...INDEX...", although the statement is not

inside a "LOOP...ENDLOOP" loop processing this table.

2. The relevant ABAP/4 statement was called from within a

"LOOP...ENDLOOP" loop after a DELETE "\PROG=YBDISEMAT\DATA=INT_MARC".

LOOP AT int_marc INTO wa_marc.

IF wa_marc-werks IN ra_source.

READ TABLE int_disgr WITH KEY zdisgr = wa_marc-disgr

zwerks = wa_marc-werks.

IF sy-subrc NE 0.

DELETE int_marc.

ENDIF.

ENDIF.

IF wa_marc-werks IN ra_zmdc.

READ TABLE int_disgr WITH KEY zdisgr = wa_marc-disgr

zwerks = wa_marc-werks.

IF sy-subrc NE 0.

DELETE int_marc. _______________________________________________ getting dump here

ENDIF.

ENDIF.

CLEAR wa_marc.

ENDLOOP.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

you are trying to delete a record from the internal table INT_MARC using the statement "DELETE INT_MARC".

For using this statement you should have the record to be deleted in the header line of ITN_MARC,But had looped the Internal table to the workarea WA_MARC ,so you dont have that record in the Header Line of INT_MARC ,insted you have it in "WA_MARC".

so you have to delete the record from internal table INT_MARC which is there in WA_MARC when your if condition is getting satisfied.

5 REPLIES 5

Former Member
0 Kudos

Hi,

Use the index specification with delete statement.

DELETE <itab> INDEX <idx>.

hence write the below code:

DELETE int_marc index sy-tabix.

Hope this helps

Regards

Shiva

Edited by: Shiva Kumar Tirumalasetty on Sep 11, 2009 3:17 PM

Former Member
0 Kudos

Hi,

The error analysis gives you the answer.

"You attempted to change, delete or create a line in the

internal table "\PROG=YBDISEMAT\DATA=INT_MARC", but no valid cursor exists

for the table."

It means that the program cannot determine which entry should be deleted from the table INT_MARC.

Have a look at the F1 help of the statement DELETE for correcting your program.

BR,

Advait

Former Member
0 Kudos

Hi.

First of all deleting an internal table inside the loop is not a good practise ..You are deleting the same internal table that you are looping..

Instead of that you can make a small modification to your code.

LOOP AT int_marc INTO wa_marc.

IF wa_marc-werks IN ra_source.

READ TABLE int_disgr WITH KEY zdisgr = wa_marc-disgr

zwerks = wa_marc-werks.

IF sy-subrc NE 0.

move 'X' to any field in the internal table.

or you can have an additinal field in the end of the internal table like flag type char01.

and move 'X' to wa_marc-flag.

ENDIF.

ENDIF.

Now outside the loop you can delete

delete int_marc where flag = 'X'.

Regards

Ansari

Former Member
0 Kudos

Hi,

Try like below:


LOOP AT int_marc INTO wa_marc.
IF wa_marc-werks IN ra_source.
READ TABLE int_disgr WITH KEY zdisgr = wa_marc-disgr
zwerks = wa_marc-werks.
IF sy-subrc NE 0.
DELETE int_marc.
continue. <add
ENDIF.
ENDIF.
IF wa_marc-werks IN ra_zmdc.
READ TABLE int_disgr WITH KEY zdisgr = wa_marc-disgr
zwerks = wa_marc-werks.
IF sy-subrc NE 0.
DELETE int_marc. 
continue.  <<<<<Add
ENDIF.
ENDIF.
CLEAR wa_marc.
ENDLOOP.

Dump is coming because the program is trying to delete an entrry that has already been deleted.

Regards,

Himanshu

Former Member
0 Kudos

you are trying to delete a record from the internal table INT_MARC using the statement "DELETE INT_MARC".

For using this statement you should have the record to be deleted in the header line of ITN_MARC,But had looped the Internal table to the workarea WA_MARC ,so you dont have that record in the Header Line of INT_MARC ,insted you have it in "WA_MARC".

so you have to delete the record from internal table INT_MARC which is there in WA_MARC when your if condition is getting satisfied.