Skip to Content
-3

Syntax Check warning

 

Hi all,

I was updating tcode to add two more field to filter. The code shows below run fine but I got a syntax check warning says condition for the key field "MJAHR" does not test for equality. Bit strange I didn't use that field. Could anyone please give me a hand to explain why this happened?

Thanks a lot!

Regards,

Lynn

Clear lv_mseg_lgort.
Select single lgort Into lv_mseg_lgort
From mseg
Where mblnr = ls_output-refbn and
      zeile = ls_output-refbz.
If sy-subrc = 0.
      ls_output-lgort = lv_mseg_lgort.
Else.
      ls_output-lgort = ''.
Endif.

"Syntax check warning
This warning is only displayed in SLIN
In "SELECT SINGLE ...", the WHERE condition for the key field "MJAHR" does not
test for equality. Therefore, the single record in question is possibly not
unique.
Internal Message Code: MESSAGE GSB"

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Apr 17 at 09:07 AM

    It's telling you that technically it's possible to have multiple entries with the same MBLNR in the database, each belonging to a different MJAHR. Combined with SELECT SINGLE, it's telling you that you're just going to get a random result if this is the case.

    Only if you add MJAHR, you're guaranteed to get exactly the record you want.

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 17 at 10:12 AM

    Hi Lynn,

    Select single is usually to get the unique row from table , i.e to pass the complete key.

    when key is partially , Extended check will show an error as it might pick up random row .

    You can get the more information at

    https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abapselect_single.htm

    To solve the problem , You can either pass the complete key in where clause or you can use select upto 1 rows

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 18 at 06:47 AM

    https://blogs.sap.com/2015/03/11/selecting-one-line-from-an-database-table/

    "The syntax documents the semantics of your statement in the program and the extended program check warns you, if you do not specify the full key."

    Add comment
    10|10000 characters needed characters exceeded