The Semantically Rich Data Model – An ABAP based CDS Views example Part 3
Co-Authored: Ritesh K Kumaria, Shekhar Razdan
In continuation to the previous Posts (The Semantically Rich Data Model – An ABAP based CDS Views example) & (The Semantically Rich Data Model – An ABA… | SCN )
Annexure 4: How to Expose CDS Views as ODATA
CDS as OData for AS ABAP 7.5.
- Create a CDS view as follows.
- Copy the below code in the newly created CDS view.
- As soon as the CDS view is activated, service <ZCDS_ODATA_CDS> is created.
- Navigate to the Tcode /IWFND/MAINT_SERVICE.
- Click on the “Add Service”.
- Fill the following details on the subsequent screen
- Select the Service and click on Add Selected Services and Press Enter
- The service created successfully
- Service is available in the Service catalog. Double click on the highlighted row
- For testing, Under the ICF Nodes section, Press SAP Gateway Client
- Click on the “EntitySets” and press Execute button. The service is successfully executed, with data for CARRID = “AA”, Status Code = 200 OK.
- On the CDS view Side we can click on the “OData-Service” under Generated Object and test the same as well
- For fetching the data add the entity set name< ZCDS_ODATA> at the last as shown the screen shot below
- Themetadata for the service <ZCDS_ODATA_CDS> can be checked as well through the following
Annexure 5: How to Translate Labels in CDS Views
Column labels, Field Labels, Report names etc. can be specified while creating CDS Views. The Column and Fields can pick up labels from their corresponding Data Elements. This ensures that the translations for the Data Element Labels are available to the fields and thus no separate Translation needs to be done.
However, it is also possible to add fields in field list as literals that do not refer to any Data Element in particular. In such cases the field labels can still be specified using the Annotation “@EndUserText.label:”
The same annotation can also be used to specify the report name that is visible to the end user while consuming the report via an analytical client. So how does one translate the labels that have been specified by using @EndUserText.Label: ?
Similar to other DDIC objects CDS Views are also translatable via TCODE SE63 (Translation Editor).
- Go to Transaction SE63 and client Button “Short Texts”.
- On the Object type Selection Box Double click on A5 User Interface Texts -> DDLS CDS Views. Alternatively use the search buttons to find DDLS and then double click on it to move to next screen.
- Give CDS name and Enter Source and Target Language and then Press “Edit”
- Subsequent screen opens with labels in Original Language and blank fields where corresponding translations can be given in target language. Save the changes when done