How to update Standard fields of Purchase Order using User Exit MM06E005
In Purchasing, you normally use User Exit MM06E005 to update customer fields but in this post, i will show you how to update standard fields of Purchase Order or in Scheduling Agreement. We use small trick to update variables out side the EXIT, in the main program.
You do need to follow these steps below to achieve it:
- Create a project to use the User Exit (Tcode CMOD)
- Activate the Components
- Write the code (in ZXM06U41)
Here i will give you a small example, which will update the Firm Zone field in Scheduling Agreement.
The system uses “Firm zone” as a key field to determine which item vendor can ship. If delivery date falls within Firm zone, the line item is treated as firm requirement, and vendor can only create ASN
for line item that marked as “Firm”. The firm zone should be relevant to JIT date range, which is determined by creation profile.
However, in S/4HANA there is no standard function to link between
firm zone and creation profile. Therefore we need to use User Exit MM06E005 to update. Here i choose EXIT EXIT_SAPMM06E_016 (Export Data to Customer Subscreen for Purchasing Document Item (PBO)) to use.
Step by step:
- Use Tcode CMOD to create a project.
2. Activate the components (and create the subscreens)
3. Implement the code
We use the below trick to edit value in main program.
ASSIGN ('(SAPMM06E)EKPO') TO <LF_EKPO>.
Here is complete code
DATA: LS_EKPO TYPE EKPO, LW_FABHO TYPE FABHO, LW_FABHO_DIV TYPE P LENGTH 3 DECIMALS 2, LW_FABHO_ROUND TYPE ETFZ1. FIELD-SYMBOLS: <LF_EKPO> TYPE EKPO. CHECK SY-TCODE = 'ME31' OR SY-TCODE = 'ME31L'. ASSIGN ('(SAPMM06E)EKPO') TO <LF_EKPO>. LS_EKPO = <LF_EKPO>. * IF LS_EKPO-ETFZ1 IS INITIAL. SELECT SINGLE FABHO INTO LW_FABHO FROM T163P WHERE ABUEB = LS_EKPO-ABUEB. IF SY-SUBRC = 0. LW_FABHO_DIV = LW_FABHO / 6. LW_FABHO_ROUND = ROUND( VAL = LW_FABHO_DIV DEC = 0 MODE = 2 ). LS_EKPO-ETFZ1 = LW_FABHO + LW_FABHO_ROUND. <LF_EKPO> = LS_EKPO. ENDIF. ENDIF.
Tcode ME32L, change Scheduling Agreement (additional data)
Firmzone value has been changed
Hope you see this post is helpful. If you have any question, please leave your comment. Thank you.