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: 

Using BAPI_PO_CHANGE to flag Delivery Complete

Former Member

Hi Experts,

I've successfully implemented code found on post

I would now like to modify the code to update the "Outward Delivery Completed" Indicator on ME22N (EGLKZ). However, running the code results in message "No Data Changed". I am aware EGLKZ is only valid for internal stock transport orders, not purchase orders. I have successfully made the changes manually using ME22N, so it is not a data validation issue.

I am very new to ABAP, so perhaps I am missing something obvious. Any suggestions?


REPORT  Z_MASS_REMOVE_FDI_BAPI.

*head
PARAMETERS: p_ebeln LIKE bapimepoheader-po_number OBLIGATORY.

*Item
PARAMETERS :p_ebelp LIKE bapimepoitem-po_item DEFAULT 1.

DATA: s_header TYPE bapimepoheader,
      s_headerx TYPE bapimepoheaderx,
      s_item TYPE bapimepoitem,
      s_itemx TYPE bapimepoitemx,
      i_return TYPE bapiret2 OCCURS 0 WITH HEADER LINE,
      i_extension TYPE bapiparex OCCURS 0 WITH HEADER LINE,
      s_bapimepoheader TYPE bapimepoheader,
      s_bapimepoheaderx TYPE bapimepoheaderx,
      s_bapimepoitem TYPE bapimepoitem,
      s_bapimepoitemX TYPE bapimepoitemX,
      wa_message TYPE c LENGTH 100.

s_bapimepoheaderx-po_number = p_ebeln.
s_bapimepoheader-po_number = p_ebeln.
s_bapimepoitemx-PO_ITEM = p_ebelp.
s_bapimepoitem-PO_ITEM = p_ebelp.
s_bapimepoitemx-DELIV_COMPL = 'X'.
s_bapimepoitem-DELIV_COMPL = 'X'.


s_header-po_number = p_ebeln.
S_item-PO_ITEM = p_ebelp.

CALL FUNCTION 'BAPI_PO_CHANGE'
  EXPORTING
    purchaseorder = p_ebeln
  TABLES
    return        = i_return.

COMMIT WORK.
LOOP AT i_return.
  MESSAGE ID   i_return-id
       TYPE    i_return-type
       NUMBER  i_return-number WITH
               i_return-message_v1
               i_return-message_v2
               i_return-message_v3
               i_return-message_v4.
ENDLOOP.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Nathan ,

are u passing ITEM data to this BAPI ,i cannt see in this code ?, u need to pass ITem data to this BAPI .

regards

Prabhu

8 REPLIES 8

Former Member
0 Kudos

Hi Nathan ,

are u passing ITEM data to this BAPI ,i cannt see in this code ?, u need to pass ITem data to this BAPI .

regards

Prabhu

0 Kudos

I have pasted the complete code, so obviously I am missing something.

Are you able to advise how to pass the ITEM data to BAPI?

0 Kudos

Hi Nathan ,

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = p_ebeln

TABLES

return = i_return

poitem = s_bapimeitem

poitemx = s_bapimepoitemx.

if i_return[] is initial.

commit work.

endif.

regards

Prabhu

0 Kudos

Thanks Prabhu.

I've added your suggested code, I am now getting the errors:

"s_bapimepoitem is not an internal table the "OCCURS n" specification is missing"

"s_bapimepoitemx is not an internal table the "OCCURS n" specification is missing"

0 Kudos

Hi ,

s_bapimepoitem TYPE bapimepoitem occurs 0 with header line ,

s_bapimepoitemX TYPE bapimepoitemX occurs 0 with header line,

and in need to change u are code as well .

s_bapimepoitemx-DELIV_COMPL = 'X'.

s_bapimepoitem-DELIV_COMPL = 'X'.

append s_bapimepoitem.

clear s_bapimepoitem.

this is just a sample code only , for more details u need to check the documentation of this BAPI or search for sample code in ABAP forums.

regards

Prabhu

0 Kudos

hi

this is the example for updating PO for changing quantity of existing item . Using this u can find any idea to change the specified field.

item-po_item = itemx-po_item = it_final-ebelp.

itemx-po_itemx = 'X'.

APPEND item.

APPEND itemx.

CLEAR item.

CLEAR itemx.

poschedule-po_item = it_final-ebelp.

poschedule-sched_line = '0001'.

poschedule-quantity = it_final-menge.

APPEND poschedule.

CLEAR poschedule.

poschedulex-po_item = it_final-ebelp.

poschedulex-sched_line = '0001'.

poschedulex-po_itemx = 'X'.

poschedulex-sched_linex = 'X'.

poschedulex-quantity = 'X'.

APPEND poschedulex.

CLEAR poschedulex.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = it_final-ebeln

TABLES

return = return

poitem = item

poitemx = itemx

poschedule = poschedule

poschedulex = poschedulex.

COMMIT WORK AND WAIT.

0 Kudos

Thankyou very much for your help, I think we're getting somewhere - but still not quite right.

Adding the code:

append s_bapimepoitem.

clear s_bapimepoitem.

Resulted in error:

"Please also populate interface parameter POITEMX"

So I added code:

append s_bapimepoitemx.

clear s_bapimepoitemx.

Now I'm getting error: (and changes were not saved to document)

No message generated for output of purchasing document

Message no. 06261

Diagnosis

The system was not able to find a message record via the message determination schema. Therefore it was not possible for such a record to be generated for this purchasing document. In consequence, the purchasing document cannot be outputted (printed or transmitted).

Procedure

The message determination process should be checked and, if necessary, corrected.

The message record can be created manually for this document. For this purpose, choose the function "Messages" in the menu "Header" and maintain the necessary data.

0 Kudos

Thank you both for your help. The program is now working, except that if yellow warnings occur the document is not saved.

I have created a new thread for this problem as follows: