Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
Hello and welcome to my blog post illustrating the steps to add Custom Fields from Purchase Order Header in FM Derivation Structure.

Introduction:

In one of my recent S4 HANA projects, I worked as an FM-BCS Consultant. I had the opportunity to write up ABAP statements relevant to my module. During the implementation, there was a scenario where I had to configure the FM derivation steps to call the target fields based on the PO Document Type.

Fields in FMDERIVE:

The Derivation Rule is the bridge (integration point) between FM and other modules such as FI/MM/SD/HCM & etc. The integration works with the concept of source and target fields.

SAP provides predefined source fields in the FMDERIVE structure for example GL Account, Cost Center, Material No. The source fields are used as an import parameters to derive the target fields, i.e. Commitment Items, Fund, Funds Center, Funded Program, Grant. The steps may include usage of Assignment, V-Lookups, Derivation Rules, Functional Modules.

Source fields that are not pre-defined in FMDERIVE, SAP provides the provision to include them in the existing structure via user exits and badis.

Note: The Functional Consultants can work with the ABAP consultants to write up the codes.

Steps to follow:

1 - Add the PO Document Type in Structure FMDERIVE via SE11

In order to bring the PO Document Type as a source field, we will add as a "Z" field in the additional fields for Handling MM.



After adding the field and activating the structure, you can see the Purchasing Document Type in FMDERIVE.



However just adding this source field will not be enough to call the target fields. Lets write up a logic to fill the field with the selection in the PO.

2 - Implement BADI: ME_PROCESS_PO_CUST in Method PROCESS_HEADER (SE18)

When FM is activated, the system checks for the require fields including Commitment Item, Funds Center and etc. If the fields are not populated, it raises an error message before saving the document.

Use the above badi and the method to fetch the PO document type from the entry screen. Take an example from the code that I have mentioned:
*Data Declaration
DATA: LS_MEPOHEADER TYPE MEPOHEADER, "Structure Table of PO Header
LV_BSART TYPE MEPOHEADER-BSART.

*Call PO Header Data Into the Local Table LT_MEPOHEADER
CALL METHOD IM_HEADER->GET_DATA
RECEIVING
RE_DATA = LS_MEPOHEADER.

*Export Variable PO Document Type to Memory
LV_BSART = LS_MEPOHEADER-BSART.

EXPORT ZPO_BSART FROM LV_BSART TO MEMORY ID 'ZPO_BSART'.

3 - Implement the FM Enhancement SAPLFMDT -> User Exit EXIT_SAPLFMDT_002 (CMOD)

Import the PO Document Type from the memory to the FM User Exit.
*Purchasing Document Type from PO from Memory
*********************************************************************
DATA: IM_ZPO_BSART TYPE MEPOHEADER-BSART.

IMPORT ZPO_BSART TO IM_ZPO_BSART FROM MEMORY ID 'ZPO_BSART'.

IF SY-SUBRC EQ 0.
WRITE: IM_ZPO_BSART.
ENDIF.

C_FMDERIVE-ZZBSART = IM_ZPO_BSART.

FREE MEMORY ID IM_ZPO_BSART.

*End Of Purchasing Document Type from PO from Memory
**********************************************************************

*Get PO Document Type from PO Header Table
**********************************************************************

IF C_FMDERIVE-ZZBSART IS INITIAL.
DATA: ZBSART TYPE EKKO-BSART.

SELECT SINGLE BSART FROM EKKO INTO ZBSART
WHERE EBELN = C_FMDERIVE-PO_NUMBER.

C_FMDERIVE-ZZBSART = ZBSART.

ENDIF.
*End Of Get PO Document Type from PO Header Table

4 - Create the derivation steps using the additional field to derive the target fields (FMDERIVE)

Conclusion

The above is just an example for reference purpose only. Similarly, you can use different BADIs and Methods for different processes.

Hope that my post adds value!

Regards,

Anss Shahid
2 Comments
Labels in this area