Ansicht
Dokumentation

MMPUR_ORDCONFRQIN_CU - BAdI: Prepare Custom Mapping for Conf. Data (Called Before Std Mapping)

MMPUR_ORDCONFRQIN_CU - BAdI: Prepare Custom Mapping for Conf. Data (Called Before Std Mapping)

ROGBILLS - Synchronize billing plans   BAL Application Log Documentation  
This documentation is copyright by SAP AG.
SAP E-Book

The API Order Confirmation – Receive (OrderConfirmationRequest_In)enables you to receive order confirmations from an external supplier system in your SAP S/4HANA buyer system. The supplier confirms the goods or services, their pricing and the delivery schedule. This message can be generated by a sales order in the supplier SAP system, which in turn triggers a message through this web service, confirming the purchase order. Upon receipt of this message, the order confirmation is generated in the SAP S/4HANA system.

By default, the values for the parameters (supported by this API) are assigned through a fixed mapping, this is called as the standard mapping. Standard mapping is the mapping that allows to bring the purchase order data in the XML message structure. You can use this BAdI to perform and define custom mapping. With this custom mapping you can fill data as required in the xml message structure of the API. You can also decide with help of this BAdI if standard mapping should be executed or not. This BAdI can also be used to raise information messages (errors or warnings). Also, you can choose not to update the purchase order confirmation after execution of the custom mapping.

Note:

  • Using this BAdI, you can only fill data for the fields that are supported in the API OrderConfirmationRequest_In. Refer documentation for the API to know the list of the supported fields.
  • This BAdI is an on-premise BAdI, it cannot be implemented using the app Custom Fields and Logic.

To create a BAdI implementation, use the transaction SE18 or SE19.

Parameters

Importing Parameters

IV_IS_RETURN_ORDER: Shows type of purchase order. If this parameter is marked as X, it means the order is a return order. If this parameter is blank, it means order is a standard purchase order.

Changing Parameters

CS_INBOUND_MESSAGE: Contains ABAP structure of the incoming XML message. Use this parameter to fill values of the attributes in the XML message.

CT_MESSAGES: Use this parameter to raise information messages, see sample implementation below.

CV_PROCEED_WITH_APPL_PROC: Use this flag to execute the custom mapping. Set value of this flag as abap_false to skip the standard mapping and execute the custom mapping. If this flag is set as abap_true, then standard mapping is executed after the cust mapping. By default, this value is abap_true.

CV_SKIP_STMAP_AND_CALL_APPL_IF: Use this parameter to skip the standard mapping and to skip the call to the API. Set value of this parameter to abap_true (by default this value is abap_false) to skip sending the standard mapping and skip the API call, see sample implementation below. If you set value for this flag as abap_false in order to stop the execution of standard mapping, then ensure to map all the fields in custom mapping that are in the standard message structure.

Note:

If you do not want to create a custom mapping for this BAdI, but just enhance or update the standard mapping then use the BAdI: Modify Standard Mapping for Conf. Data (Called After Std Mapping). You can also further process the data that is returned by the API and generate information messages using the BAdI: Execute Post Processing After Posting Confirmation.

  METHOD if_mmpur_ordconfrqin_cust_map~custom_mapping.
*Below is the sample example for custom mapping
*You can modify fields in CS_INBOUND_MESSAGE structure to map data according to the buisness use case.
*If CV_PROCEED_WITH_APPL_PROC is true and CV_SKIP_STDMAP_AND_APPL_IF is false,
*the standard processing logic (standard mapping and call application interface) shall be executed
*If CV_PROCEED_WITH_APPL_PROC is true and CV_SKIP_STMAP_AND_CALL_APPL_IF is also true, Standard mapping shall not be executed and
*BAdi implementation shall call application interface directly to update PO confirmations.

    DATA: ls_bapimeconf_header  TYPE bapimeconfheader,
          ls_bapimeconf_headerx TYPE bapimeconfheaderx,
          lt_bapimeconf_item    TYPE TABLE OF bapimeconfitem,
          lt_bapimeconf_itemx   TYPE TABLE OF bapimeconfitemx,
          lt_bapimeconf_detail  TYPE TABLE OF bapimeconfdetail,
          lt_bapimeconf_detailx TYPE TABLE OF bapimeconfdetailx.

*Custom Mapping
* Update date by 2 days
    cs_inbound_message-order_confirmation-item[ 1 ]-schedule_line[ 1 ]-confirmed_delivery_date =  cs_inbound_message-order_confirmation-item[ 1 ]-schedule_line[ 1 ]-confirmed_delivery_date + 2.
*    Update Confirm Quantity by 2 quantity
    cs_inbound_message-order_confirmation-item[ 1 ]-schedule_line[ 1 ]-confirmed_order_quantity_by_ma-content =  cs_inbound_message-order_confirmation-item[ 1 ]-schedule_line[ 1 ]-confirmed_order_quantity_by_ma-content + 2.

    DATA(lv_ebeln) = CONV ebeln( cs_inbound_message-order_confirmation-purchase_order_id ).

* For authorization check
*    APPEND VALUE #( id = 'ME'
*                number = '303'
*                type   = 'A'
*                message_v1 = 'You are not authorized to change the PO.') TO ct_messages.

    ls_bapimeconf_header = VALUE #( doc_number = lv_ebeln
                                    doc_type = 'F'
                                    vendor = '0010300080' ).

    ls_bapimeconf_headerx = VALUE #( doc_number = 'X'
                                     doc_type = 'X'
                                     vendor = 'X' ).

    APPEND VALUE #( iTEM_NO = '00010'
                    quantity = '10.0'
                    po_unit = 'ST'
                    po_unit_iso = 'PCE'
                    price_unit = 0
                    net_price = '2.0' ) TO lt_bapimeconf_item.

    APPEND VALUE #( iTEM_NO = '00010'
                    iTEM_NOX = 'X'
                    quantity = 'X'
                    po_unit = 'X'
                    po_unit_iso = 'X'
                    price_unit = 'X'
                    net_price = 'X' ) TO lt_bapimeconf_itemx.

    APPEND VALUE #( iTEM_NO = '00010'
                    conf_category = 'AB'
                    deliv_date = '20201014'
                    deliv_time = '020000'
                    quantity = '10.0'
                    msgtstmp = '20201014134759.0000000' ) TO lt_bapimeconf_detail.

    APPEND VALUE #( iTEM_NO = '00010'
                    iTEM_NOX = 'X'
                    conf_category = 'X'
                    deliv_date_TYP = 'X'
                    deliv_date = 'X'
                    deliv_time = 'X'
                    reference = 'X'
                    quantity = 'X'
                    msgtstmp = 'X' ) TO lt_bapimeconf_detailx.


* call for updating the PO
*    CALL FUNCTION 'ME_PO_CONFIRM'
*      EXPORTING
*        document_no   = lv_ebeln
*        header        = ls_bapimeconf_header
*        headerx       = ls_bapimeconf_headerx
*        item          = lt_bapimeconf_item
*        itemx         = lt_bapimeconf_itemx
*        confirmation  = lt_bapimeconf_detail
*        confirmationx = lt_bapimeconf_detailx
*      IMPORTING
*        return        = ct_messages.

    APPEND VALUE #( id = 'ME'
                number = '303'
                type   = 'W'
                message_v1 = 'Warning Message test from BADI 1') TO ct_messages.

* change as per the scenario
    cv_proceed_with_appl_proc = abap_true.
    cv_skip_stmap_and_call_appl_if = abap_false.

  ENDMETHOD.






CL_GUI_FRONTEND_SERVICES - Frontend Services   ABAP Short Reference  
This documentation is copyright by SAP AG.

Length: 13380 Date: 20240523 Time: 213109     sap01-206 ( 119 ms )