Skip to Content
1

PUR ME21n hangs on save: read table with key fails

Oct 11, 2017 at 09:59 AM

98

avatar image
Former Member

Since yesterday we have a problem in the pruchasing module. When hitting save in ME21n, under some conditions the program goes into an endless loop. So i debugged it and noticed, that something strange is happening in a standard sap include.

In a loop over table tkomp, new lines are appended to tkomp, because

 read table tkomp with key komp-kposn binary search.

fails to find the line in the table, but it is definetly there..

I have never seen this syntax before, where the "key =" statement is missing, but the syntax check does not complain.

So i did a simple test with the following result:

DATA: lt_komp type STANDARD TABLE OF komp WITH HEADER LINE,
      ls_komp like LINE OF LT_KOMp.

lt_KOMp-KPOSN = 10.
APPEND LT_KOMP.
lt_KOMp-KPOSN = 20.
APPEND LT_KOMP.
lt_KOMp-KPOSN = 20.
APPEND LT_KOMP.
lt_KOMp-KPOSN = 30.
APPEND LT_KOMP.

break-POINT.
*Search test:
LT_KOMP-KPOSN = 20.
LS_KOMP-KPOSN = LT_KOMP-KPOSN.

*** Syntax i am used to and works:
READ TABLE LT_KOMP with KEY KPOSN = LT_KOMP-KPOSN BINARY SEARCH.
* sy-subrc = 0, sy-tabix = 2
READ TABLE LT_KOMP with KEY KPOSN = LT_KOMP-KPOSN.
* sy-subrc = 0, sy-tabix = 2

*** ME21n syntax, does not work:
READ TABLE LT_KOMP with KEY LT_KOMP-KPOSN BINARY SEARCH.
* sy-subrc = 8, sy-tabix = 5
READ TABLE LT_KOMP with KEY LT_KOMP-KPOSN.
* sy-subrc = 4, sy-tabix = 0

So this syntax seems not to work. Did it got obsolete with an support package (i have no informations that any update has been installed)? But why does the syntax check do not complain it?

I am a bit confused.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Raymond Giuseppi
Oct 12, 2017 at 08:39 AM
1

This is an obsolete form of READ TABLE: Look for ... WITH KEY dobj.

Did another program/exit/BAdI/enhancement insert non sorted records into the internal table, did you check number and order of records in the internal table during debug of application (or change your test program to insert record in a wrong order)

Share
10 |10000 characters needed characters left characters exceeded
Jürgen L
Oct 11, 2017 at 10:54 AM
0

If this started yesterday then it is probably much easier to look with SE09 for all the imports that have been done between the last time when it worked and the time it started not to work.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

i could not find any import in this time span, that could have such an effect. Very strange.

0
Dibyendu Patra Oct 12, 2017 at 08:49 AM
0

This is not the cause of performance issue. The same code is here in my system but no performance issue.

Look into the OSS note for basic issues of performance 1942976 - Performance issue when using transactions ME21N, ME22N, ME23N and related notes.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Oct 16, 2017 at 07:10 AM
0

I could solve the issue now. The problem was, that a collegue modified the SAP structure KOMP. He added a field at the beginning. So the read table could not use kposnr as key, which was the first element before..

Normal read table with key = X statements still work, but the obsolete read table with X does not.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

How could you have missed this in SE09?

0