I have the following CDS view, the data of this view comes from CRMD_ORDERADM_H, an association named _statushelp is defined, and it points to another CDS view Z_C_Status_Valuehelp. The view exposes two fields STATUS_KEY and STATUS_TEXT.
Now my requirement is: only one read operation is required in the ABAP code, which can read not only the guid field in the main view, but also the two fields STATUS_KEY and STATUS_TEXT exposed by the association view Z_C_Status_Valuehelp.
solution
(1) Create a new data type that contains a total of 3 fields to be read from the two views.
(2) Use the following code to read data:
DATA: lt_data TYPE tt_Data. SELECT guid, \_STATUSHELP-STATUS_KEY AS STATUS_KEY , \_STATUSHELP-STATUS_TEXT AS STATUS_TEXT FROM ZORDER_SYS_STATUS WHERE ZORDER_SYS_STATUS~GUID = 'FA163E8EAB031EE6A99F824537D112A4' AND ZORDER_SYS_STATUS~STAT = 'I1002' AND \_STATUSHELP-STATUS_KEY IS NOT NULL INTO TABLE @lt_data.
To get more original technical articles from Jerry, please follow the public account "Wang Zixi" or scan the QR code below: