Syntax and usage of several data_source~* in query

Hi,

We can use data_source~* in  OPEN SQL to select all columns from table.

https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abapselect_list.htm#!ABAP_VARIANT_1@1@

But what happens if we have several tables with overlapping column names? For example:

 

TYPES:
BEGIN OF t_output,
vbeln TYPE vbeln,
kunnr TYPE kunnr,
name1 TYPE name1,
ort01 TYPE ort01,
END OF t_output,
tt_output TYPE STANDARD TABLE OF t_output WITH EMPTY KEY.

DATA:
output TYPE tt_output.

SELECT FROM vbak LEFT JOIN kna1 ON kna1~kunnr = vbak~kunnr
FIELDS vbak~*, kna1~*
INTO CORRESPONDING FIELDS OF TABLE .

 

 

VBAK and KNA1 have field KUNNR, which also exists in target area. From what I’ve observed, it’s filled from last table containing this field. So in above example, it will be filled from KNA1. If I were to change order to 

 

FIELDS kna1~*, vbak~*

 

it would take field value from VBAK. I’ve checked SQL Trace and generated query confirms it.

Question is, is it reliable? Can I be sure, that in first example KUNNR will always be taken from KNA1? Or is it effectively random? Is there any documentation about generated query in such cases?

Scroll to Top