Skip to Content

点这里查看中文版

1. Requirement

In order to fulfill some requirement, we may need a custom tab for transaction VF01/VF02/VF03 with some custom field(s) in that sub screen, in this document we take GTI (Golden Tax Invoice) for example.

2. Symptom

There is no screen enhancement or user exit for us to enhance the billing document tab, for SAP standard, only BADI (BADI_SD_CUST_HEAD, BADI_SD_CUST_ITEM) to do this, but both these BADIs are only provided for SAP internal use.

3. Environment

This document is under SAP ERP 6.0 EHP7 with IDES on NetWeaver 7.42, and also verified on SAP S4/HANA 1511(S4Core 100 SP03) on NetWeaver 7.49.

This document is under SAP GUI 750 Patch 1.

4. Reproducing the Issue

When we try to create BADI implementation for BADI_SD_CUST_HEAD or BADI_SD_CUST_ITEM, we get the error message “BAdI definition BADI_SD_CUST_xxxx is only provided for SAP internal use”.

Check the BADI definition, we can find that these BADIs marked as “Within SAP”, so we cannot use this BADI to add our own data.

5. Reason and Prerequisites

5.1 Reference

SAP Note 864944[1] describe the detail on this, these BADIs are only intended to be used for individual SAP industry solutions, and there is no solution according to the note.

5.2 Investigate

This document we take header tab on billing document for example, intended to add two fields GTI number and GTI generate date, and related data should be stored into VBRK by append structure.

From SE93, we could find the main program of VF03 is SAPMV60A (VF01/VF02 are the same), then check the screens on repository browser for program SAPMV60A, screen 6001/6101 maybe the related ones.

From where-used we can found that BADI_SD_CUST_HEAD is used within function module GET_HANDLE_SD_CUST_HEAD, and there are only 4 hits for this function module

Also check from screen (take 6001 for example), there is module CUST_HEAD_ACTIVATE in flog logic to call CUST_HEAD_ACTIVATE which using the function module GET_HANDLE_SD_CUST_HEAD.

From the navigation target for IF_EX_BADI_SD_CUST_HEAD~ACTIVATE_TAB_PAGE we could found there is an BADI implementation within the SAP standard, CL_IM_WB2_IVGUI_LAYOUT_H is referring to BADI implementation WB2_IVGUI_LAYOUT_H which could be found with SE19

So the conclusion is that BADI implementation WB2_IVGUI_LAYOUT_H is referring to BADI definition BADI_SD_CUST_HEAD, which is store in package WB2B_CORE for Global Trade Industry solution.

According to this, the whole picture to adding custom tab to billing document is to implement BADI which related to screen 6001 and 6101, since this BADI are not allowed to be implemented by ourselves, we could try to inject the similar code to screen 6001 and 6101 to achieve the goal.

5.3 Verification

Let’s debug to find out all the key point.

There are four methods within BADI implementation WB2_IVGUI_LAYOUT_H, we set breakpoint for each method, and pick a billing document to change with VF02.

When we go to the header tab, the first breakpoint is for ACTIVATE_TAB_PAGE.

When we switch to “Global Trade Management” tab, which is enhanced by BADI implementation WB2_IVGUI_LAYOUT_H, the second breakpoint is for TRANSFER_DATA_TO_SUBSCREEN.

When we input data or press button on the screen, the third breakpoint is for PASS_FCODE_TO_SUBSCREEN, and then the fourth breakpoint is for TRANSFER_DATA_FROM_SUBSCREEN.

Using debugger “Return (F7)” we can verify that these four breakpoint all related to screen 6001 and 6101, the previous conclusion verified.

All above are based on SAP ERP 6.0 EHP7 IDES, but basically for production environment we don’t have “Global Trade Management” tab, let’s find out the root cause.

Check the code within WB2_IVGUI_LAYOUT_H->ACTIVATE_TAB_PAGE and trace back, the control point come from TWGTAWB2_ADDON_ACTIVE.

Table TWGTA is maintained by view V_TWGTA, which located at SPRO–>Logistics – General–>Global Trade Management–>Active Components, and under “Enhancement Settings”–>”Add-Ons Active”.

When this option set to “2 Active for All Documents”, we can see the enhance tab named “Global Trade Management” in billing document header.

Try to set it as “Inactive”.

Then the “Global Trade Management” tab disappears.

This option is for an industry solution named “SAP Enterprise Extension Global Trade”, which contains in an individual component EA-GLTRADE, which merged into S4CORE from S4/HANA 1503.

This option differed between different SAP version, default as below:

6. Solution

6.1 Side Effect

There is only one screen reserved for enhancement on billing document header, we should check carefully for the validity of “Global Trade Management” before we adding our own custom tab to billing document header.

Below solution based on we deactivate the “Global Trade Management”, if we want to add custom data when “Global Trade Management” activated, consider to process it within BADI WB2_IVGUI_LAYOUT_H, will not discuss it in this document, referring to main program SAPLWB2B_SCREEN_HANDLING.

6.2 Append Structure

We will append ZZ fields to VBRK, which will be shown in custom tab, in order to populate the data to VBRK automatically. All the name should start with double Z to prevent conflict because some standard field name start with single Z.

Create data element ZGTINO and the description, data type, field label like below:

Create data element ZGTIDT and the description, data type, field label like below:

Display table VBRK, and go to Append Structure…, then click the Create Append and fill in the append name “ZZVBRK_APPEND_GTI”, structure name should start with “ZZ”

Fill in component “ZZGTI_NUM” and “ZZGTI_DAT” using data element created previous as component type, make sure the component name also starts with “ZZ”.

6.3 Create Program

Since all the include of main program SAPMV60A is start with MV60AF, so we could create an individual program named ZMV60AF_CUST_HEAD to store all the processing code.

Go to repository browser to create screen 6001, make sure the screen type is set to “Subscreen”.

Go to the flow logic of screen 6001, write below PBO and PAI, then double click on PBO_6001, and create PBO Module within main program ZMV60AFZ_CUST_HEAD, write down your own code, and finally back to screen 6001 to click Layout to next step.

On the screen painter, press F6 to open diction/program fields window, put VBRK into Table/Field Name, then click Get from Dictionary, and select the field(s) which should display in the screen.

6.4 Screen Enhancement

From screen 6001 of main program SAPMV60A, double click on the CUST_HEAD_ACTIVATE to the FORM, press Shift+F4 to enhance.

Select the menu Edit–>Enhancement Operations–>Show Implicit Enhancement Options.

Right click on the line under FORM CUST_HEAD_ACTIVATE, and select Enhancement Operations–>Create Implementation, choose the enhancement mode as Declaration.

Create new enhancement implementation names ZGTI_SAPMV60A.

Here I will show two solutions to implement the enhancement, and recommended to choose solution B:

  • PERFORM … IN PROGRAM … IF FOUND
  • CALL BADI … (custom BADI)

 


SOLUTION A: PERFORM … IN PROGRAM … IF FOUND


Put own code into enhancement implementation, suggest using PERFORM … IN PROGRAM … IF FOUND, and all code of detail logic could be coding within program ZMV60AFZ_CUST_HEAD. WB2_IVGUI_LAYOUT_H->ACTIVATE_TAB_PAGE could be a reference.

For the rest three methods of BADI BADI_SD_CUST_HEAD, which is using with screen 6101, even we don’t use for this moment, recommended to enhance and reserve to change easily within program ZMV60AFZ_CUST_HEAD, all the enhancement implementation should use the same name ZGTI_SAPMV60A, so that we could use SE20 to check all the enhancement together.


SOLUTION B: CALL BADI … (custom BADI)


The better way is to create custom BADI, start with interface refer to IF_EX_BADI_SD_CUST_HEAD. Let’s go to SE24 to create ZIF_EX_BADI_SD_CUST_HEAD.

Set the methods and parameters the same as IF_EX_BADI_SD_CUST_HEAD, and then add one more parameter FTAB for ACTIVATE_TAB_PAGE to exporting tab caption, also add one more method CHECK_BADI_ACTIVATE to check if the standard BADI already activated.

When the interface ready, go to SE20 to create enhancement spot named ZES_GTI_SAPMV60A.

Within enhancement spot element definitions, we create BADI definition named ZBADI_SD_CUST_HEAD.

Assign interface ZIF_EX_BADI_SD_CUST_HEAD we created previously.

Uncheck the “Multiple Use” option.

Create BADI implementation named ZGTI_BADI_SD_CUST_HEAD, and fill in the implementing class ZCL_IM_GTI_BADI_SD_CUST_HEAD on the popup window.

Double click or through SE19 we display BADI implementation ZGTI_BADI_SD_CUST_HEAD.

Double click on the method to create method implementation

Assign aliases for implementation class ZCL_IM_GTI_BADI_SD_CUST_HEAD.

Put own code into related implementation method, don’t forget to check if standard BADI activated, and the method of standard BADI implementation WB2_IVGUI_LAYOUT_H could be a reference.

Finally, put own code into enhancement implementation into screen 6001 and 6101 of main program SAPMV60A, which can simply use CALL BADI.

6.5 Verification

Change billing document with VF02, and go to Header–>Additional Data, fill in related data and save, then check table VBRK, the additional data already stored there.

Display billing document with VF03, the additional data in custom tab is read only.

When we activated the “Global Trade Management” again, our custom tab will be replaced, not effect to the control of standard customizing.

7. Best Practice

Try not to put the detail logic DIRECTLY into enhancement implementation, create custom BADI would be a good choice, don’t forget to reserve enough parameters and should check the validity of the call, so that the possible effect will be minimized, and if we would like to change the logic of enhancement, it is easier to control them through SE20.

Solution A should not be a choice for production environment since FORMS is an obsolete ABAP statement.

8. Quotation

To report this post you need to login first.

1 Comment

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

Leave a Reply