DELIVERY_FINAL_CHECK

<< Click to Display Table of Contents >>

Navigation:  All About ABAP Technique > English > ABAP Tutorial > ABAP Workbench Tools > Enhancement > Business Add-Ins (BADI) > Business Add-Ins (BADI) Examples > ZSHP_DELIVERY_PROC >

DELIVERY_FINAL_CHECK

method IF_EX_LE_SHP_DELIVERY_PROC~DELIVERY_FINAL_CHECK .
**
*Prevent inbound delivery created for PO with final delivery
*Check if material, vendor and plant are within source inspection,
* and provide warning if not packed
**
data: dlv_comp type c,
       ls_finchdel     type finchdel.
data: zekpo type ekpo.
data: zqinf type qinf.
data: zmsg(70) type c.
 
field-symbols: <ls_xlikp> type likpvb,
                <ls_xlips> type lipsvb,
                <ls_xvbup> type vbupvb.
 
* Loop at all created inbound deliveries
loop at it_xlikp assigning <ls_xlikp> where updkz ne 'D'
                                          and LFART eq 'EL'
                                          or LFART eq 'ZEL'.
  clear: dlv_comp.
 
*   Check delivery quantity of all items belonging to current delivery
  loop at it_xlips assigning <ls_xlips>
                    where vbeln eq <ls_xlikp>-vbeln
                      and updkz ne 'D'.
    select * from ekpo into zekpo where
                        EBELN = <ls_xlips>-VGBEL and
                        EBELP = <ls_xlips>-VGPOS and
                        ELIKZ = 'X'.
    endselect.
    if sy-subrc = 0.
       dlv_comp = 'X'.
    endif.
 
    if dlv_comp eq 'X'.
*     Some items of the delivery have PO status deliv comp
*     Write message with type E to error log
*     (forces deletion of the delivery or prevents delivery from saving)
      clear ls_finchdel.
       ls_finchdel-vbeln    = <ls_xlikp>-vbeln.
       ls_finchdel-pruefung = '99'.
       ls_finchdel-msgty    = 'E'.
       ls_finchdel-msgid    = 'ME'.
       ls_finchdel-MSGV1    = <ls_xlips>-VGBEL.
       ls_finchdel-MSGV2    = <ls_xlips>-VGPOS.
       ls_finchdel-msgno    = '632'.
*     Note: CT_FINCHDEL is a hashed table
      insert ls_finchdel into table ct_finchdel.
    endif.
 
*Check if source inspection, give warning if packing status not complete
    select * from QINF into zqinf where
                   MATNR = <ls_xlips>-MATNR and
                   WERK = <ls_xlips>-WERKS and
                   LIEFERANT = <ls_xlikp>-LIFNR and
                   VARIABNAHM <> '' and
                   LOEKZ = ' '.
    endselect.
    if sy-subrc = 0.
      loop at it_xvbup assigning <ls_xvbup> where
                        vbeln = <ls_xlips>-VBELN and
                        posnr = <ls_xlips>-POSNR.
        if <ls_xvbup>-PKSTA <> 'C'.
*     Send warning if not packed
          concatenate 'Item' <ls_xlips>-VGPOS into zmsg
                              separated by space.
          concatenate zmsg
          'relevant to Handling Unit. Pls check !'
          into zmsg separated by space.
 
          clear ls_finchdel.
           ls_finchdel-vbeln    = <ls_xlikp>-vbeln.
           ls_finchdel-pruefung = '99'.
           ls_finchdel-msgty    = 'W'.
           ls_finchdel-msgid    = 'VL'.
*            ls_finchdel-msgno    = '615'.
           ls_finchdel-msgno    = '001'.
           ls_finchdel-MSGV1    = zmsg.
*     Note: CT_FINCHDEL is a hashed table
          insert ls_finchdel into table ct_finchdel.
 
        endif.
 
      endloop.
    endif.
*
****  Check SLOC for Inbound Delivery (PO Based)
      IF <ls_xlips>-KZBEW = 'B' and  <ls_xlips>-lgort is initial.
        MESSAGE E604(VL) WITH <ls_xlips>-posnr.
*   The storage location is not defined for delivery item &
      ENDIF.
 
  endloop.         "loop at it_xlips
 
endloop.           "loop at it_xlikp
 
endmethod.