How to read CDS view association data with ABAP code
This article mainly introduces how to use ABAP code to read CDS view association data, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
I have the following CDS view, whose data comes from CRMD_ORDERADM_H, defines an association named _ statushelp, and points to another CDS view Z_C_Status_Valuehelp. The view exposes two fields, STATUS_KEY and STATUS_TEXT.
Now my requirement is that I only need to read once 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 association view Z_C_Status_Valuehelp.
Solution
(1) create a new data type that contains a total of 3 fields to be read for two view.
(2) read the data using the following code:
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.
Thank you for reading this article carefully. I hope the article "how to read CDS view association data with ABAP code" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!