SAP PGI BAPI

The Code will help you do the PGI(Post Good Issue) from Delivery.

BAPI to post PGI

DATA : l_vbkok TYPE vbkok,
i_vbkok TYPE STANDARD TABLE OF vbkok,
i_lips TYPE lips,
l_verko TYPE verko,
i_verko TYPE TABLE OF verko,
it_lips TYPE TABLE OF lips WITH HEADER LINE,
i_vbpok TYPE vbpok,
it_vbpok TYPE TABLE OF vbpok,
dono TYPE lips-vbeln VALUE ‘0080000087’.

l_vbkok-vbtyp_vl = ‘J’.
l_vbkok-vbeln = l_vbkok-vbeln_vl = dono. “do number
l_vbkok-wabuc = ‘X’. “automatically PGI selection
APPEND l_vbkok TO i_vbkok.

l_verko-object = ’01’.
l_verko-objkey = dono.
APPEND: l_verko TO i_verko.

REFRESH it_lips.

SELECT * FROM lips
INTO TABLE it_lips
WHERE vbeln = dono.” AND charg NE ”.

CLEAR i_vbpok.

LOOP AT it_lips INTO i_lips.
*move-corresponding i_lips to i_vbpok.
i_vbpok-vbeln_vl = i_lips-vbeln.”Delivery
i_vbpok-posnr_vl = i_lips-posnr.”Delivery Item
i_vbpok-posnn = i_lips-posnr.”Delivery Item
i_vbpok-vbeln = i_lips-vbeln.”Pick Order
i_vbpok-vbtyp_n = ‘Q’.
i_vbpok-pikmg = i_lips-lfimg.
i_vbpok-meins = i_lips-meins.
*
**i_VBPOK-NDIFM = 0.
*i_VBPOK-TAQUI = ‘ ‘.
i_vbpok-charg = i_lips-charg.
i_vbpok-matnr = i_lips-matnr.
i_vbpok-werks = i_lips-werks.
APPEND i_vbpok TO it_vbpok.
ENDLOOP.
BREAK tcs_namit.
CALL FUNCTION ‘WS_DELIVERY_UPDATE_2’
EXPORTING
vbkok_wa = l_vbkok
synchron = ”
no_messages_update_1 = ‘ ‘
commit = ‘X’
delivery = dono
update_picking = ‘X’
nicht_sperren_1 = ‘X’
TABLES
vbpok_tab = it_vbpok
verko_tab = i_verko.
IF sy-subrc = 0.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’ ” call FM to
EXPORTING
wait = ‘X’.
ENDIF.

Leave a Reply

Your email address will not be published. Required fields are marked *