In SAP S/4HANA Public Cloud, the S/4 Output Management is used to manage output items of sales order. It is possible to define business rules in Output Parameter Determination to control how output items are processed. See detail in blog. This blog shows an example how to embed custom fields in Output Parameter Determination to control sales order output items.
Selling company ABC has a complex MRP process to confirm the delivery date on sales order. From customer order is placed to final order confirmation, MRP will be triggered multiple times before the confirmed delivery date is stable. Therefore, selling company ABC only wants to inform customer 7 days before requested delivery date because normally the confirmed delivery date is more reliable.
In order to achieve this business purpose, we could include confirmed delivery date information as criteria to control output items. This blog shows detail of implementation.
Create following custom fields on sales document header and sales document item to capture confirmation date and indicator of order confirmation.
Custom Fields
Because the schedule line data is only available in Cloud BAdI “SD_SLS_MODIFY_ITEM”, the custom fields need to be determined firstly in sales order item level.
Implement the Cloud BAdI “SD_SLS_MODIFY_ITEM” to update custom fields on sales order item. The basic logic is to check schedule line items and update confirmed schedule line date on custom fields of sales order item.
If confirmed delivery date is within 7 days, set the indicator to “X” which means the output item shall be processed. Here is code example.
* update custom field for confirmed delivery date
data(lv_current_date) = cl_abap_context_info=>get_system_date( ).
if salesdocument-salesdocumenttype = 'TA' and
salesdocumentitem-salesdocumentitemcategory = 'CBAO'.
* set output indicator to space
salesdocumentitem_extension_o-yy1_confoutcheckbox_i_sdi = ' '.
* read schedule line to check confirmed date
loop at salesdocumentschedulelines into data(ls_schedule_line).
salesdocumentitem_extension_o-yy1_confoutdate_i_sdi = ls_schedule_line-confirmeddeliverydate.
if ls_schedule_line-confirmeddeliverydate is not initial.
* check if confirmed delivery date is within 7 days, if yes, issue the output email, otherwise, do not trigger output item
if ls_schedule_line-confirmeddeliverydate - lv_current_date <= 7.
salesdocumentitem_extension_o-yy1_confoutcheckbox_i_sdi = 'X'.
exit.
endif.
endif.
endloop.
endif.
Then implement Cloud BAdI “SD_SLS_MODIFY_HEAD” to update custom fields of sales order header. The custom fields of sales order item are copied to relevant custom fields of sales order header. Here is code example.
* Set the committed delivery date of first line item into custom field
if salesdocument-salesdocumenttype = 'TA'.
salesdocument_extension_out-yy1_confoutcheckbox_h_sdh = ' '.
* Pass custom fields from sales order item to sales order header
loop at salesdocumentitems_extension into data(ls_item_ext).
if ls_item_ext-yy1_confoutdate_i_sdi is not initial.
salesdocument_extension_out-yy1_confoutdate_h_sdh = ls_item_ext-yy1_confoutdate_i_sdi.
if ls_item_ext-yy1_confoutcheckbox_i_sdi is not initial.
salesdocument_extension_out-yy1_confoutcheckbox_h_sdh = 'X'.
exit.
endif.
endif.
endloop.
endif.
In order to use custom fields to control output items, go to app “Output Parameter Determination” to add custom field “ConfOutCheckbox_H” in determination step “Output Relevance” for sales document.
Output Parameter Determination
Activate the output parameter determination setting.
Create a sales order. Set the requested delivery date to 12/01/2024 which is 14 days from current day (current date is 29/12/2023).
Create Sales Order – Initial
Directly save the sales order, and display the created sales order to check schedule line data.
Schedule Line Out of 7 Days
Then check the custom fields on sales order item and sales order header.
Custom Fields on Sales Order Item
Because the confirmed delivery date is beyond 7 days, the checkbox is still initial.
Custom Fields on Sales Order Header
These sales order header custom fields are copied from sales order item.
Go to output tab and the output items are still in “In Preparation” based on OPD determination rule.
Output Items are In Preparation
Update the sales order and change the requested delivery date on item to today (29/12/2023)
Update Requested Delivery Date
Save the sales order.
Then open the sales order to check the schedule line confirmed date.
Schedule Line with New Confirmed Date
Go to custom fields tabs on sales order item and header.
Confirmed Delivery Date is Within 7 Days
The confirmed delivery date is 05/01/2024 which is the 7th day from today. According to custom logic, the order confirmation indicator is checked.
Custom Fields on Sales Order Header
The custom fields of sales order header are updated from sales order item.
Finally, go to output tab to check if output items are processed.
Output Items Are Completed
The output items are processed correctly according to OPD setting.
It is a good example to show extensibility option on both S/4 output management feature and sales order process. There are two Cloud BAdIs implemented to determine the order confirmation indicator. Because it is not possible to access schedule line data from BAdI “SD_SLS_MODIFY_HEAD”, I need to firstly implement the BAdI “SD_SLS_MODIFY_ITEM” to determine the custom fields and then pass those custom fields to header level extension fields.