Symptom
A custom field has been created to be printed on the PO output form. During the creation of the purchase order it is observed that the custom field is empty
when using the print preview. However, after the purchase order has been saved and a change is made the custom field appears as expected on the print preview.
One or more of the following BADIs is coded to fill the custom field:
MM_PUR_S4_PO_MODIFY_HEADER, MM_PUR_S4_PO_MODIFY_ITEM, MMPUR_PO_OUTPUT_HEADER_EXT and/or MMPUR_PO_OUTPUT_ITEM_EXT.
Environment
SAP S/4HANA Cloud Public Edition
Reproducing the Issue
1) Create a Purchase Order via the 'Create Purchase Order - Advance' APP (ME21n)
2) Issue the print preview during creation - The custom field is empty
3) Save the purchase order
4) access the new purchase order in change mode and make a small change - The custom field is filled
Cause
- The issue occurs due to the current system design.
- The BAdIs MMPUR_PO_OUTPUT_HEADER_EXT and MMPUR_PO_OUTPUT_ITEM_EXT are not initiated during the output preview in the Manage Purchase Orders and Create Purchase Order - Advanced applications, except in specific use cases.
- These BAdIs are designed to fetch saved details or hardcoded values provided in their implementation when the Output Preview button is clicked in the Manage Purchase Orders application while in display mode.
Resolution
As per the current design, the BAdIs MMPUR_PO_OUTPUT_HEADER_EXT and MMPUR_PO_OUTPUT_ITEM_EXT are not triggered during the output preview in the Manage Purchase Orders and Create Purchase Order - Advanced applications, except in the following use case:
- The BADI is triggered when the Output Preview button is clicked in the Manage Purchase Orders application while in display mode (not in edit mode). In this scenario, the BADI fetches either already saved details or hardcoded values provided in the BADI implementation.
- Note that this workaround applies only to Purchase Orders that can be opened in the Manage Purchase Orders app. For more information on which Purchase Orders can be opened and which cannot, please refer to this KBA 2372209 - Purchase order opens in the Display Purchase Order - Advanced (ME23N) app .
As per the design, the BAdI's MMPUR_PO_OUTPUT_HEADER_EXT and MMPUR_PO_OUTPUT_ITEM_EXT are intended to be used to fill the custom field value that is meant to be displayed only in the PDF of Print and Email channels. To update the custom field in any other area, such as email templates or applications, the value of the custom field needs to be updated with other BAdIs, such as MM_PUR_S4_PO_MODIFY_HEADER and MM_PUR_S4_PO_MODIFY_ITEM.
Notes* The BADI's MM_PUR_S4_PO_MODIFY_HEADER and MM_PUR_S4_PO_MODIFY_ITEM are called during the application processing, BEFORE the PO is saved on the database
selecting data from the database here will not work during create because the document is not saved when the PO is being created. In change mode it exists and will be successful
with the old unchanged data. These BADI's can be used to actually fill custom fields in the database tables of the purchase order header and item.
BAdIs MMPUR_PO_OUTPUT_HEADER_EXT and MMPUR_PO_OUTPUT_ITEM_EXTare called during the update task after the purchase order has been saved. With these BADI's you can select from the
database using the purchase order as the key, because the PO has already been saved when these are called. Custom fields can be determined for the print form in this way.
important to note, the field value is provided for the form data ONLY, it does not fill the custom field in the database tables of the purchase order header and item.
See Also
KBA 2372209 - Purchase order opens in the Display Purchase Order - Advanced (ME23N) app - SAP S/4HANA
Keywords
MMPUR_PO_OUTPUT_HEADER_EXT, MMPUR_PO_OUTPUT_ITEM_EXT, Output, Preview, Print Preview , KBA , MM-FIO-PUR-PO-OM-2CL , Purchase Order Output Management (Public Cloud) , Problem
SAP Knowledge Base Article - Public