Tuesday 19 September 2017

Adding custom tab to billing document Part - 1

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.

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

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”.

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

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.

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

5. Reason and Prerequisites


5.1 Reference


SAP Note 864944 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.

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

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

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

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.

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

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

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

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.

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

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

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

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.

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

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.

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

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 TWGTA–WB2_ADDON_ACTIVE.

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

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”.

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

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

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

Try to set it as “Inactive”.

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

Then the “Global Trade Management” tab disappears.

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

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.

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

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

SAP ABAP Development, SAP ABAP Tutorials and Materials, SAP ABAP Certifications, SAP ABAP Guides

No comments:

Post a Comment