In part-1 of this blog series we will add a custom field Smart Number to SAP S/4HANA Manage Purchase Order SAP Fiori app and also make it editable so that data will persist in Database.
Manage Purchase Order is Created using below principles:
Backend SAP Fiori Elements on CDS for UI annotations
Reference Data Source to enable OData query options using SADL Framework
BOPF to handle Transactional Behavior including Draft handling
In theory any app which is created using above principles can be extended in similar way including those created using auto generated OData services (@ OData publish true).
Please note that SAP also provides key user extensibility which enables customers to enhance standard apps without any technical knowhow.
However, if key user extensibility is not supported for the app you want to enhance, then the method mentioned in this blog can be used which is more generic in nature.
On High level below steps are required to extend the SAP Fiori App.
Add custom fields to the extension include (DDIC Structure) so that custom fields appear in DB Table, Draft Table and BO Persistent Structure
Extend the Transactional and Consumption CDS views with custom fields. The fields are automatically available in OData service metadata and no regeneration is required.
In some cases UI Adoption in WebIDE may be required if backend SAP Fiori Elements are missing in the Standard consumptions CDS view. For our use case we will extend the Delivery and Invoice node at PO header and we would not require any UI adoption .
Step1: Add custom fields to structure EKKO_INCL_EEW_PS
We will use append structure to add custom field ZSMART_NUMBER.
Enhancing structure EKKO_INCL_EEW_PS automatically enhances the PO header table EKKO and Draft Table PURORDTP_D with custom fields as this structure is used as include in both tables as well as Business Object Persistent Structure.
Another advantage is that EKKO_INCL_EEW_PS is an extension include provided by SAP standard and no additional code is required to transfer the data from business layer to database layer.
Note that you can also use CI Include CI_EKKODB to add your custom fields.
Step2: Enhance the Consumption and Transactional CDS View
C_PurchaseOrderTP is the consumption view which is used as reference data source in SEGW OData project and will be enhanced so that custom fields appear on SAP Fiori application.
I_PurchaseOrderTP is the transactional view with associated BOPF node, and is responsible for transactional behavior. This view also needs to be enhanced so that we can save data for custom field
R_PurchasingDocument is the basic view which gets data from EKKO.
We will extend all four view highlighted below so that custom fields are available in Consumption and Transactional CDS View