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

Using BAPI_PO_CREATE1,net price is corrupted.Kindly help

anish_asokan
Explorer
0 Kudos
1,235

Hi,

I am using BAPI_PO_CREATE1 for creating the PO.I am passing the order quantity as 1 BOX [1 BOX = 12 EA], while the pricing is maintained as $10/EA.After the PO is created, however, the net  price is shown as 150 instead of 120.I am not sure ,what is missing while passing to BAPI or is there something i need to take care of.

Any help in this regards, will be greatly appreciated.Thanks...

9 REPLIES 9
Read only

karthikeyan_p3
Contributor
0 Kudos
767


Hi Anish,

Are you filling all the necessary parameters of BAPIMEPOITEM? eg

QUANTITY

PO_UNIT

Have you tried creating the PO in ME21N with the same inputs which you have passed to BAPI & checked if it created PO with price as 120?

Thanks,

Karthikeyan

Read only

0 Kudos
767

Hi Kathikeyan,

I created one with Me21n and it created properly.Hence, doubts are on what i am passing to BAPI.I have added the details of the code, could you kindly help me on same.

Thanks..

Read only

former_member210770
Active Participant
0 Kudos
767

Hi Anish,

Can you please let us know what values you are passing in BAPIMEPOITEM  for Quantity, UOM . Also if possible can you please attach screenshot of created po with net value 150. So i can get deeper insight of the scenario.

Regards,

Sagar

Read only

0 Kudos
767

*** set ORDER_HEADER**********************************
poheader
-po_number = orders-mbstnr.
poheader
-doc_type = orders-mbsart.
poheader
-vendor = orders-mlifnr.
poheader
-purch_org = orders-mekorg.
poheader
-pur_group = orders-mekgrp.
poheader
-currency = orders-mwaers.


*** set ORDER_HEADERX**********************************
poheaderx
-po_number = 'X'.
poheaderx
-doc_type = 'X'.
poheaderx
-vendor = 'X'.
poheaderx
-purch_org = 'X'.
poheaderx
-pur_group = 'X'.
poheaderx
-currency = 'X'.
poheaderx
-item_intvl = 'X'.


*** set ORDER_ITEM **********************************
poitem
-po_item = orders-mbstpo.
poitem
-short_text = orders-mtxz01.
poitem
-material = orders-mematn.
poitem
-plant = orders-mwerks.
poitem
-stge_loc = orders-mlgort.
poitem
-matl_group = orders-mmatkl.

*Conversion of units and quantities done before moving the same to BAPI

IF orders-mematn IS NOT INITIAL OR orders-mematn NE SPACE.
CLEAR : l_meins,l_quantity.
SELECT SINGLE meins
FROM  mara
INTO l_meins
WHERE MATNR = orders-mematn.
IF sy-subrc  = 0.

poitem
-po_unit = l_meins.

SELECT SINGLE umrez umren
FROM   marm
INTO   (l_umrez,l_umren)
WHERE  MATNR = orders-mematn
AND    MEINH = orders-mmeins.
IF sy-subrc = 0.

l_quantity
= orders-mmenge * ( l_umrez / l_umren ).
poitem
-quantity = l_quantity.
ELSE.
flag_issueunit
= 'X'.
l_meinhu 
= orders-mmeins.
l_matnru 
= orders-mematn.
SHIFT l_matnru LEFT DELETING LEADING '0'.
l_ponum 
poheader-po_number.
ENDIF.

ENDIF.
ELSE.
poitem
-quantity = orders-mmenge.
poitem-po_unit = orders-mmeins.
ENDIF.


poitem
-net_price = orders-mnetpr.
poitem
-vend_mat = orders-midnlf.
poitem
-acctasscat = orders-mknttp.
poitem
-gr_ind = orders-mwepos.


poitemx
-po_item = orders-mbstpo.
poitemx
-short_text = 'X'.
poitemx
-material = 'X'.
poitemx
-plant = 'X'.
poitemx
-stge_loc = 'X'.
poitemx
-matl_group = 'X'.
poitemx
-quantity = 'X'.
poitemx
-po_unit = 'X'.
poitemx
-net_price = 'X'.
poitemx
-vend_mat = 'X'.
poitemx
-acctasscat = 'X'.
poitemx
-gr_ind = 'X'.

IF orders-muebto IS NOT INITIAL. poitemx-over_dlv_tol = 'X'.ENDIF.
IF orders-muebtk IS NOT INITIAL. poitemx-unlimited_dlv = 'X'.ENDIF.

IF poitem-tax_code IS NOT INITIAL.
poitemx
-tax_code = 'X'.
ENDIF.

APPEND poitemx.

*** set ORDER_SHEDULE **********************************
poschedule
-po_item = orders-mbstpo.
poschedule
-sched_line = '0001'.
poschedule
-delivery_date = orders-meeind.  IF l_quantity IS INITIAL OR l_quantity EQ SPACE.
poschedule
-quantity = orders-mmenge.
ELSE.
poschedule
-quantity = l_quantity.
ENDIF.
* End of Change by AA34862
APPEND poschedule.

*** set ORDER_SHEDULEX **********************************
poschedulex
-po_item = orders-mbstpo.
poschedulex
-sched_line = '0001'.
poschedulex
-po_itemx = 'X'.
poschedulex
-sched_linex = 'X'.
poschedulex
-delivery_date = 'X'.
poschedulex
-quantity = 'X'.
APPEND poschedulex.

*** set ORDER_ACCOUNT_ASSIGNMENT ************************
IF orders-mknttp CN ' '.
poaccount
-po_item = orders-mbstpo.
poaccount
-serial_no = '01'.
poaccount
-quantity = orders-mmenge.
poaccount
-gl_account = orders-msakto.
*** check accounting flag for object to charge **********
IF orders-mknttp = 'K'.
poaccount
-costcenter = orders-mkostl.
ELSEIF orders-mknttp = 'F'.
poaccount
-orderid = orders-maufnr.
ELSEIF orders-mknttp = 'P'.
poaccount
-wbs_element = orders-mpspnr.
ELSEIF orders-mknttp = 'A'.
poaccount
-asset_no = orders-manln1.
ENDIF.
APPEND poaccount.

*** set ORDER_ACCOUNT_ASSIGNMENTX ************************
poaccountx
-po_item = orders-mbstpo.
poaccountx
-serial_no = '01'.
*      POACCOUNTX-PO_ITEMX = 'X'.
*      POACCOUNTX-SERIAL_NO = 'X'.
poaccountx
-quantity = 'X'.
poaccountx
-gl_account = 'X'.
*** check accounting flag for object to charge **********
IF orders-mknttp = 'K'.
poaccountx
-costcenter = 'X'.
ELSEIF orders-mknttp = 'F'.
poaccountx
-orderid = 'X'.
ELSEIF orders-mknttp = 'P'.
poaccountx
-wbs_element = 'X'.
ELSEIF orders-mknttp = 'A'.
poaccountx
-asset_no = 'X'.
ENDIF.
APPEND poaccountx.
ENDIF.

*** set ORDER_ITEM_TEXT **********************************
potextitem
-po_number = orders-mbstnr.
potextitem
-po_item = orders-mbstpo.
potextitemx
-po_number = orders-mbstnr.
potextitemx
-po_item = orders-mbstpo.
******1**
IF orders-mtext1 CN ' '.
potextitem
-text_form = '*'.
potextitem
-text_line = orders-mtext1.
APPEND potextitem.
potextitemx
-text_form = 'X'.
potextitemx
-text_line = 'X'.
APPEND potextitemx.
ENDIF.
*******2**
IF orders-mtext2 CN ' '.
potextitem
-text_form = '*'.
potextitem
-text_line = orders-mtext2.
APPEND potextitem.
potextitemx
-text_form = 'X'.
potextitemx
-text_line = 'X'.
APPEND potextitemx.
ENDIF.
*******3**
IF orders-mtext3 CN ' '.
potextitem
-text_form = '*'.
potextitem
-text_line = orders-mtext3.
APPEND potextitem.
potextitemx
-text_form = 'X'.
potextitemx
-text_line = 'X'.
APPEND potextitemx.
ENDIF.
*******4**
IF orders-mtext4 CN ' '.
potextitem
-text_form = '*'.
potextitem
-text_line = orders-mtext4.
APPEND potextitem.
potextitemx
-text_form = 'X'.
potextitemx
-text_line = 'X'.
APPEND potextitemx.
ENDIF.
*******5**
IF orders-mtext5 CN ' '.
potextitem
-text_form = '*'.
potextitem
-text_line = orders-mtext5.
APPEND potextitem.
potextitemx
-text_form = 'X'.
potextitemx
-text_line = 'X'.
APPEND potextitemx.
ENDIF.
*******6**
IF orders-mtext6 CN ' '.
potextitem
-text_form = '*'.
potextitem
-text_line = orders-mtext6.
APPEND potextitem.
potextitemx
-text_form = 'X'.
potextitemx
-text_line = 'X'.
APPEND potextitemx.
ENDIF.
*******7**
IF orders-mtext7 CN ' '.
potextitem
-text_form = '*'.
potextitem
-text_line = orders-mtext7.
APPEND potextitem.
potextitemx
-text_form = 'X'.
potextitemx
-text_line = 'X'.
APPEND potextitemx.
ENDIF.
*******8**
IF orders-mtext8 CN ' '.
potextitem
-text_form = '*'.
potextitem
-text_line = orders-mtext8.
APPEND potextitem.
potextitemx
-text_form = 'X'.
potextitemx
-text_line = 'X'.
APPEND potextitemx.
ENDIF.
*******9**
IF orders-mtext9 CN ' '.
potextitem
-text_form = '*'.
potextitem
-text_line = orders-mtext9.
APPEND potextitem.
potextitemx
-text_form = 'X'.
potextitemx
-text_line = 'X'.
APPEND potextitemx.
ENDIF.
*******10*
IF orders-mtext10 CN ' '.
potextitem
-text_form = '*'.
potextitem
-text_line = orders-mtext10.
APPEND potextitem.
potextitemx
-text_form = 'X'.
potextitemx
-text_line = 'X'.
APPEND potextitemx.
ENDIF.
*** clear structures *****************************
CLEAR: poitem, potextitem, poschedule, poaccount,potextitem,
orders
, poitemx, potextitemx, poschedulex, poaccountx.
ENDLOOP.


CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader        
= poheader
poheaderx       
= poheaderx
IMPORTING
exppurchaseorder
= exppurchaseorder
TABLES
poitem          
= poitem
poaccount       
= poaccount
poschedule      
= poschedule
potextitem      
= potextitem
poitemx         
= poitemx
poaccountx      
= poaccountx
poschedulex     
= poschedulex
*       POTEXTITEMX      = POTEXTITEMX
return           = return.
ENDIF



This is the code currently I am using.                                                   

Read only

0 Kudos
767

Hi Anish,

I just go through your code. I have one doubt. Can you please let me know, What UOM you are passing in your file and What UOM you want to pass in your Bapi.

SELECT SINGLE umrez umren
FROM   marm
INTO   (l_umrez,l_umren)
WHERE  MATNR = orders-mematn
AND    MEINH = orders-mmeins.
IF sy-subrc = 0.

l_quantity
= orders-mmenge * ( l_umrez / l_umren ).  I have doubt in this calculation. Please clarify my doubts then i will confirm the logic.


Regards,

Sagar

Read only

0 Kudos
767

Hi Sagar,

I am passing the Unit of measure as BOX, I am mentioning as 1 BOX.But the rate is maintained as 10/EA.12 EA = 1 Box.

about the code you saw, the quantity comes to 12* 1/12 = 1 .the conversion factors maintained in MARM computs it into 1 Box itself.

Thanks...

Read only

0 Kudos
767

Hi Anish,

I request you to please pass the PRIZE_UNT after you are passing the value of NET_PRIZE.

I assume you are passing value of NET_PRIZE directly from file and it is pre calculated as per your rate calculation . Like 10/EA and quantity is 12 so you have to pass 120 - EA .

Regards,

Sagar

Read only

0 Kudos
767

Hi Sagar,

Price_unit is pack data type.It is not for accepting uom.You may check the same.

Thanks...

Read only

0 Kudos
767

Hi Anish,

It's better if you debug and check what value you are passing in NETPR , Price Unit should be passed.

Because there is no other way that your netpr values calculated wrong by system. Better you check your Quantity, UOM, Price and Prize Unit.

Also please verify your code with Standard documentation of this bapi : you can find it here.

tcode : BAPI -> Choose Tab Alphabetical -> Purchase Order -> Create From Data1 -> Documentation.

You will get mandatory parameters list from here. Please pass only those parameters.

Regards,

Sagar