Skip to Content

Create Custom Logic Using Key User Extensibility and Perform Trace

Create custom logic for an existing custom field in S/4HANA Cloud ABAP Environment, then check its parameters using the Custom Logic Tracing app
You will learn
  • How to create custom logic for an existing custom field in the app Custom Fields
  • How to run a trace for the Fiori app Create Purchase Order in the app Custom Logic Tracing
  • How to check the output value of this custom field using Custom Logic Tracing
  • How to check the custom logic of this custom field, in Custom Fields
julieplummer20Julie PlummerNovember 24, 2022
Created by
May 24, 2022


  • You have a license for SAP S/4HANA Cloud
  • You are familiar with Key User extensibility in SAP S/4HANA Cloud. If not, see the More Information section
  • You are familiar with the app Custom Logic Tracing. If not, see the More Information section
  • In SAP Fiori launchpad, you have the following authorizations:
    • SAP_BR_PURCHASER for the app Create Purchase Order - Advanced
    • SAP_BR_ADMINISTRATOR for Custom Logic Tracing and Custom Logic
  • You have created a custom field using Key User extensibility yy1_zhdrprnt2_pdh_000
  • In Custom Logic, you have created a BAdI implementation YY1_FILLHEADERCUSTOMFIELDS_000 in the business context and BAdI definition Modify Purchase Order Header (MM_PUR_S4_PO_MODIFY_HEADER)

The administrator receives an welcome e-mail after provisioning. This e-mail includes the system URL. By removing /ui you can log into the SAP S/4HANA Cloud ABAP Environment system. Further information can be found Developer Extensibility: Connect to the ABAP System.

Throughout this tutorial, the placeholder ### or 000 is used. Always replace this with your initials or group number.

  • Step 1
    1. Open the app Custom Fields.

    2. Change to the Custom Logic tab, search for the BAdI implementation YY1_FILLHEADERCUSTOMFIELD_000.

      Link text e.g., Destination screen
    3. Open the Details screen (by choosing the arrow on the right).


    You can now see the Published Logic and Draft Logic, if they exist, relevant to the custom field.

    Log in to complete tutorial
  • Step 2
    1. Comment out any existing code.

    2. In the custom logic for the field yy1_zhdrprnt2_pdh_000, copy the following code.
      This code will copy the content from a standard field, purchaseorder-supplyingplant into the custom field, yy1_zhdrprnt2_pdh_000, where supplyingplant is filled.

      IF purchaseorder-supplyingplant is not initial.
      purchaseorderchange-yy1_zhdrprnt2_pdh_000 = purchaseorder-supplyingplant.
    3. Save and publish your custom code.

    You are now ready to trace the effects of your custom code when a purchase order is created.

    Log in to complete tutorial
  • Step 3
    1. Open the app Custom Logic Tracing and choose Start Trace.

    2. Enter the following information, remembering to change the placeholder to your group number or initials:

      Field Name Value
      Name Test Create PO Custom Fields 000
      Trace User Your user
      Stored until future date in the format
      Lifetime 15
    Log in to complete tutorial
  • Step 4

    IMPORTANT: While Trace is running, create a purchase order as follows.

    1. Open Create Purchase Order - Advanced.

    2. In the top header, change the Order Type to Stock Transport Order and the Supplying Plant to 1010.

    3. Enter the Supplying Plant, 1010

    4. In the header section, go to the Custom Fields tab, check that the custom field ZPOHDRPRINT2 now contains the value 1010.

    5. On the Org Data tab, enter the following:

      Field Name Value
      Purchase Organization 1010
      Group 001
      Company code 1010

      If you check the custom field YY1_ZHDRPRNT2_PDH_000, it is now filled with the same value as Supplying Plant, 1010.

    6. In the Item Overview section, enter the following. Ignore any warnings.

      Field Name Value
      Material Tg0501
      PO Quantity 1
      Delivery Date future date in the format
      Plant 1010

      The other fields - Material Group, Plant Storage Location - should be filled automatically.

    7. Choose Save.

    Log in to complete tutorial
  • Step 5
    1. Choose Finish trace.

    2. Open the trace. In Trace Hierarchy, choose the last call of BAdI implementation YY1_FILLHEADERCUSTOMFIELD_000.
      (This is necessary because the BAdI implementation is called several times.)
      Then choose the parameter Purchase Order.

    3. Scroll right down to the field YY1_ZHDRPRNT2_PDH_000. Check that its value = 1010.

    Log in to complete tutorial
  • Step 6

    In which Fiori app do you find all custom implementations that are called during a process?

    Log in to complete tutorial
  • Step 7

    Log in to complete tutorial
Back to top