quinta-feira, 4 de julho de 2019

Fiori for SAP S/4HANA – Identifying the OData Services, CDS Views, and Authorizations of a SAP Fiori App

This blog post explains how to identify the underlying components of a Fiori app
From time to time, you may need to find out what OData Services, CDS Views and Authorizations are used by a specific SAP Fiori app.  For example, you may need this to:
  • Build your security profiles
  • Plan an extension
  • Troubleshoot an issue


From Fiori app to the underlying OData Services

There are 2 ways to confirm this:
  • Via the Fiori Apps Library
  • Via the app’s manifest.json file

Option 1 – Fiori Apps Library

In the Fiori Apps Library, find the Fiori app you are interested in.
For the specific Fiori app, in the Detail View go to the
Implementation Information tab > Configuration section >  see list of OData Services
Example:
Supply Chain Visualization
for Transportation Scheduler (Oil & Gas)

https://fioriappslibrary.hana.ondemand.com/sap/fix/externalViewer/#/detail/Apps(‘F2737’)/S13OP

If you want to see all the OData Services for all your Fiori apps, you can also view & download this using the List View
Just select the apps > select List View > use the Settings icon button to change the selection to include OData Services.

When you download you will see both the primary and any additional OData Services


Option 2 – Manifest.json

Get the SAPUI5 technical name from the Implementation Information > Configuration > SAPUI5 Application
Example: For Supply Chain Visualization, it is VISUAL_SCM_S1

 
In GUI transaction SE80, in the Repository Browser, select application type BSP Application and enter the technical name, and press Display. Expand the Page Fragments to find the manifest.json file and open it.  Look for the section “dataSources” and you will find the path to the OData Services

In this example the OData Services TSW_VISUAL_SHIPMENT_SRV and VBI_APPL_DEF2_SRV are shown, i.e. uri path “/sap/opu/odata/SAP/TSW_VISUAL_SHIPMENT_SRV” and “/sap/opu/odata/sap/VBI_APPL_DEF2_SRV” respectively.
TIP: For Fiori elements you can also identify the most important OData Entity Sets in the manifest.json – i.e. those main Entity Sets assigned to the Fiori elements pages.

From OData Services to CDS Views

There are different techniques depending on how the CDS Entities were exposed to the OData Service.  You can identify which technique via the naming convention used in the OData Service.
Exposing CDS Entities as OData Service

OData Service with naming convention <xxxxxx>_CDS

Remove the _CDS suffix and that is your CDS View name. Yes it’s that simple!
Example: (anything from KPI Workspace or search in Fiori Apps Library > Fiori apps for S/4HANA > All Apps > search on _CDS
181 Apps!

Supplier Payment Analysis(Open Payments) (S/4HANA)

for Accounts Payable Manager
https://fioriappslibrary.hana.ondemand.com/sap/fix/externalViewer/#/detail/Apps(‘F1750’)/S13OP
Implementation Information > Configuration >  see list of OData Services

OData Service =  C_APVENDOROPENITEMS_CDS

Therefore CDS view = C_APVENDOROPENITEMS
You can review the CDS Views using ABAP Development Tools in Eclipse. Within your ABAP Project for your system/client/user id, use the Open ABAP Development Object menu option to search for and open the matching CDS View Data Definition.

Why does this work? These CDS Views have been auto-generated using annotation @OData.Publish: true
ABAP Prog Model for Fiori help
https://help.sap.com/viewer/cc0c305d2fab47bd808adcad3ca7ee9d/201809.002/en-US/3b77569ca8ee4226bdab4fcebd6f6ea6.html

OData Service with naming convention <xxxxxx>_SRV

Remove the _SRV and that is your Gateway Project name.
TIP: There are some exceptions so if this does NOT find the Gateway Project name go to the any other naming convention option.

Open Gateway Project in transaction SEGW – or using ADT in Eclipse.


Within the Gateway Project, expand the Data Model.
Within the Data Model expand the Data Source References.
Within the Data Source References, expand the Exposures via SADL, then CDS Entity Exposures, then Entity Types.


Remove the suffix Type from the Entity Types and those are your CDS View names.
Example:
Entity Type name = C_VisualLocationsType
Therefore CDS View name = C_VisualLocations

Once you know the CDS View name you can view the matching data definition in ABAP Development Tools for Eclipse.

 
Why does this work? These CDS Views have been auto-generated using Referenced Data Source technique.
Reference ABAP Prog Model for Fiori help
https://help.sap.com/viewer/cc0c305d2fab47bd808adcad3ca7ee9d/201809.002/en-US/3b77569ca8ee4226bdab4fcebd6f6ea6.html

OData Service with naming convention CB_<xxxxxxxxx>

These are OData Services that support Fiori Search and are written with a special approach.

Go to transaction /IWFND/MAINT_SERVICE. Use the filter to search for the OData Service using the External name. You can use wildcards, e.g. cb_cost_c*

Once you find the service, select the row and then press the System Implementation button.

In the System Implementation you will find the ABAP Class for the Data Model

Drill down on the Data Provider Class to see the underlying ABAP Class coding.
Find the GET_ENTITYSET method

Drilldown on the GET_ENTITYSET method to review the ABAP code and determine how the data was retrieved. This may include CDS Views and BAPIs.  You may need to set a debug breakpoint.

Any other OData Service

Any other naming convention usually indicates it is a Mapped OData Service approach for SAP Gateway Projects.

Example:
Fiori app Periodic Meter Reading Overview for Meter Reading Specialist (Utilities)
https://fioriappslibrary.hana.ondemand.com/sap/fix/externalViewer/#/detail/Apps(‘F2186’)/S13OP

OData Service ISU_MR_PERDC_OVP

Go to /IWFND/MAINT_SERVICE, use the filter to find the OData Service.
Select the service and then press Service Implementation

In the Service Implementation details, find the Model Provider Class

Open the class and look for method IF_SADL_GW_MODEL_EXPOSURE_DATA~GET_MODEL_EXPOSURE. Note: You may need navigate to the super class.

Once you have found the method, review the code and search for entries with dataSource type=”CDS”.  The binding value contains the CDS View name. There may be several.
For example you can see the CDS view C_METERRDNGUNITSCHEDRECDOVW has been mapped.


You can also look for the line of code indicating the Gateway Service Project, in this case ISU_MR_PERDC_OVP.


Once you know the CDS View you can find it directly.

Why does this work?
Mapped OData Services use manually mapped references to CDS Views.


Becoming a SAP Fiori for SAP S/4HANA guru

Some words around… thanks  to my colleague Jocelyn Dart for drafting this blog post.
You’ll find much more on our SAP Fiori for SAP S/4HANA wiki
Brought to you by the S/4HANA RIG


Source: https://blogs.sap.com/2019/07/03/fiori-for-sap-s4hana-identifying-the-odata-services-cds-views-and-authorizations-of-a-sap-fiori-app/

Nenhum comentário:

Postar um comentário