Application Development and Automation 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: 
Read only

PGI for Delivery

Former Member
0 Likes
1,264

Hi Experts,

I have coded the following successfully.

1. Create a delivery from a production order

2. Create TO from delivery created

3. Pick/Pack and Confirm TO

Now, I need to create a PGI based from the delivery i created. I used FM BAPI_GOODSMVT_CREATE, however it only creates another delivery. Code is below:

LOOP AT i_itemhu INTO wa_itemhu.

wa_goodsmvt_item-plant = wa_itemhu-plant.

wa_goodsmvt_item-stge_loc = wa_itemhu-stge_loc.

wa_goodsmvt_item-batch = wa_itemhu-batch.

wa_goodsmvt_item-move_type = '261'.

wa_goodsmvt_item-entry_qnt = wa_itemhu-entry_qnt.

wa_goodsmvt_item-entry_uom = wa_itemhu-entry_uom.

wa_goodsmvt_item-orderid = wa_itemhu-orderid.

wa_goodsmvt_item-deliv_numb = wa_itemhu-deliv_numb.

wa_goodsmvt_item-deliv_item = wa_itemhu-deliv_item.

APPEND wa_goodsmvt_item TO i_goodsmvt_item.

CLEAR wa_goodsmvt_item.

ENDLOOP.

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

goodsmvt_header = wa_header

goodsmvt_code = '03'

IMPORTING

materialdocument = ws_doc_gihu

TABLES

goodsmvt_item = i_goodsmvt_item.

Is it really possible to do PGI using this FM? If yes, please help in coding.. Many many thanks!!!

9 REPLIES 9
Read only

Former Member
0 Likes
1,177

This message was moderated.

Read only

Former Member
0 Likes
1,177

Hello,

For doing PGI, BAPI_GOODSMVT_CREATE will not be appropriate. Instead, use either of the FMs WS_DELIVERY_UPDATE or WS_DELIVERY_UPDATE_2. This will help you do the PGI for the given delivery.

Regards,

Venkata Phani Prasad K

Read only

0 Likes
1,177

Hi,

I am using WS_DELIVERY_UPDATE to perform PGI of delivery. I am testing first the FM by in SE37 and PGI is correctly done for a delivery, however, when I had coded it (same way as the testing) I am getting error Delivery XXXXXXXXXX created. On which the delivery XXXXXXXXXX is the delivery I want to perform PGI. I am also trying do some changes in my code like passing the items to vbpok_tab; enabling synchon FM parameter; enabling nicht_sperren; etc., but still same error is being produced. My code is as below:

wa_vbkok-vbeln_vl = ws_delivery_doc.

wa_vbkok-vbtyp_vl = 'J'.

wa_vbkok-wabuc = 'X'.

CALL FUNCTION 'WS_DELIVERY_UPDATE'

EXPORTING

vbkok_wa = wa_vbkok

commit = 'X'

delivery = ws_delivery_doc

IMPORTING

ef_error_any_0 = ws_xfeld

TABLES

prot = wa_prot.

Please help.

Read only

0 Likes
1,177

Hello,

Did you try WS_DELIVERY_UPDATE_2? Does it give the same error?

Regards,

Venkata Phani Prasad K

Read only

0 Likes
1,177

Same goes with that FM since WS_DELIVERY_UPDATE_2 is being used inside FM WS_DELIVERY_UPDATE. Both of them successfully perform PGI when testing them in SE37, but when it is in code, error message is being retrieved.

Read only

0 Likes
1,177

I am now getting error No status object is available for HU &. I already called FMs below that would refresh standard data before executing FM 'WS_DELIVERY_UPDATE', however the still error is getting retrieved.

CALL FUNCTION 'QAAT_HUMO_REFRESH'.

CALL FUNCTION 'MB_MOVEMENTS_REFRESH'.

CALL FUNCTION 'STATUS_BUFFER_REFRESH'.

CALL FUNCTION 'HU_STATUS_REFRESH'.

CALL FUNCTION 'MB_MOVEMENTS_REFRESH'.

I am planning to talk with the Functional team and Basis team implement SAP Note 614179. I hope this would solve this.

Read only

eduardo_hinojosa
Active Contributor
0 Likes
1,177

Hi

Do a coding as this:



      call function 'BAPI_GOODSMVT_CREATE'
        exporting
          goodsmvt_header  = l_goodsmvt_header
          goodsmvt_code    = l_goodsmvt_code
          testrun          = ' '
        importing
          goodsmvt_headret = l_goodsmvt_headret
          materialdocument = l_mblnr
          matdocumentyear  = l_mjahr
        tables
          goodsmvt_item    = i_goodsmvt_item
          return           = i_return.

      call function 'BAPI_TRANSACTION_COMMIT'.

Read the data in I_RETURN to know the origin of troubles.

See also SAP Note 520813 - FAQ: BAPIs for goods movements, it will help you

Regards

Eduardo

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,177

I used FM BAPI_GOODSMVT_CREATE, however it only creates another delivery.

The function you mentioned does not create a delivery. I have used the same fm for create PGI and it worked fine. Unfortunately i donot have the code with me now.Please check it once again. When doing it through standard transaction is there any new delivery created ?

Kesav

Read only

0 Likes
1,177

Solved by using BDC.