How to read the data of CDS view association with ABAP

tags: ABAP  CRM  Original SAP technical article by Jerry Wang

AG3, view name Zorder_Sys_Status.
This view has an association named _statushelp:

Requirement

I would like to read the guid from host view Zorder_Sys_Status together with its associated data via association _statushelp.

(1) Since there is no existing data type which holds both host view field and associated view fields, you have to create one on your own:

(2) Use the following syntax in ABAP 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.

By the way, when the association defined in CDS view is consumed via OPEN SQL, it will be converted to LEFT OUTER JOIN, as could be observed in SQL trace:


In ST05, select your trace record, and click this button in toolbar:

For more original articles by Jerry, please pay attention to the public number "Wang Zixi":

Intelligent Recommendation

Step by step to create ABAP CDS view

Add AG3 or ER9 in your local SAPGUI. Open your ABAP Studio: Select the system where you will work: Click next: Once done, you can find your new project: Create your own package in SAPGUI: And add it t...

Use ODBC SAP ABAP CDS View in Excel

Consuming CDS View Entities Using ODBC-Based Client Tools This article introduces the method of visiting the ABAP system CDS View data based on the ODBC (Open DataBase Connectivity) SQL statement. ODB...

Enhanced ABAP Development with Core Data Services (CDS)

Enhanced ABAP Development with Core Data Services (CDS) How CDS Brings a Modern Data Modeling Approach to ABAP Foreword: With the advent of SAP HANA, a new data modeling infrastructure called core dat...

How to create CDS view to return Service order item detail data

Requirement You are asked to create a CDS view which must return the following information of Service order line item. (1). Create a CDS view which return system status code and description like below...

Tutorial: ABAP CDS view permissions based on access control

Hi! For each CDS view, we can define access control through DCL (Data Control Language). In this article, I will introduce a very important aspect of ABAP CDS view: permission management. This article...

More Recommendation

SAP CDS view in the association will be compiled into LEFT OUTER MANY TO ONE JOIN

An example: I've written in ABAP Development Tool in CDS view association, after activation, read the CDS view at run time: Use transaction code ST05 obtained database trace file, found that the assoc...

How to get the current system date and system time from ABAP CDS

Date and time in CDS $session.system_date TSTMP_CURRENT_UTCTIMESTAMP( ) TSTMP_CURRENT_UTCTIMESTAMP () gets the current timestamp; Use the time zone problem Date / Time Conversion SQL function can only...

ABAP CDS Table Function

Do a Demo of Table Function in ABAP CDS today 1, define Table Function 2, in the ADMP class to achieve the Table Function's fetch logic 3, use Table Function in the program  ...

ABAP CDS - String Functions

The following table shows the ABAP CDS CDS in view of the potential string SQL functions, and the requirements for parameters. Meaning function can be found in the SQL function string.   function...

ABAP CDS - SELECT, WHERE

format result CDS view defined conditions Where the result set.When accessing CDS view, the result set contains only data from a data source data source, where the conditions specified in the followin...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top