Skip to Content
avatar image
Former Member

PUR ME21n hangs on save: read table with key fails

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Oct 12, 2017 at 08:39 AM

    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)

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 11, 2017 at 10:54 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 12, 2017 at 08:49 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 16, 2017 at 07:10 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded