Wednesday 5 October 2022

POWL Enhancement in SAP TM: Standard Hidden Field and Custom Field in Freight Unit Overview Screen

Introduction


I have provided a detailed guide on how to add custom Date/Time Field in your FPM Application. In this blog post, you will learn how to enhance the Overview screen and add custom field as well as Standard hidden fields in your active Query in the Overview Screen.

POWL Enhancements are a tad bit different than enhancing FPM applications. They are subject to the Active Query in POWL which is present in the Planning component of NWBC screen in SAP TM.

Business Scenario:


We will discuss two scenarios of POWL Enhancement here.

1. Add hidden Standard field (Delivery) in the Freight Unit Overview Screen that are present in the UI Result structure but are not displayed normally.

2. Enhance POWL to add custom field (Original Order) to the Freight Unit Overview Screen.

SAP ABAP, SAP ABAP Tutorial and Materials, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP Prep, SAP ABAP Preparation

Display Hidden Standard Fields on Freight UnitOverview Screen (POWL)

 
Step1: Get the Application ID and the POWL Type

Get the Application ID and the POWL Type using the Function Module POWL_QUERY_REFRESH. Put a Breakpoint on the below statement and open/refresh the Overview Freight Units screen on NWBC screen. When you refresh or open the screen, it will stop at that point.

SAP ABAP, SAP ABAP Tutorial and Materials, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP Prep, SAP ABAP Preparation

Here, the Application ID is ‘SCMTMS_POWL_FU’ and the POWL Type is ‘SCMTMS_TOR_FU’.

Step2: Go to TCode ‘POWL_COCKPIT’ and get the Feeder Class

In the TCode ‘POWL_COCKPIT’, choose the ‘Standard POWL’ radio button and execute.

SAP ABAP, SAP ABAP Tutorial and Materials, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP Prep, SAP ABAP Preparation

Choose ‘Maintain Type’ button in the next screen.

SAP ABAP, SAP ABAP Tutorial and Materials, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP Prep, SAP ABAP Preparation

Now, search the list using the POWL Type you obtained in STEP1. Once you identify the POWL TYPE, get the corresponding Feeder Class by double clicking the POWL Type.

SAP ABAP, SAP ABAP Tutorial and Materials, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP Prep, SAP ABAP Preparation

SAP ABAP, SAP ABAP Tutorial and Materials, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP Prep, SAP ABAP Preparation

The POWL Feeder Class here is ‘/SCMTMS/CL_UI_POW_FD_TOR_FU’.

POWL Feeder Class is the access point for a POWL. And in TM, there is a one-to-one relationship between a Business Object Query and a Feeder Class. A Feeder Class holds all the relevant details of a Query like selectioncriteria, field catalog etc.

Step3: Get the Selection Criteria Structure and Result Structure

Go to SE24 TCode and open the Feeder Class obtained in the previous Step. Keep a breakpoint on the below statements at the method ‘CONSTRUCTOR’ of the POWL Feeder Class ‘/SCMTMS/CL_UI_POW_FD_TOR_FU’.

SAP ABAP, SAP ABAP Tutorial and Materials, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP Prep, SAP ABAP Preparation

The Structure ‘/scmtms/if_ui_pow_const=>co_output_structure_name-fu’ will have the result structure (Output Structure) and ‘/scmtms/if_ui_pow_const=>co_selcrit_structure_name-fu’ will have the selection criteria structure.

SAP ABAP, SAP ABAP Tutorial and Materials, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP Prep, SAP ABAP Preparation

Result Structure: /SCMTMS/S_UI_POW_R_FU

The Result Structure contains the list of attributes that are going to be displayed on the Overview screen.

Selection Criteria Structure: /SCMTMS/S_UI_POW_S_FU

The Selection Criteria Structure contains the list of attributes that are available as selection criteria for the queries. According to the first Business Scenario, we will first enhance the Result Structure and insert the field ‘Delivery’.

Step4: Enhance the Field Catalog Method of Feeder Class for Display

We need to enhance the below method of Feeder Class to display the hidden Standard Field. Here, the Standard Field is already available in the Result Structure but is not enabled. We need to enable this field and make it visible.

Class -> /SCMTMS/CL_UI_POW_FD_TOR_FU
Method -> IF_POWL_FEEDER~GET_FIELD_CATALOG

SAP ABAP, SAP ABAP Tutorial and Materials, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP Prep, SAP ABAP Preparation

Step5: Manipulate the Data in GET_OBJECTS Method of Feeder Class

However, in case of field BASE_BTD_ID (Base Business Transaction Document), the FU BO Structure has all the original order details including SO, STO, PO, Delivery etc. Therefore, to restrict all values except Delivery, we need to add below custom code in the below method to manipulate the data flowing into the Result Structure.

Class -> /SCMTMS/CL_UI_POW_FD_TOR_FU
Method -> IF_POWL_FEEDER~GET_OBJECTS

SAP ABAP, SAP ABAP Tutorial and Materials, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP Prep, SAP ABAP Preparation

SAP ABAP, SAP ABAP Tutorial and Materials, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP Prep, SAP ABAP Preparation

Step6: Refresh the POWL Query to get the changes reflected in UI.
 

Display Custom Fields on Freight Unit Overview Screen (POWL)


This scenariois like the above scenarioin some aspect. The difference is that in this case, the Custom Field to be added (Original Order: SO/PO/STO) is not present in the Result structure or the Selection Criteria Structure.

Therefore, we need to add the custom field in both the Result and Selection Criteria Structure.

As we are adding the custom field in the same Freight Unit Overview Screen like the above scenario, few steps will be common in both. So, without further ado, lets get started.

1st Step: Repeat Step1 to Step3 to get the Feeder Class as well as the Result Structure and Selection Criteria Structure.

• Result Structure: /SCMTMS/S_UI_POW_R_FU
• Selection Structure: /SCMTMS/S_UI_POW_S_FU
• Feeder Class: /SCMTMS/CL_UI_POW_FD_TOR_FU

2nd Step: Add Custom Field to the Result Structure and the Selection Criteria Structure

SAP ABAP, SAP ABAP Tutorial and Materials, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP Prep, SAP ABAP Preparation

3rd Step: Enhance the Field Catalog Method of Feeder Class for Display

Class -> /SCMTMS/CL_UI_POW_FD_TOR_FU
Method -> IF_POWL_FEEDER~GET_FIELD_CATALOG

SAP ABAP, SAP ABAP Tutorial and Materials, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP Prep, SAP ABAP Preparation

4th Step: Populate Data in Custom Field

The code to obtain the data from the node structure is given in the previous scenario. Here is the code to map the data to the custom field.

Class -> /SCMTMS/CL_UI_POW_FD_TOR_FU
Method -> IF_POWL_FEEDER~GET_OBJECTS

SAP ABAP, SAP ABAP Tutorial and Materials, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP Prep, SAP ABAP Preparation

5th Step: Map the UI Fields with the BO Node Element

Go to SE38 and execute Report /SCMTMS/MAINT_QUERY_ENH.

Here, the Original Order Field data is already fetched by the Query FU_DATA_BY_ATTR and is present in the DOCREF structure. Therefore, we only need to enhance and map the Result Structure field with the BO Node element.

Therefore, we only need to enhance the Result Structure. Choose the Result Structure and execute.

SAP ABAP, SAP ABAP Tutorial and Materials, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP Prep, SAP ABAP Preparation

The FU details are present in the TOR structure and can be fetched using the Query FU_DATA_BY_ATTR. Moreover, the Original Order data is present under the BASE_BTD_ID field of DOCREFERENCE Node. Hence, we do not need to add any custom field in the node structure. We can just map the BASE_BTD_ID field to our UI Custom Field ZZORG_ORD.

SAP ABAP, SAP ABAP Tutorial and Materials, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP Guides, SAP ABAP Prep, SAP ABAP Preparation

Once you have maintained the above details, save and capture in TR to imported to higher environments.

6th Step: Refresh the POWL Query to get the changes reflected in UI.

Source: sap.com

No comments:

Post a Comment