Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

PGI with WS_DELIVERY_UPDATE- Goods Movement doc status set to 'Archived'

Former Member

Hi experts,

I have a report in which I am trying to do PGI for an outbound delivery. The PGI is successful but the Goods movement document created by PGI is being archived immediately. It should not be archived. Is there any parameter that I need to change or use a different FM for PGI?

The code looks like this

  • carry out goods issue

LOOP AT it_likp INTO likp_wa.

CLEAR lv_error.

l_vbkok-vbeln_vl = likp_wa-vbeln.

l_vbkok-wabuc = 'X'. u201Cvariable to set Post good issue automatically

CLEAR lv_pgi.

CALL FUNCTION 'WS_DELIVERY_UPDATE'

EXPORTING

vbkok_wa = l_vbkok

synchron = 'X'

no_messages_update = ' '

update_picking = 'X'

commit = ' '

delivery = likp_wa-vbeln

nicht_sperren = 'X'

IMPORTING

ef_error_in_goods_issue_0 = lv_pgi

TABLES

prot = l_prott

EXCEPTIONS

OTHERS = 0.

IF sy-subrc <> 0 OR lv_pgi EQ 'X'.

lv_error = 'X'.

ENDIF.

ENDLOOP.

Thanks for your help in advance.

Nalini.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Satya,

Can you please give me details of data passed in below input parameters

structure: ls_vbkok

tables : lt_vbpok, lt_prot, lt_verk, lt_verpo, lt_vbsupcon

Currently I am passing

delivery number,

'Post good issue automatically' flag

and PGI date

in structure ls_vbkok.

Thanks,

Nalini.

9 REPLIES 9

Former Member
0 Kudos

HI,

Pass the Actual Goods Movement Date to this field L_VBKOK-WADAT_IST = SY-DATUM "

0 Kudos

Hi Avinash,

Thank you for your quick reply. I have added the parameter. But the status is still set to 'Archived'. Please suggest.

Thanks,

Nalini.

Former Member
0 Kudos

Hi,

I have used the following code successfully, can you try?

CALL FUNCTION 'WS_DELIVERY_UPDATE'
  EXPORTING
    vbkok_wa                          = ls_vbkok
*   SYNCHRON                          = ' '
*   NO_MESSAGES_UPDATE                = ' '
*   COMMIT                            = ' '
    delivery                          = gv_delivery
    update_picking                    = 'X'
*   NICHT_SPERREN                     = ' '
*   IF_CONFIRM_CENTRAL                = ' '
*   IF_WMPP                           = ' '
*   IF_GET_DELIVERY_BUFFERED          = ' '
*   IF_NO_GENERIC_SYSTEM_SERVICE      = ' '
    if_database_update                = '1'
*   IF_NO_INIT                        = ' '
*   IF_NO_READ                        = ' '
    if_error_messages_send_0          = 'X'
*   IF_NO_BUFFER_REFRESH              = ' '
*   IF_NO_MES_UPD_PACK                = ' '
 IMPORTING
   ef_error_any_0                    = lv_err_anyerr
   ef_error_in_item_deletion_0       = lv_err_itmdel
   ef_error_in_pod_update_0          = lv_err_podupd
   ef_error_in_interface_0           = lv_err_interf
   ef_error_in_goods_issue_0         = lv_err_goodsi
   ef_error_in_final_check_0         = lv_err_finalc
 TABLES
   vbpok_tab                          = lt_vbpok
   prot                               = lt_prot
   verko_tab                          = lt_verko
   verpo_tab                          = lt_verpo
   vbsupcon_tab                       = lt_vbsupcon
*   IT_VERPO_SERNR                    =
*   IT_PACKING                        =
*   IT_PACKING_SERNR                  =
*   IT_REPACK                         =
*   IT_HANDLING_UNITS                 =
*   ET_CREATED_HUS                    =
*   TVPOD_TAB                         =
          .

Regards,

~Satya

Former Member
0 Kudos

Hi Satya,

Can you please give me details of data passed in below input parameters

structure: ls_vbkok

tables : lt_vbpok, lt_prot, lt_verk, lt_verpo, lt_vbsupcon

Currently I am passing

delivery number,

'Post good issue automatically' flag

and PGI date

in structure ls_vbkok.

Thanks,

Nalini.

0 Kudos

Hi,

Please check the below code,

*&---------------------------------------------------------------------*
*&      Form  do_PGI
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM do_pgi.
DATA: ls_vbkok    TYPE vbkok,
      lt_vbpok    LIKE vbpok  OCCURS 0  WITH HEADER LINE,
      lt_prot     LIKE prott  OCCURS 0  WITH HEADER LINE,
      lt_verko    LIKE verko  OCCURS 0  WITH HEADER LINE,
      lt_verpo    LIKE verpo  OCCURS 0  WITH HEADER LINE,
      lt_vbsupcon LIKE vbsupcon OCCURS 0  WITH HEADER LINE,

      lv_err_anyerr TYPE c,
      lv_err_itmdel TYPE c,
      lv_err_podupd TYPE c,
      lv_err_interf TYPE c,
      lv_err_goodsi TYPE c,
      lv_err_finalc TYPE c.
DATA:  lv_message(132) TYPE c,
       lt_lips LIKE lips OCCURS 0 WITH HEADER LINE,
       lv_vbeln LIKE vbfa-vbeln.

* Return parameter
DATA:  lt_return  LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
       ls_return1 TYPE bapireturn1.


*-Indicator - Creating GI Document
  gv_indtext = text-046. " Creating GI Document
  perform sapgui_indicator using gv_indtext.

*-Get all the line items from delivery
  SELECT *
       FROM lips
       INTO TABLE lt_lips
      WHERE vbeln = gv_delivery.

*-Populate required fields to perform PGI
* Assign Header Data
  ls_vbkok-vbeln_vl = gv_delivery.     " Delivery Number
  ls_vbkok-vbtyp_vl = 'J'.             " Delivery Type
  ls_vbkok-wabuc    = gc_x.            " Post good issue automatically
  ls_vbkok-komue    = gc_x.  "  update delivery qty with picking qty

* Detail
  LOOP AT lt_lips WHERE charg <> space.
    CLEAR lt_vbpok.
    lt_vbpok-vbeln_vl = lt_lips-vbeln. " Delivery No
    lt_vbpok-posnr_vl = lt_lips-posnr. " Delivery Item
    lt_vbpok-vbeln    = lt_lips-vgbel. " Sales order - Ref Doc
    lt_vbpok-posnn    = lt_lips-vgpos. " SO Line item - Ref doc item
    lt_vbpok-matnr    = lt_lips-matnr. " Material No
    lt_vbpok-werks    = lt_lips-werks. " Plant
    lt_vbpok-pikmg    = lt_lips-lfimg. " Delivery Qty

    APPEND lt_vbpok.
    CLEAR lt_vbpok.
  ENDLOOP.

*-Do Picking and PGI
  CALL FUNCTION 'WS_DELIVERY_UPDATE'
  EXPORTING
    vbkok_wa                          = ls_vbkok
*   SYNCHRON                          = ' '
*   NO_MESSAGES_UPDATE                = ' '
*   COMMIT                            = ' '
    delivery                          = gv_delivery
    update_picking                    = 'X'
*   NICHT_SPERREN                     = ' '
*   IF_CONFIRM_CENTRAL                = ' '
*   IF_WMPP                           = ' '
*   IF_GET_DELIVERY_BUFFERED          = ' '
*   IF_NO_GENERIC_SYSTEM_SERVICE      = ' '
    if_database_update                = '1'
*   IF_NO_INIT                        = ' '
*   IF_NO_READ                        = ' '
    if_error_messages_send_0          = 'X'
*   IF_NO_BUFFER_REFRESH              = ' '
*   IF_NO_MES_UPD_PACK                = ' '
 IMPORTING
   ef_error_any_0                    = lv_err_anyerr
   ef_error_in_item_deletion_0       = lv_err_itmdel
   ef_error_in_pod_update_0          = lv_err_podupd
   ef_error_in_interface_0           = lv_err_interf
   ef_error_in_goods_issue_0         = lv_err_goodsi
   ef_error_in_final_check_0         = lv_err_finalc
 TABLES
   vbpok_tab                          = lt_vbpok
   prot                               = lt_prot
   verko_tab                          = lt_verko
   verpo_tab                          = lt_verpo
   vbsupcon_tab                       = lt_vbsupcon
*   IT_VERPO_SERNR                    =
*   IT_PACKING                        =
*   IT_PACKING_SERNR                  =
*   IT_REPACK                         =
*   IT_HANDLING_UNITS                 =
*   ET_CREATED_HUS                    =
*   TVPOD_TAB                         =
          .

COMMIT WORK.

wait up to 2 seconds.

*-If errors found - Populate msg table to display in the output
  IF NOT lv_err_anyerr IS INITIAL.     " GI doc creation failed
         lv_message = text-021.
         REPLACE '&' WITH gv_delivery INTO lv_message.

            gt_messages-statuson = 'Picking & GI Doc Creation'.
            gt_messages-msgtyp   = 'E'.
            gt_messages-message  = lv_message.
          APPEND gt_messages.
          CLEAR  gt_messages.

* Reverse all the prior docs since PGI failed
      gv_pgifailed = gc_x.

*-To get the GI Document & display  in the output
  ELSE.
    SELECT SINGLE vbeln
             FROM vbfa
             INTO lv_vbeln
             WHERE vbelv   = gv_delivery
               AND vbtyp_n = 'R'
               and rfmng   > 0.

* Update Final data table with GI doc number
    IF sy-subrc = 0.
      if lv_vbeln is initial.
         wait up to 3 seconds.
      endif.

      gv_pgidoc = lv_vbeln.

      LOOP AT gt_final.     " Update output table
           gt_final-pgidoc  = lv_vbeln.
           gt_final-message = text-027.
                " GR, Delivery, GI documents have created successfully
           MODIFY gt_final INDEX sy-tabix TRANSPORTING pgidoc message.
      ENDLOOP.
    ENDIF.

* Populate message table with GI doc number
         lv_message = text-024. " GI Doc & has been created successfully
         REPLACE '&' WITH lv_vbeln INTO lv_message.

            gt_messages-statuson = 'GI Doc Creation'.
            gt_messages-orgdoc   = lv_vbeln.
            gt_messages-msgtyp   = 'S'.
            gt_messages-message  = lv_message.
          APPEND gt_messages.
          CLEAR  gt_messages.
ENDIF.

ENDFORM.                    " do_PGI

Regards,

~Satya

0 Kudos

I am also doing automatic PGI at the time of billing, when user enters Delivery document no. and hits Enter, PGI should be done in background.

please help me with this enhancement. I have used your code but it is still archieving the PGI.

Thanks in advance.

0 Kudos

Hi Jaskaran,

Are you able to solve that?

Even I am facing the same problem. Materail document is automatically getting archived.

Please share the solution if you have worked it out.

Thanks,

Karthikeyan

0 Kudos

Flow

The sequence of flow will be as follow:-

(1). Delivery document number is
entered in ‘VF01’ and Enter is pressed.

(2). Post Goods Issue is done in
the background if the delivery document number exists.

(3).After Doing PGI the billing
process is continued.

Design

Step1 Created
a project in CMOD named
ZV60A001.

Step2 Create
a Customer exit component EXIT_SAPLV60A_002
in project ZV60A001.

Step3 In Exit there is a custom exit which is not
created, Press Enter and create include “”.

Step4 The
Function Module “
CSO_P_DLVRY_GOODS_ISSUE_CREATE” is used.

Step5 The Function Module is passed with the parameters:-

EXPORTING

  • Pi_deliv_numb which

IMPORTING

  • Pe_return1 which is Return Parameter(s), is
    a structure which returns error description, if any.
  • Pe_gi_blocked which is checkbox field, for telling if the PGI is blocked.

Hope this helps...

Former Member
0 Kudos

Thank you..