on ‎2025 Jan 13 5:00 AM
Dear experts,
I have a request to add Sales Order from Account Assignment of Purchase Requisition Items to the screen Process Purchase Requisition (V2).
I have created a custom field named YY1_SALESORDERPURRQ with business context Procurement: Purchase Requisition Item, then I created custom logic using extension point Change of Purchase Requisition Item.
May I ask if there is any problem with my code in custom logic because it doesn't do anything at all.
IF purchaserequisitionitem-YY1_SALESORDERIDEXTPRQ_PRI IS INITIAL AND
purchaserequisitionitem-YY1_SALESORDERPURRQ_PRI IS INITIAL.
LOOP AT PURCHASEREQACCASSGNMT_TABLE INTO DATA(prqaccountassgnmt).
IF prqaccountassgnmt-SALESDOCUMENT IS NOT INITIAL.
purchaserequisitionitemchange-YY1_SALESORDERPURRQ_PRI = prqaccountassgnmt-SALESDOCUMENT.
ENDIF.
ENDLOOP.
ENDIF.
Request clarification before answering.
Hello @lamtq
Your approach is correct; the issue is typically related to enablement/publishing or writing to an incorrect structure. Follow these steps:
Enable the field for the app and publish
In Custom Fields & Logic, navigate to YY1_SALESORDERPURRQ Business Context: Procurement: Purchase Requisition Item.
Tick UIs & Reports (include Process Purchase Requisitions – V2) and Publish. Then Adapt UI in the app to place the field. SAP Help Portal-App Extensibility: Process Purchase Requisitions
Implement the appropriate BAdI and record it in the change structure.
Use BAdI: Change of Purchase Requisition Item (MM_PUR_S4_PR_MODIFY_ITEM).
Fill PurchaseRequisitionItemChange-YY1_SALESORDERPURRQ from PURCHASEREQACCASSGNMT_TABLE. Exit after the first hit.
IF purchase requisition item change-yy1_salesorderpurrq IS INITIAL.
LOOP AT purchasereqaccassgnmt_table INTO DATA(acc)
WHERE salesdocument IS NOT INITIAL.
"Optional: restrict to account assignment 'E' (Sales Order)
IF acc-accountassignmentcategory = 'E'.
purchaserequisitionitemchange-yy1_salesorderpurrq = acc-salesdocument.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
Test correctly
Activate the implementation and create a new PR item with account assignment linked to a Sales Document; note that the BAdI does not retroactively populate existing PRs.
Check, SAP API Hub: BAdI MM_PUR_S4_PR_MODIFY_ITEM – Change of Purchase Requisition Item. Business Accelerator Hub-Change of Purchase Requisition Item
Best regards,
Chuma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @lamtq ,
The code seems to be good. Be sure that this code will only work if YY1_SALESORDERIDEXTPRQ_PRI and YY1_SALESORDERPURRQ_PRI are blank and PURCHASEREQACCASSGNMT_TABLE has account assignment data which will only vallues if account assignment values are filled by user on the Purchase requisition screen.
Note: Since YY1_SALESORDERPURRQ_PRI is new custom field it will always be blank if its not visible on UI.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 7 | |
| 7 | |
| 7 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.