Process Sales Order Output Items by Confirmed Delivery Date
2023-12-29 18:13:14 Author: blogs.sap.com(查看原文) 阅读量:53 收藏

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.

Custom Custom Fields

Create following custom fields on sales document header and sales document item to capture confirmation date and indicator of order confirmation.

  • ConfOutCheckBox_H: it is an indicator on sales order header to control order confirmation output items.
  • ConfOutCheckBox_I: it is an indicator on sales order item. This field is determined by confirmation date on schedule lines.
  • ConfOutDate_H: capture the first confirmed delivery date on sales order header.
  • ConfOutDate_I: capture the first confirmed delivery date of schedule line and persist on sales order item.

Custom%20Fields

Custom Fields

Cloud BAdI Implementation

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.

Output Parameter Determination Setting

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%20Parameter%20Determination

Output Parameter Determination

Activate the output parameter determination setting.

Confirmed Delivery Date is Out of 7 Days

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%20Sales%20Order%20-%20Initial

Create Sales Order – Initial

Directly save the sales order, and display the created sales order to check schedule line data.

Schedule%20Line%20Out%20of%207%20Days

Schedule Line Out of 7 Days

Then check the custom fields on sales order item and sales order header.

Custom%20Fields%20on%20Sales%20Order%20Item

Custom Fields on Sales Order Item

Because the confirmed delivery date is beyond 7 days, the checkbox is still initial.

Custom%20Fields%20on%20Sales%20Order%20Header

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%20Items%20are%20In%20Preparation

Output Items are In Preparation

Confirmed Delivery Date is Within 7 Days

Update the sales order and change the requested delivery date on item to today (29/12/2023)

Update%20Requested%20Delivery%20Date

Update Requested Delivery Date

Save the sales order.

Then open the sales order to check the schedule line confirmed date.

Schedule%20Line%20with%20New%20Confirmed%20Date

Schedule Line with New Confirmed Date

Go to custom fields tabs on sales order item and header.

Confirmed%20Delivery%20Date%20is%20Within%207%20Days

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%20Fields%20on%20Sales%20Order%20Header

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%20Items%20Are%20Completed

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.


文章来源: https://blogs.sap.com/2023/12/29/process-sales-order-output-items-by-confirmed-delivery-date/
如有侵权请联系:admin#unsafe.sh