Skip to end of metadata
Go to start of metadata

You can only cancel the ASN if the ASN does not yet have the status Goods ReceiptPartial Goods Receipt, orClosed. This means that the customer has not posted a goods receipt for the ASN, or closed the ASN yet.

 

To send a cancellation ASN from SAP SNC to the SAP back-end system of the customer, you must do the following:

  • You have to define a content-based mapping in SAP NetWeaver PI that, upon action code 03, maps theDespatchedDeliveryNotification message to the WHSCON.DELVRY03 IDoc. To do this, you can use the DespatchedDeliveryActionCode context object.

  • SAP SNC does not know the delivery number in the SAP back-end system. For the SAP back-end system to be able to process the cancellation ASN, you therefore have to implement the /SPE/BADI_IBDLV_CONTROL Business Add-In (BAdI) in the IDoc inbound processing of the SAP back-end system.

     You need to use the /SPE/IDOC_INPUT_DESADV1 function module for processing the inbound Idoc, and implement the /SPE/BADI_IBDLV_CONTROLBAdI. The BAdI should determine the inbound delivery number in the SAP back-end system from the SAP SNC delivery number and from the supplier, and write it to the IDoc.

You can use the following implementation for the BAdI:

  METHOD /spe/if_badi_ibdlv_control~process_idoc_delvry03.

 

    DATA: ls_e1edl18            TYPE e1edl18,

          ls_e1edl20            TYPE e1edl20,

          lv_vbeln              TYPE vbeln,

          ls_e1edl44            TYPE e1edl44,

          ls_e1edl24            TYPE e1edl24.

 

    FIELD-SYMBOLS:

                   <ls_edidd>   TYPE edidd,

                   <ls_edidd2>  TYPE edidd,

                   <ls_e1edl20> TYPE e1edl20.

* Copy batch number from item level to handling unit

    LOOP AT idoc_data ASSIGNING <ls_edidd> WHERE segnam = 'E1EDL44'.

      ls_e1edl44 = <ls_edidd>-sdata.

      LOOP AT idoc_data ASSIGNING <ls_edidd2> WHERE segnam = 'E1EDL24'.

        ls_e1edl24 = <ls_edidd2>-sdata.

        IF ls_e1edl44-posnr = ls_e1edl24-posnr.

          ls_e1edl44-charg = ls_e1edl24-charg.

          <ls_edidd>-sdata = ls_e1edl44.

          EXIT.

        ENDIF.

      ENDLOOP.

    ENDLOOP.

* Need to fill inbound delivery number only for replacement on cancellation ASN

    READ TABLE idoc_data ASSIGNING <ls_edidd> WITH KEY segnam = 'E1EDL18'.

    CHECK sy-subrc = 0.

    ls_e1edl18 = <ls_edidd>-sdata.

    CHECK ls_e1edl18-qualf = 'REP' OR

          ls_e1edl18-qualf = 'DEL'.

* Get IDoc header with LIFEX and PARID

    READ TABLE idoc_data ASSIGNING <ls_edidd> WITH KEY segnam = 'E1EDL20'.

    IF sy-subrc = 0.

      ls_e1edl20 = <ls_edidd>-sdata.

* Get inbound delivery number

      SELECT SINGLE vbeln FROM likp INTO lv_vbeln WHERE lifex = ls_e1edl20-lifex AND

        lifnr = ls_e1edl20-parid.

      IF sy-subrc = 0.

        ls_e1edl20-vbeln = lv_vbeln.

        <ls_edidd>-sdata = ls_e1edl20.

      ENDIF.

    ENDIF.

  ENDMETHOD.