Skip to Content

Field Controls’ is One of the very efficient and useful feature of ODATA, which allows user to control fields (i.e. Display Only, Optional, Mandatory, Hidden etc) on UI as per configurable / customizing setting set by the application users (especially Administrative Users).

In this blog, I would like to share our experience of implementing Field Control functionality for a custom object built on top of S/4 HANA. We used tools and technologies provided in S/4 HANA to minimize the development effort.

 

Pre-requisite:

Basic knowledge of OData

 

Requirement:

Before getting all technical, let’s see what was the motive behind designing the Field Control feature in OData this way.

A new custom data object is developed with numerous attributes. Front end UI (Fiori) is using these attributes across Tabs available on front end. The requirement is that the application should be able to Control Fields present on various tabs in sync based on customizing settings (i.e. Read-Only, Optional, Mandatory, Hidden) as well as user should be able to give some Default behavior to all the other attributes which are not maintained in customizing / configuration.

As the result of this exercise, we would be able to see a field as Mandatory or Optional or Read Only or Hidden from all tabs simultaneously if user has used it on multiple tabs / screens. UI5 Developer just need to read the value from Metadata and Data to identify which field has which Field Control property assigned to it and what value is assigned to field control individually. Based on this value, UI5 developer can set fields as Hide, Read Only, Optional or Mandatory.

The Feature should support below capability:

  1. Hide: Ability to user to Hide fields on UI.
  2. Read Only: Ability to user to make fields Read Only on UI.
  3. Optional: Ability to user to make Optional on UI.
  4. Mandatory: Ability to user to make Mandatory on UI.

Also, Ability to user to set other UI properties if user has set up the customization accordingly.

Implementation:

A typical S/4 HANA application is built with SAP Fiori as user interface with REST based APIs (in our case OData) calls to backend server to get /post required information.

Let’s see how we can design the ODATA and implement it to provide required results to UI layer.

 

Development Summary:

Any application to be able to work efficiently and with ease have various fields placed under various tabs which categorizes these fields as per their relevance in the application. Also, these applications have Header and Item Fields as well, which again adds fields complexity on UI application. In order to control all these spreaded out fields based on some customization setup by user OData have inbuilt feature of ‘Field Controls’.

To enable this, we would create an OData project with various properties and here in example we will map this OData entity to a Database Table, that will fetch the data from tables and show on UI.

 

Step 1: Create Database Table and Structures for usage in OData Project.

  1. Structure ‘ZSE_DEAL’ – For usage in OData Project to import Project Properties.           
    UXFC_DEFAULT – is used for all those fields which are not maintained in Field-Field_Control Mapping UI Config table (Explained in Point 5).UXFC_01, 02, 03 etc. are given to user to allocate some property (i.e. Hidden, Read Only, Mandatory, Optional) individually to each field in Field – Field Control Mapping.
  2. Transparent Table ‘ZDEAL’ – Table from which Application shows the data in UI and in Metadata. Sample data as show below.                          
  3. Structure ‘ZSE_FIELD_CONTROL_PROP’ – Separate reusable structure created for handling Field Control Metadata and Actual Value for Field control fields. This reusable structure for Fields Control properties, which should be included in the all the relevant entities under an OData Project.                                  

 

Step 2: Create a SAP Gateway project having OData Entity.         

Create a new SAP Gateway project ‘ZDEAL_DEMO’. Right click on Data Model->Import->DDIC Structure. Create the Entity ‘Deal’ and Entity Set ‘DealSet’ using the DDIC Structure ‘ZSE_DEAL’.

 

Step 3: Map the Service Implementation of OData Entity to DDIC Z_DEAL.

In your SAP Gateway project, expand node Service Implementation -> DealSet. Right-click on entity set and choose “Map to Data Source”. Choose DDIC from F4 Search help on popup.

Press ‘Generate Mapping’ button as highlighted. Which will generate appropriate mapping between OData properties and Source Table fields. For the fields, which does not get mapped, manual mapping can be done.

Register the service ‘ZDEAL_DEMO’ generated using Transaction Code: /IWFND/MAINT_SERVICE.

 

Step 4: Enhance Logic in Metadata using Class MPC_EXT and DEFINE Method.

 

 

The Customizing table ‘ZDEAL_UI_CONF’ is used here to store the Mapping between Fields and Field Control IDs. This Customizing table can be used in SPRO where User can maintain it.

 

 

Step 5: Load the Metadata for Service ‘ZDEAL_DEMO’.

As maintained in the Field – Field Control Mapping Customizing tables each of the OData Property is now gets assigned to a Field Control Property (as highlighted).

 

Step 6: Create Customizing for Field Control Values.

Create another Customizing table (which can also be used in SPRO) where user can allocate values to each Field Control IDs individually.

As per standard annotations, following values are assigned to these properties:

Hide              00
Read Only    01
Optional        03
Mandatory    07

Here, per index, UXFC_01 is assigned to value 00, UXFC_02 to 03, UXFC_03 to 07, UXFC_04 to 07.

These values will be displayed when we will use OData service to display data from entity.

Step 7: Enhance Class DPC_EXT method DEALSET_GET_ENTITYSET.

Here for the Demo purpose the values for Field Control are hard-coded. Developers must write appropriate logic to fetch Field control values from the customizing table(configuration) in Step 6 and set it accordingly here to respective placeholder fields.

 

 Step 8: Check the Data and Values of Field Controls.

 

Further Steps:

  1. UI Developers must read the Metadata first to know which fields of the Entity are assigned to which Field Control IDs.
  2. As per Index under point 6, UI Developer must fix meaning of values 00, 01, 03 and 07 as Hidden, Read Only, Optional and Mandatory respectively and must write UI5 code in such a way that if any field which has Field Control ID assigned to it and a corresponding value in Data, UI Code must automatically assign that field, its corresponding type of property.

 

Reference:

Standard OData Project : MM_PUR_PO_MAINTAIN, DPC_EXT class ( Method SET_FIELDCONTROL_INCO3_L ).

There are several other Standard projects as well which uses Field Control Feature, can be used for reference.

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Pawan Kalyan

    Hi Amit Singh, Nice Blog…

    I have added few custom fields using “Custom Fields and Logic” App and automatically  in the MetaData ,  sap:field-control has been created for that Custom Field. 

     

    When I am trying to manipulate visibility in DPC_EXT class , Custom Field properties are not getting changed. I debugged alot and find out ,It is happening because of field – ROLE_SUFFIX of tableCFD_L_DEL_CDS .

    I would like to understand what’s the significance of this field? How to populate this field .

    (0) 

Leave a Reply