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

changing the PO

Former Member
0 Likes
614

Hi gurus,

I have a condition where I need to update the price of the existing PO's based on certain conditons, I have two internal tables, itab1 has two fields matnr and price (changed price of the materials) and itab2 has all the po's that are required to change along with material and item no. and now I need to update these po's . for this I have written the below code, although code is doing fine are return parameter is returning that " PO # 1234567 has been updated succesfully " but when I went to the POitem table it shows me the same old price, can you please tell me where the error is :

data: begin of it_tab1 occurs 0,

matnr(18),

mat_price(15),

end of it_tab1.

data: begin of it_tab2 occurs 0,

ebeln like ekko-ebeln,

ebelp like ekpo-ebelp,

matnr like ekpo-matnr,

end of it_tab2.

data: purchaseorder LIKE BAPIMEPOHEADER-PO_NUMBER,

poheader LIKE bapimepoheader,

poheaderx LIKE bapimepoheaderx,

poitem LIKE bapimepoitem OCCURS 0 WITH HEADER LINE,

poitemx LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE,

return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,

return2 LIKE bapiret2 OCCURS 0 WITH HEADER LINE,

exppurchaseorder LIKE bapimepoheader-po_number,

poschedule LIKE bapimeposchedule OCCURS 0 WITH HEADER LINE,

poschedulex LIKE bapimeposchedulx OCCURS 0 WITH HEADER LINE,

pocond LIKE bapimepocond OCCURS 0 WITH HEADER LINE,

pocondx LIKE bapimepocondx OCCURS 0 WITH HEADER LINE.

loop at it_tab2.

move: it_tab2-ebeln to poheader-PO_NUMBER.

loop at it_tab1.

if it_tab1-matnr = it_tab2-matnr.

move: it_tab1-mat_price to poitem-NET_PRICE.

move: it_itab2-ebelp to poitem-PO_ITEM.

move: 'X' to poitemx-NET_PRICE.

move: 'X' to poitemx-po_item.

append : poitem,poitemx.

endif.

endloop.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

PURCHASEORDER = it_tab2-ebeln

  • POHEADER =

  • POHEADERX =

  • POADDRVENDOR =

  • IMPORTING

  • EXPHEADER =

  • EXPPOEXPIMPHEADER =

TABLES

RETURN = return

POITEM = poitem

POITEMX = poitemx

  • pocond =

  • pocondx = *POADDRDELIVERY =

  • POSCHEDULE =

  • POSCHEDULEX =

  • POACCOUNT =

  • POACCOUNTPROFITSEGMENT =

  • POACCOUNTX =

  • POCONDHEADER =

  • POCONDHEADERX =

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

IMPORTING

return = return2.

endloop.

Thanks

Rajeev

Message was edited by:

Rajeev Gupta

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
598

Hi,

You missed to populate field POITEMX-PO_ITEM with IT_TAB2-EBELP.

Please change to this ...


...

loop at it_tab2.
  move: it_tab2-ebeln to poheader-PO_NUMBER.
  
  loop at it_tab1 where matnr = it_tab2-matnr.          "Change here
     move: it_tab1-mat_price to poitem-NET_PRICE.
     move: it_tab2-ebelp to poitem-PO_ITEM.
     move: it_tab2-ebelp to poitemx-PO_ITEM.             "Add here
     move: 'X' to poitemx-po_itemx.
     move: 'X' to poitemx-NET_PRICE.
     append : poitem,poitemx.
  endloop.
...

Regards,

Ferry Lianto

Hi gurus,

I have a condition where I need to update the price of the existing PO's based on certain conditons, I have two internal tables, itab1 has two fields matnr and price (changed price of the materials) and itab2 has all the po's that are required to change along with material and item no. and now I need to update these po's . for this I have written the below code, although code is doing fine are return parameter is returning that " PO # 1234567 has been updated succesfully " but when I went to the POitem table it shows me the same old price, can you please tell me where the error is :

data: begin of it_tab1 occurs 0,

matnr(18),

mat_price(15),

end of it_tab1.

data: begin of it_tab2 occurs 0,

ebeln like ekko-ebeln,

ebelp like ekpo-ebelp,

matnr like ekpo-matnr,

end of it_tab2.

data: purchaseorder LIKE BAPIMEPOHEADER-PO_NUMBER,

poheader LIKE bapimepoheader,

poheaderx LIKE bapimepoheaderx,

poitem LIKE bapimepoitem OCCURS 0 WITH HEADER LINE,

poitemx LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE,

return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,

return2 LIKE bapiret2 OCCURS 0 WITH HEADER LINE,

exppurchaseorder LIKE bapimepoheader-po_number,

poschedule LIKE bapimeposchedule OCCURS 0 WITH HEADER LINE,

poschedulex LIKE bapimeposchedulx OCCURS 0 WITH HEADER LINE,

pocond LIKE bapimepocond OCCURS 0 WITH HEADER LINE,

pocondx LIKE bapimepocondx OCCURS 0 WITH HEADER LINE.

loop at it_tab2.

move: it_tab2-ebeln to poheader-PO_NUMBER.

loop at it_tab1.

if it_tab1-matnr = it_tab2-matnr.

move: it_tab1-mat_price to poitem-NET_PRICE.

move: it_itab2-ebelp to poitem-PO_ITEM.

move: 'X' to poitemx-NET_PRICE.

move: 'X' to poitemx-po_item.

append : poitem,poitemx.

endif.

endloop.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

PURCHASEORDER = it_tab2-ebeln

  • POHEADER =

  • POHEADERX =

  • POADDRVENDOR =

  • IMPORTING

  • EXPHEADER =

  • EXPPOEXPIMPHEADER =

TABLES

RETURN = return

POITEM = poitem

POITEMX = poitemx

  • pocond =

  • pocondx = *POADDRDELIVERY =

  • POSCHEDULE =

  • POSCHEDULEX =

  • POACCOUNT =

  • POACCOUNTPROFITSEGMENT =

  • POACCOUNTX =

  • POCONDHEADER =

  • POCONDHEADERX =

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

IMPORTING

return = return2.

endloop.

Thanks

Rajeev

Message was edited by:

Rajeev Gupta

4 REPLIES 4
Read only

messier31
Active Contributor
0 Likes
598

Hi,

Can you check in debugging mode wht you are getting in RETURN table of

'BAPI_PO_CHANGE' and the RETURN parameter of commit BAPI ?

Enjoy SAP.

Pankaj Singh

Read only

Former Member
0 Likes
598

Thanks for the reply Pankaj, but these return are returning the same value

"Standard PO 450123654 changed"

"Standard PO 450123654 changed"

Thanks

Rajeev

Read only

Former Member
0 Likes
599

Hi,

You missed to populate field POITEMX-PO_ITEM with IT_TAB2-EBELP.

Please change to this ...


...

loop at it_tab2.
  move: it_tab2-ebeln to poheader-PO_NUMBER.
  
  loop at it_tab1 where matnr = it_tab2-matnr.          "Change here
     move: it_tab1-mat_price to poitem-NET_PRICE.
     move: it_tab2-ebelp to poitem-PO_ITEM.
     move: it_tab2-ebelp to poitemx-PO_ITEM.             "Add here
     move: 'X' to poitemx-po_itemx.
     move: 'X' to poitemx-NET_PRICE.
     append : poitem,poitemx.
  endloop.
...

Regards,

Ferry Lianto

Read only

0 Likes
598

Thanks very much Ferry...the probelm is resolved now!!

Thanks

Rajeev