For the CDS view extraction from SAP S/4HANA we are going to use
ABAP CDS Reader
operator in DI. It is a standard operator to read data from a CDS view.
Problem description
:
Using this operator, you will not see any headers in the file by default.
There are three versions of ABAP CDS Reader operator. The main difference here is the output data type. But independent of version you are using, the headers are still not visible in the file. This problem we are going to solve in this post.
Solution:
Among these three versions, only ABAP CDS Reader V2 has information about fields in its output. The output data type of this operator is a message. A message has a body and attributes. The body of the output delivers data, and attributes some information about fields, the last batch, etc. There is no standard solution to get headers using Generation 1 graph, we must use a python script.
The pipeline looks like:
-
First operator is the standard ABAP CDS Reader V2 operator.
-
Second operator is a python operator with input "input2" as a message type and output "outData" as a message type.
...
-
Third operator is the standard write file operator as csv.
-
Fourth operator is again a python operator with input "input1" as a message type and output "outData1" as a message type to read the last batch information.
...
-
Last operator is the Graph Terminator which will be terminated when the last batch is true.
Referenced Blog:
SAP Data Intelligence | How to get headers of CDS view | SAP Blogs
Conclusion:
Using the above approach, data is written into a CSV file with headers and the graph will be terminated. This can be helpful for the initial load.
Hope you find the content of this blog helpful. Feel free to comment for further clarifications.