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

Runtime error

Former Member
0 Likes
1,048

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

internal table "ITAB1", 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 "ITAB1".

dear all,i get the above runtime errors....the coding works fine if i enter more than 2 matnr but if i enter only 1 matnr in the selectin screen,problem occur..any idea? thanks

10 REPLIES 10
Read only

Former Member
0 Likes
986

Hi Joan,

Please use an index while deleting an entry inside a loop. You can use sy-tabix value for this.

Regards,

Chetan

PS:Reward points if this is helpful.

Read only

Former Member
0 Likes
986

Looks like you a DELETE statement and after that you are updating the internal table and that row is already deleted.

Post you code here and the data with which the loop is getting executed.

If you can execute the code debug mode, you will understand what I am saying.

Regards,

Ravi

Note - Please mark all the helpful answers

Read only

Former Member
0 Likes
986

ARE U USING INDEX OPTION FOR READING OR MODIFYING THE INTERNALL TABLE ? PROBABLY INDEX IS GETTING THE VALUE 0. PLS CHECK THAT.

Read only

Former Member
0 Likes
986

In the dump, there will be a source code extract. Would you post that portion please.

Rob

Read only

0 Likes
986

hei guys,below are the portion of code which get error

this segment of code are in a loop

LOOP AT ITAB3 WHERE MATNR = ITAB1-MATNR

AND IND2 = ' '.

CLEAR: MONTH, YEAR, DATE3.

YEAR = ITAB3-BUDAT0(4). MONTH = ITAB3-BUDAT4(2).

CONCATENATE YEAR MONTH INTO DATE3.

IF DATE1 = DATE3.

IF ITAB1-BUDAT3 IS INITIAL.

IF ITAB3-BWART = '312'. " mseg-shzkg = H

ITAB3-MENGE = ITAB3-MENGE * -1.

IF ITAB3-BWART = '412'. " mseg-shzkg = H

ITAB3-MENGE = ITAB3-MENGE * -1.

ENDIF.

ENDIF.

ITAB1-BUDAT3 = ITAB3-BUDAT.

ITAB1-MBLNR3 = ITAB3-MBLNR.

ITAB1-ZEILE3 = ITAB3-ZEILE.

ITAB1-MENGE3 = ITAB3-MENGE.

ITAB1-MEINS3 = ITAB3-MEINS.

ITAB1-BKTXT3 = ITAB3-BKTXT.

ITAB3-IND2 = 'U'.

MODIFY ITAB1. MODIFY ITAB3.

EXIT.

ENDIF.

ENDIF.

ENDLOOP.

error occurs at the "MODIFY ITAB1. MODIFY ITAB3."

Read only

0 Likes
986

you can't modify itab in the loop on itab3 without specifying an index. If the tables have the same number of entries you can try:

MODIFY ITAB1 index sy-tabix. MODIFY ITAB3.

otherwise you'll have to read itab1 to find the matching entry and then change it:

read table itab1 with key ???

if sy-subrc = 0.

modify itab1.

else.

append itab1.

endif.

Read only

0 Likes
986

hie neil, i tried using tat..it oso gimme errors..b4 this segment of code,there;s another similar codes..n tat part of codes works fine..juz this segment alone causing errors

Read only

0 Likes
986

Hi John,

You can't modify ITAB1 inside a loop of ITAB3. Modify ITAB3 inside the loop and you need to have index for the internal table ITAB1 for which you have ITAB1-MATNR.

LOOP AT ITAB3 WHERE MATNR = ITAB1-MATNR

AND IND2 = ' '.

.....

...

  • MODIFY ITAB1. (comment this statement here and modify ITAB1 outside the loop with index statement as in this loop there might be multiple values of ITAB3-MATNR based on ITAB1-MATNR)

MODIFY ITAB3.

EXIT.

ENDIF.

ENDIF.

ENDLOOP.

Also can u provide the code how r u getting ITAB1-MATNR also.

Read only

0 Likes
986

the error will happen whenever you try to 'update itab1' inside the itab3 loop. But sometimes because of the 'ifs' it will not actually go through the modify and so no dump will occur.

just noticed an error in my previous code:

read table itab1 with key ???

if sy-subrc = 0.

<b>modify itab1 index sy-tabix.</b>

else.

append itab1.

endif.

Read only

0 Likes
986

guys..thx for all the infor

i manage to solve it d...it seems tat it is fine to use modify itab1 n itab3 inside d loop itself..juz tat my program got error bcoz i mis put the endloop somewhere..thx again ^^