Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
16,258
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


 

 

Extend R_PurchasingDocument

 
@AbapCatalog.sqlViewAppendName: 'ZRPURCHDOCEXT'
@EndUserText.label: 'Extend R_PurchasingDocument'
extend view R_PurchasingDocument with ZR_PurchasingDocument_Ext {
ekko.zsmart_number
}

         


    Extend R_PurchaseOrder
@AbapCatalog.sqlViewAppendName: 'ZRPOEXT'
@EndUserText.label: 'Extend R_PurchaseOrder'
extend view R_PurchaseOrder with ZR_PurchaseOrder_Ext {
R_PurchasingDocument.zsmart_number
}


Extend I_PurchaseOrderTP
@AbapCatalog.sqlViewAppendName: 'ZIPOTPEXT'
@EndUserText.label: 'Extend I_PurchaseOrderTP'
extend view I_PurchaseOrderTP with ZI_PurchaseOrderTP_EXT {
Document.zsmart_number
}


Extend C_PurchaseOrderTP

Annotation @UI lineItem is used to place the fields in list page so that it appears at third position

Annotation @UI.fieldGroup is used to place the field in object page under Delivery and Invoice Tab
@AbapCatalog.sqlViewAppendName: 'ZCPOTPEXT'
@EndUserText.label: 'Extend C_PurchaseOrderTP'
extend view C_PurchaseOrderTP with ZC_PurchaseOrderTP_EXT {

@UI: {lineItem: [ {position: 25, importance: #HIGH} ] }
@UI.fieldGroup: [ { position: 45, qualifier: 'DeliveryInvoiceGroup2'} ]
PurchaseOrderTP.zsmart_number
}


 

Note that since @UI.fieldGroup annotation exist in consumption view C_PurchaseOrderTP we were able to use the same in extended view.

For General Information Tab no such annotation exists, UI adoption on WebIDE may be needed if you want add custom field on Generation Information Tab where you can add frontend annotations.


Step3: Test the CDS view and ODATA Service

Using se16n insert some  test values for our custom fields in EKKO Table.


 

Test Consumption View C_PurchaseOrderTP


 

Check SEGW project MM_PUR_PO_MAINTAIN_V2 for custom field

Since Consumption View C_PurchaseOrderTP is used as Reference Data Source, any extension to this view should automatically appear without need for Regeneration


 

Test OData Service MM_PUR_PO_MAINT_V2_SRV

Using below URL we can fetch the data for PO header and can see fields zsmart_number is returning correct value
/sap/opu/odata/sap/MM_PUR_PO_MAINT_V2_SRV/C_PurchaseOrderTP(PurchaseOrder='4500000006',DraftUUID=guid'00000000-0000-0000-0000-000000000000',IsActiveEntity=true)


 

Step4: Test SAP Fiori UI

We can see that field Smart Number appear as filter option as well as in list page.  We can search for PO documents which have smart number as non empty.


 

 

The smart number also appears on Delivery and Invoice Node of Object Page . We can edit and update the value in database. The draft functionality also works for our field.


 

We were able to achieve all of this without any ABAP code changes and UI adoption so far as CDS Extension, SADL and BOPF Framework, together with SAP Fiori Elements  automatically takes  cares of this.

In  part-2 of this series I will attempt to incorporate below functionality for custom fields.

  1. Adding a Value Help

  2. Adding Validation and Determinations

18 Comments