Skip to Content
-3
Jun 18, 2020 at 10:58 AM

DISTINCT Clause is added automatically to query

905 Views Last edit Jun 18, 2020 at 11:00 AM 2 rev

We have a open SQL statement in our ABAP Code as given below.

TYPES:
     BEGIN OF ty_vbak.
         INCLUDE TYPE vbak.
         TYPES: asttx   TYPE  asttx,
         asttx_t TYPE  j_txt30,
     END OF ty_vbak .

DATA:  lt_temp_vbeln            TYPE HASHED TABLE OF ty_vbak WITH UNIQUE KEY vbeln

SELECT head~vbeln
       INTO CORRESPONDING FIELDS OF TABLE lt_temp_vbeln
........

Now when this code is executed on the SQL Server, in the ST12 we can see that a DISTINCT clause has been added to the query as shown below

SELECT DISTINCT "HEAD"."VBELN"
FROM ( "VBAK" .........)

So my question is that how come the DISTINCT clause is added to the query?