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: 

BAPI_PO_CREATE1 with NET_PRICE wrong!!

luisfel28
Participant
0 Kudos
531

Hi magics of abap!

I'm using a function BAPI_PO_CREATE1 with NET_PRICE, but after call function the values change for contract price... I've tried many ways found in SDN, but nothing worked!!!

Can someone give me a definitive solution???

Regards!!

1 ACCEPTED SOLUTION

former_member222709
Contributor
0 Kudos
218

Hi,

1. Are you taking the PR - RFQ reference to create the PO?

or

2. Are you directly creating the PO by passing the values to BAPI.

Because, I've noticed that when you pass data directly, there are a lot of factors and functional configuration that influence pricing when a PO is created using the BAPI. You need to be thorough with the Function Module Documentation with reference to passing parameters to the table parameters.

Also, please post your code to check out probables.

Regards,

Pranav.

7 REPLIES 7

krishnendu_laha
Active Contributor
0 Kudos
218

hello,

May be there is some user exit / BADI implemented to change price based on condition...

DEBUG is a suitable approach I can see...

Thanks

former_member222709
Contributor
0 Kudos
219

Hi,

1. Are you taking the PR - RFQ reference to create the PO?

or

2. Are you directly creating the PO by passing the values to BAPI.

Because, I've noticed that when you pass data directly, there are a lot of factors and functional configuration that influence pricing when a PO is created using the BAPI. You need to be thorough with the Function Module Documentation with reference to passing parameters to the table parameters.

Also, please post your code to check out probables.

Regards,

Pranav.

0 Kudos
218

Doctors, the NET_PRICE is changed for CONTRACT PRICE after call function... follow my code:

DATA: GT_BAPIMEPOITEM TYPE TABLE OF BAPIMEPOITEM,

GT_BAPIMEPOITEMX TYPE TABLE OF BAPIMEPOITEMX,

GT_BAPIMEPOSCHEDULE TYPE TABLE OF BAPIMEPOSCHEDULE,

GT_BAPIMEPOSCHEDULX TYPE TABLE OF BAPIMEPOSCHEDULX,

GT_BAPIMEPOACCOUNT TYPE TABLE OF BAPIMEPOACCOUNT,

GT_BAPIMEPOACCOUNTX TYPE TABLE OF BAPIMEPOACCOUNTX,

GT_BAPIMEPOCOND TYPE TABLE OF BAPIMEPOCOND,

GT_BAPIMEPOCONDX TYPE TABLE OF BAPIMEPOCONDX,

GT_BAPIMEPOSERVICES TYPE TABLE OF BAPIESLLC,

GT_BAPIMEPOSRVACCESSVALUES TYPE TABLE OF BAPIESKLC,

GT_BAPIMEPOLIMITS TYPE TABLE OF BAPIESUHC,

GT_BAPIMEPOCONTRACTLIMITS TYPE TABLE OF BAPIESUCC.

FORM Z_PROCESS_DATA.

DATA: L_BAPIMEPOSERVICES TYPE BAPIESLLC,

L_BAPIMEPOACCOUNT TYPE BAPIMEPOACCOUNT,

L_BAPIMEPOSCHEDULX TYPE BAPIMEPOSCHEDULX,

L_BAPIMEPOCOND TYPE BAPIMEPOCOND,

L_BAPIMEPOACCOUNTX TYPE BAPIMEPOACCOUNTX,

L_BAPIMEPOCONDX TYPE BAPIMEPOCONDX,

L_BAPIMEPOSRVACCESSVALUES TYPE BAPIESKLC,

L_BAPIMEPOSCHEDULE TYPE BAPIMEPOSCHEDULE,

L_BAPIMEPOITEMX TYPE BAPIMEPOITEMX,

L_BAPIMEPOITEM TYPE BAPIMEPOITEM,

L_MOEDA TYPE BSID-WAERS.

  • Limpar tabelas/variaveis globais

CLEAR: GI_TOT_REG.

  • Numero de registros no arquivo de entrada

DESCRIBE TABLE GT_DATA LINES GI_TOT_REG.

  • DATA: L_SEQ TYPE I.

LOOP AT GT_DATA INTO GT_DATA.

"COLOCA ZEROS A ESQUERDA PARA OS SEGUINTES CAMPOS

UNPACK GT_DATA-FORNECEDOR TO GT_DATA-FORNECEDOR.

UNPACK GT_DATA-MATERIAL TO GT_DATA-MATERIAL.

UNPACK GT_DATA-REQ_COMPRAS TO GT_DATA-REQ_COMPRAS.

UNPACK GT_DATA-ITEM_RC TO GT_DATA-ITEM_RC.

"ESTRUTURA SÓ SERÃO ALIMENTADAS QUANDO TROCAR O DOCUMENTO

ON CHANGE OF GT_DATA-TIPO_DOC.

  • L_SEQ = 1.

GS_POHEADER-PO_NUMBER = GT_DATA-PEDIDO.

GS_POHEADER-COMP_CODE = GT_DATA-EMPRESA.

GS_POHEADER-DOC_TYPE = GT_DATA-TIPO_DOC.

GS_POHEADER-ITEM_INTVL = GT_DATA-ITEM.

GS_POHEADER-VENDOR = GT_DATA-FORNECEDOR.

GS_POHEADER-PMNTTRMS = GT_DATA-COND_PGTO.

GS_POHEADER-PURCH_ORG = GT_DATA-ORG_COMPRAS.

GS_POHEADER-PUR_GROUP = GT_DATA-GRP_COMPRAS.

GS_POHEADER-CURRENCY = GT_DATA-MOEDA.

GS_POHEADER-INCOTERMS1 = GT_DATA-INCOTERM1.

GS_POHEADER-INCOTERMS2 = GT_DATA-INCOTERM2.

GS_POHEADER-REF_1 = GT_DATA-REFERENCIA.

GS_POHEADER-VPER_START = GT_DATA-INI_VAL.

GS_POHEADER-VPER_END = GT_DATA-FIM_VAL.

GS_POHEADERX-COMP_CODE = 'X'.

GS_POHEADERX-DOC_TYPE = 'X'.

GS_POHEADERX-ITEM_INTVL = 'X'.

GS_POHEADERX-VENDOR = 'X'.

GS_POHEADERX-PMNTTRMS = 'X'.

GS_POHEADERX-PURCH_ORG = 'X'.

GS_POHEADERX-PUR_GROUP = 'X'.

GS_POHEADERX-CURRENCY = 'X'.

GS_POHEADERX-INCOTERMS1 = 'X'.

GS_POHEADERX-INCOTERMS2 = 'X'.

GS_POHEADERX-REF_1 = 'X'.

GS_POHEADERX-VPER_START = 'X'.

GS_POHEADERX-VPER_END = 'X'.

ENDON.

L_BAPIMEPOITEM-PO_ITEM = GT_DATA-ITEM.

L_BAPIMEPOITEM-MATERIAL = GT_DATA-MATERIAL.

L_BAPIMEPOITEM-PLANT = GT_DATA-CENTRO.

L_BAPIMEPOITEM-STGE_LOC = ''.

L_BAPIMEPOITEM-PCKG_NO = 1.

L_BAPIMEPOITEM-QUANTITY = GT_DATA-QTD.

L_BAPIMEPOITEM-PRICE_UNIT = 1.

L_BAPIMEPOITEM-NET_PRICE = GT_DATA-PRECO_LIQ.

L_BAPIMEPOITEM-TAX_CODE = GT_DATA-IVA.

L_BAPIMEPOITEM-ITEM_CAT = GT_DATA-CTG_ITEM.

L_BAPIMEPOITEM-ACCTASSCAT = GT_DATA-CLASS_CONT.

L_BAPIMEPOITEM-PREQ_NO = GT_DATA-REQ_COMPRAS.

L_BAPIMEPOITEM-PREQ_ITEM = GT_DATA-ITEM_RC.

L_BAPIMEPOITEM-PO_PRICE = '2'.

L_BAPIMEPOITEM-CALCTYPE = 'B'.

APPEND L_BAPIMEPOITEM TO GT_BAPIMEPOITEM.

CLEAR: L_BAPIMEPOITEM.

L_BAPIMEPOITEMX-PO_ITEM = GT_DATA-ITEM.

L_BAPIMEPOITEMX-MATERIAL = 'X'.

L_BAPIMEPOITEMX-PLANT = 'X'.

L_BAPIMEPOITEMX-STGE_LOC = 'X'.

L_BAPIMEPOITEMX-PCKG_NO = 'X'.

L_BAPIMEPOITEMX-QUANTITY = 'X'.

L_BAPIMEPOITEMX-NET_PRICE = 'X'.

L_BAPIMEPOITEMX-PRICE_UNIT = 'X'.

L_BAPIMEPOITEMX-TAX_CODE = 'X'.

L_BAPIMEPOITEMX-ITEM_CAT = 'X'.

L_BAPIMEPOITEMX-ACCTASSCAT = 'X'.

L_BAPIMEPOITEMX-PREQ_NO = 'X'.

L_BAPIMEPOITEMX-PREQ_ITEM = 'X'.

L_BAPIMEPOITEMX-PO_PRICE = 'X'.

L_BAPIMEPOITEMX-CALCTYPE = 'X'.

APPEND L_BAPIMEPOITEMX TO GT_BAPIMEPOITEMX.

CLEAR: L_BAPIMEPOITEMX.

L_BAPIMEPOSCHEDULE-PO_ITEM = GT_DATA-ITEM.

L_BAPIMEPOSCHEDULE-DELIVERY_DATE = GT_DATA-DT_REMESSA.

L_BAPIMEPOSCHEDULE-QUANTITY = GT_DATA-QTD.

L_BAPIMEPOSCHEDULE-PREQ_NO = GT_DATA-REQ_COMPRAS.

L_BAPIMEPOSCHEDULE-PREQ_ITEM = GT_DATA-ITEM_RC.

APPEND L_BAPIMEPOSCHEDULE TO GT_BAPIMEPOSCHEDULE.

CLEAR: L_BAPIMEPOSCHEDULE.

L_BAPIMEPOSCHEDULX-PO_ITEM = GT_DATA-ITEM.

L_BAPIMEPOSCHEDULX-DELIVERY_DATE = 'X'.

L_BAPIMEPOSCHEDULX-QUANTITY = 'X'.

L_BAPIMEPOSCHEDULX-PREQ_NO = 'X'.

L_BAPIMEPOSCHEDULX-PREQ_ITEM = 'X'.

APPEND L_BAPIMEPOSCHEDULX TO GT_BAPIMEPOSCHEDULX.

CLEAR: L_BAPIMEPOSCHEDULX.

L_BAPIMEPOACCOUNT-PO_ITEM = GT_DATA-ITEM.

L_BAPIMEPOACCOUNT-GL_ACCOUNT = '0000604105'.

L_BAPIMEPOACCOUNT-COSTCENTER = GT_DATA-CENTRO_CUSTO.

L_BAPIMEPOACCOUNT-SERIAL_NO = 1.

L_BAPIMEPOACCOUNT-CO_AREA = 'CAPE'.

L_BAPIMEPOACCOUNT-WBS_ELEMENT = ''.

L_BAPIMEPOACCOUNT-QUANTITY = GT_DATA-QTD.

APPEND L_BAPIMEPOACCOUNT TO GT_BAPIMEPOACCOUNT.

CLEAR: L_BAPIMEPOACCOUNT.

L_BAPIMEPOACCOUNTX-PO_ITEM = GT_DATA-ITEM.

L_BAPIMEPOACCOUNTX-GL_ACCOUNT = 'X'.

L_BAPIMEPOACCOUNTX-COSTCENTER = 'X'.

L_BAPIMEPOACCOUNTX-SERIAL_NO = 'X'.

L_BAPIMEPOACCOUNTX-CO_AREA = 'X'.

L_BAPIMEPOACCOUNTX-WBS_ELEMENT = 'X'.

L_BAPIMEPOACCOUNTX-QUANTITY = 'X'.

APPEND L_BAPIMEPOACCOUNTX TO GT_BAPIMEPOACCOUNTX.

CLEAR: L_BAPIMEPOACCOUNTX.

L_BAPIMEPOCOND-ITM_NUMBER = GT_DATA-ITEM.

L_BAPIMEPOCOND-COND_TYPE = 'PB00'.

L_BAPIMEPOCOND-COND_VALUE = GT_DATA-PRECO_LIQ.

L_BAPIMEPOCOND-CURRENCY = GT_DATA-MOEDA.

L_BAPIMEPOCOND-CURRENCY_ISO = GT_DATA-MOEDA.

PERFORM Z_CONVERT_UNIDADE

USING GT_DATA-UNIDADE

CHANGING L_BAPIMEPOCOND-COND_UNIT.

L_BAPIMEPOCOND-COND_P_UNT = 1.

L_BAPIMEPOCOND-CHANGE_ID = 'I'.

APPEND L_BAPIMEPOCOND TO GT_BAPIMEPOCOND.

CLEAR: L_BAPIMEPOCOND.

L_BAPIMEPOCONDX-ITM_NUMBER = GT_DATA-ITEM.

L_BAPIMEPOCONDX-COND_ST_NO = 'X'.

L_BAPIMEPOCONDX-COND_TYPE = 'X'.

L_BAPIMEPOCONDX-COND_VALUE = 'X'.

L_BAPIMEPOCONDX-CURRENCY = 'X'.

L_BAPIMEPOCONDX-CURRENCY_ISO = 'X'.

L_BAPIMEPOCONDX-COND_UNIT = 'X'.

L_BAPIMEPOCONDX-COND_P_UNT = 'X'.

L_BAPIMEPOCONDX-CHANGE_ID = 'X'.

APPEND L_BAPIMEPOCONDX TO GT_BAPIMEPOCONDX.

CLEAR: L_BAPIMEPOCONDX.

  • IF GT_DATA-REQ_COMPRAS EQ '' AND GT_DATA-ITEM_RC EQ ''.

L_BAPIMEPOSERVICES-QUANTITY = GT_DATA-QTD.

PERFORM Z_CONVERT_UNIDADE

USING GT_DATA-UNIDADE

CHANGING L_BAPIMEPOSERVICES-BASE_UOM.

L_BAPIMEPOSERVICES-PCKG_NO = 1.

L_BAPIMEPOSERVICES-LINE_NO = 1.

L_BAPIMEPOSERVICES-PRICE_UNIT = 1.

L_BAPIMEPOSERVICES-GR_PRICE = GT_DATA-PRECO_LIQ.

L_BAPIMEPOSERVICES-SHORT_TEXT = GT_DATA-ITEM.

APPEND L_BAPIMEPOSERVICES TO GT_BAPIMEPOSERVICES.

CLEAR: L_BAPIMEPOSERVICES.

L_BAPIMEPOSRVACCESSVALUES-PCKG_NO = 1.

L_BAPIMEPOSRVACCESSVALUES-LINE_NO = 1.

L_BAPIMEPOSRVACCESSVALUES-SERNO_LINE = 1.

L_BAPIMEPOSRVACCESSVALUES-SERIAL_NO = 'X'.

APPEND L_BAPIMEPOSRVACCESSVALUES TO GT_BAPIMEPOSRVACCESSVALUES.

CLEAR: L_BAPIMEPOSRVACCESSVALUES.

  • ENDIF.

"QUANDO O DOCUMENTO FOR ALTERADO, OM PERFORM É CHAMADO

AT END OF TIPO_DOC.

PERFORM Z_CALL_BAPI

TABLES GT_BAPIMEPOITEM

GT_BAPIMEPOITEMX

GT_BAPIMEPOSCHEDULE

GT_BAPIMEPOSCHEDULX

GT_BAPIMEPOACCOUNT

GT_BAPIMEPOACCOUNTX

GT_BAPIMEPOCOND

GT_BAPIMEPOCONDX

GT_BAPIMEPOSERVICES

GT_BAPIMEPOSRVACCESSVALUES

GT_BAPIMEPOLIMITS

GT_BAPIMEPOCONTRACTLIMITS

USING GS_POHEADER

GS_POHEADERX.

ENDAT.

  • L_SEQ = L_SEQ + 1.

ENDLOOP.

  • Exibir log de processamento

  • PERFORM Z_PRINT_LOG.

ENDFORM. " Z_PROCESS_DATA

FORM Z_CALL_BAPI TABLES P_GT_BAPIMEPOITEM STRUCTURE BAPIMEPOITEM

P_GT_BAPIMEPOITEMX STRUCTURE BAPIMEPOITEMX

P_GT_BAPIMEPOSCHEDULE STRUCTURE BAPIMEPOSCHEDULE

P_GT_BAPIMEPOSCHEDULX STRUCTURE BAPIMEPOSCHEDULX

P_GT_BAPIMEPOACCOUNT STRUCTURE BAPIMEPOACCOUNT

P_GT_BAPIMEPOACCOUNTX STRUCTURE BAPIMEPOACCOUNTX

P_GT_BAPIMEPOCOND STRUCTURE BAPIMEPOCOND

P_GT_BAPIMEPOCONDX STRUCTURE BAPIMEPOCONDX

P_GT_BAPIMEPOSERVICES STRUCTURE BAPIESLLC

P_GT_BAPIMEPOSRVACCESSVALUES STRUCTURE BAPIESKLC

P_GT_BAPIMEPOLIMITS STRUCTURE BAPIESUHC

P_GT_BAPIMEPOCONTRACTLIMITS STRUCTURE BAPIESUCC

USING P_GS_POHEADER TYPE BAPIMEPOHEADER

P_GS_POHEADERX TYPE BAPIMEPOHEADERX.

DATA: L_ORDER LIKE BAPIMEPOHEADER-PO_NUMBER.

BREAK-POINT.

CALL FUNCTION 'BAPI_PO_CREATE1'

EXPORTING

POHEADER = P_GS_POHEADER

POHEADERX = P_GS_POHEADERX

  • POADDRVENDOR =

TESTRUN = P_VALIDA

  • MEMORY_UNCOMPLETE =

  • MEMORY_COMPLETE =

  • POEXPIMPHEADER =

  • POEXPIMPHEADERX =

  • VERSIONS =

  • NO_MESSAGING =

  • NO_MESSAGE_REQ =

  • NO_AUTHORITY =

  • NO_PRICE_FROM_PO = 'X'

  • PARK_COMPLETE =

  • PARK_UNCOMPLETE =

IMPORTING

EXPPURCHASEORDER = L_ORDER

  • EXPHEADER =

  • EXPPOEXPIMPHEADER =

TABLES

RETURN = GT_RETURN

POITEM = P_GT_BAPIMEPOITEM

POITEMX = P_GT_BAPIMEPOITEMX

  • POADDRDELIVERY =

POSCHEDULE = P_GT_BAPIMEPOSCHEDULE

POSCHEDULEX = P_GT_BAPIMEPOSCHEDULX

POACCOUNT = P_GT_BAPIMEPOACCOUNT

  • POACCOUNTPROFITSEGMENT =

POACCOUNTX = P_GT_BAPIMEPOACCOUNTX

  • POCONDHEADER =

  • POCONDHEADERX =

POCOND = P_GT_BAPIMEPOCOND

POCONDX = P_GT_BAPIMEPOCONDX

  • POLIMITS = P_GT_BAPIMEPOLIMITS

  • POCONTRACTLIMITS = P_GT_BAPIMEPOCONTRACTLIMITS

POSERVICES = P_GT_BAPIMEPOSERVICES

POSRVACCESSVALUES = P_GT_BAPIMEPOSRVACCESSVALUES

  • POSERVICESTEXT =

  • EXTENSIONIN =

  • EXTENSIONOUT =

  • POEXPIMPITEM =

  • POEXPIMPITEMX =

  • POTEXTHEADER =

  • POTEXTITEM =

  • ALLVERSIONS =

  • POPARTNER =

  • POCOMPONENTS =

  • POCOMPONENTSX =

  • POSHIPPING =

  • POSHIPPINGX =

  • POSHIPPINGEXP =

  • SERIALNUMBER =

  • SERIALNUMBERX =

  • INVPLANHEADER =

  • INVPLANHEADERX =

  • INVPLANITEM =

  • INVPLANITEMX =

.

ENDFORM. " Z_CALL_BAPI*

0 Kudos
218

Hi,

W.r.t. to the code, I presume you are passing the PR reference to the Call Function. Hence, I believe the BAPI will determine pricing and account assignment automatically. That means, even if you pass the net price, preference is to the reference. I would recommend you to confirm with the Functional Consultant whether the Contract Price is as per the PR configuration for confirmation.

To pass it on using code you will have to remove the references and pass the Pricing parameters/conditions to the BAPI for full control.

Regards,

Pranav.

0 Kudos
218

Hi Pranav, the functional said the net_price should be maintained. How do I remove the references of the contract?

Edited by: luisfel28 on Sep 9, 2011 6:39 PM

0 Kudos
218

Hi,

I'm sorry, that I don't have a sample code. You can try the following hints. It will take you sometime to write a code for this, but, should be fun doing it.

1. If you want to pass the data, then remove the PR reference from the item table parameter.

2. If the user is willing to maintain an RFQ for the said PO, then, ideally the RFQ should be maintained and RFQ's reference will be the best reference to create the PO with the NET Price as required.

3. Before writing the code, I would recommend you to test the BAPI via T. Code SE37. Pass the parameters and save the variant. On successful result, pass the parameters used in the variant.

Regards,

Pranav.

0 Kudos
218

Pranav, solved!!

Change my l_bapimepocond-cond_type at PB00 for PBXX and worked!!

Tks!!!