10-11-2014 3:22 AM
Hi,
I have a problem to create a PO using BAPI_PO_CREATE1. I fill the field net price from item, but it doesn't fill the value right (it always fill with 1)
I found this note,and I tried but still doesn't working...
1899549 - BAPI_PO_CREATE1 : Net price is not taken from input data in POITEM-NET_PRICE
There is these information in this note:
Cause
There is no price in the info record (for example, EUR) for PO currency (for example, JPY).
When PO_PRICE = '1', system will try to find an entry in the info record with the PO currency (for example, JPY) first. If there is no entry (for
example, with currency JPY) in the info record, system will not consider the price from POITEM
NET_PRICE, but take the value from info record (for
example, currency EUR) and convert it into PO currency (for example, JPY).
Resolution
Option 1
Set PO_PRICE as "2".
Option 2
Input value in POCOND and POCONDX to update the net price
Does anyone have any suggestion?
10-12-2014 2:53 PM
Hi
Assuming that your are passing the net price as input in the BAPI data source.
You need to set the following:
Step 1
In the bapi table structure filling.. use as follows:
PURITEM-NET_PRICE = wa_datafeed-netpr.
APPEND PURITEM.
PURITEMX-NET_PRICE = 'X'.
APPEND PURITEMX.
Step 2
In call function of BAPI, pass the flag as NO_PRICE_FROM_PO
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = PO_HEADER
POHEADERX = PO_HEADERX
NO_PRICE_FROM_PO = 'X'
Then it will take the value you pass and does not calculate as its own.
Regards,
venkat
10-12-2014 3:05 PM
Hello,
I did it but still not working... Do you have any other suggestion?
10-12-2014 3:08 PM
It should work..
I faced the same problem.
After doing the above step, i resolved it.
can you paste the input value spcified and your code.
10-12-2014 3:22 PM
Yeah, it's strange
Look:
REPORT z1 NO STANDARD PAGE HEADING.
TYPE-POOLS: abap.
*----------------------------------------------------------------------*
* Tabelas Internas *
*----------------------------------------------------------------------*
DATA:
t_item TYPE STANDARD TABLE OF bapimepoitem ,
t_itemx TYPE STANDARD TABLE OF bapimepoitemx ,
t_schedule TYPE STANDARD TABLE OF bapimeposchedule,
t_schedulex TYPE STANDARD TABLE OF bapimeposchedulx,
t_account TYPE STANDARD TABLE OF bapimepoaccount ,
t_accountx TYPE STANDARD TABLE OF bapimepoaccountx,
t_limite TYPE STANDARD TABLE OF bapiesuhc ,
t_servico TYPE STANDARD TABLE OF bapiesllc ,
t_cond TYPE STANDARD TABLE OF bapimepocond ,
t_condx TYPE STANDARD TABLE OF bapimepocondx ,
t_esklc TYPE STANDARD TABLE OF bapiesklc ,
t_bapiret2 TYPE STANDARD TABLE OF bapiret2 .
*----------------------------------------------------------------------*
* Work-Areas / Field-Symbols *
*----------------------------------------------------------------------*
DATA:
w_header TYPE bapimepoheader ,
w_headerx TYPE bapimepoheaderx ,
w_item LIKE LINE OF t_item ,
w_itemx LIKE LINE OF t_itemx ,
w_schedule LIKE LINE OF t_schedule ,
w_schedulex LIKE LINE OF t_schedulex,
w_account LIKE LINE OF t_account ,
w_accountx LIKE LINE OF t_accountx ,
w_limite LIKE LINE OF t_limite ,
w_servico LIKE LINE OF t_servico ,
w_cond LIKE LINE OF t_cond ,
w_condx LIKE LINE OF t_condx ,
w_esklc LIKE LINE OF t_esklc ,
w_bapiret2 LIKE LINE OF t_bapiret2 .
*----------------------------------------------------------------------*
* Constantes *
*----------------------------------------------------------------------*
CONSTANTS:
c_item TYPE ebelp VALUE 00010 ,
c_gnatus_matriz TYPE t001w-werks VALUE '1000' ,
c_gnatus_empresa TYPE t001-bukrs VALUE '1000' ,
c_gnatus_grupo TYPE t024e-ekorg VALUE '1000' ,
c_felipe_zimmerman TYPE t024-ekgrp VALUE '100' ,
c_centro_custos_ctag TYPE csks-kostl VALUE '0000104405' ,
c_br_real TYPE tcurc-waers VALUE 'BRL' ,
c_custo_seguro_frete TYPE tinc-inco1 VALUE 'CIF' ,
c_qtd_pedido TYPE bstmg VALUE 1 ,
c_unidade_medida_ua TYPE t006-msehi VALUE 'UA' ,
c_preco_liquido TYPE bapicurext VALUE 1 ,
c_preco_bruto TYPE bpueb VALUE '1' ,
c_iva_servico TYPE t007a-mwskz VALUE 'SV' ,
c_centro_custos TYPE t163k-knttp VALUE 'K' ,
c_prestacao_servico TYPE t163-pstyp VALUE 'D' ,
c_dsc_item TYPE txz01 VALUE 'Comissão Vendas' ,
c_dsc_servico TYPE txz01 VALUE 'Serviço 1' ,
c_grp_merc_servicos TYPE t023-matkl VALUE 'YBSVS1' ,
c_pedido_normal TYPE t161-bsart VALUE 'NB' ,
c_comissao_sobre_vendas TYPE ska1-saknr VALUE '0032207001' ,
c_servico_comissao TYPE asmd-asnum VALUE '000000000003000151',
c_nro_pacote_l1 TYPE packno VALUE '0000000001' ,
c_nro_pacote_l3 TYPE packno VALUE '0000000003' ,
c_nro_linha_l1 TYPE srv_line_no VALUE '0000000001' ,
c_nro_linha_l2 TYPE srv_line_no VALUE '0000000002' ,
c_nro_subpacote_l1 TYPE sub_packno VALUE '0000000003' ,
c_nro_seq_cl_ctb TYPE dzekkn VALUE 1 ,
c_nro_seq_linha_servico TYPE numkn VALUE 1 .
*----------------------------------------------------------------------*
* Pedido dds.cabeçalho
*----------------------------------------------------------------------*
DATA: v_fornecedor TYPE lfa1-lifnr.
v_fornecedor = '1000391'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_fornecedor
IMPORTING
output = v_fornecedor.
CLEAR w_header .
w_header-doc_type = c_pedido_normal . " (NB)
w_header-vendor = v_fornecedor . "
w_header-comp_code = c_gnatus_empresa . " (1000)
w_header-purch_org = c_gnatus_grupo . " (1000)
w_header-pur_group = c_felipe_zimmerman . " (100)
w_header-doc_date = sy-datum . "
w_header-currency = c_br_real . " (BRL)
w_header-incoterms1 = c_custo_seguro_frete . " (CIF)
*----------------------------------------------------------------------*
* Dados do cabeçalho do pedido (barra de modificação)
*----------------------------------------------------------------------*
CLEAR w_headerx .
w_headerx-doc_type = abap_true.
w_headerx-doc_date = abap_true.
w_headerx-incoterms1 = abap_true.
w_headerx-vendor = abap_true.
w_headerx-currency = abap_true.
w_headerx-comp_code = abap_true.
w_headerx-purch_org = abap_true.
w_headerx-pur_group = abap_true.
*----------------------------------------------------------------------*
* Item do pedido
*----------------------------------------------------------------------*
DATA: v_preco_liquido TYPE lips-netpr.
v_preco_liquido = '123.45'.
CLEAR w_item .
w_item-po_item = c_item . " (00010)
w_item-plant = c_gnatus_matriz . " (1000)
w_item-quantity = c_qtd_pedido . " (1)
w_item-po_unit = c_unidade_medida_ua. " (UA)
w_item-net_price = v_preco_liquido . " (1)
w_item-po_price = '1' . " (1)
w_item-tax_code = c_iva_servico . " (SV)
w_item-acctasscat = c_centro_custos . " (K)
w_item-item_cat = c_prestacao_servico. " (D)
w_item-short_text = c_dsc_item . " (COMISSÃO VENDAS)
w_item-matl_group = c_grp_merc_servicos. " (YBSVS1).
w_item-pckg_no = c_nro_pacote_l1 . "
* w_item-calctype = 'B' .
APPEND w_item TO t_item . " BAPIMEPOITEM
*----------------------------------------------------------------------*
* Dados do item do pedido (barra de modificação)
*----------------------------------------------------------------------*
CLEAR w_itemx .
w_itemx-po_item = c_item .
w_itemx-plant = abap_true.
w_itemx-quantity = abap_true.
w_itemx-po_unit = abap_true.
w_itemx-net_price = abap_true.
w_itemx-po_price = abap_true.
w_itemx-tax_code = abap_true.
w_itemx-acctasscat = abap_true.
w_itemx-item_cat = abap_true.
w_itemx-short_text = abap_true.
w_itemx-matl_group = abap_true.
w_itemx-pckg_no = abap_true.
APPEND w_itemx TO t_itemx . " BAPIMEPOITEMX
*----------------------------------------------------------------------*
* Campos para divisões de remessa do pedido
*----------------------------------------------------------------------*
CLEAR w_schedule .
w_schedule-po_item = c_item .
w_schedule-delivery_date = sy-datum .
APPEND w_schedule TO t_schedule. " BAPIMEPOSCHEDULE
*----------------------------------------------------------------------*
* Campos p/divisões de remessa do pedido (barra modificação)
*----------------------------------------------------------------------*
CLEAR w_schedulex .
w_schedulex-po_item = c_item .
w_schedulex-delivery_date = abap_true .
APPEND w_schedulex TO t_schedulex. " BAPIMEPOACCOUNT
*----------------------------------------------------------------------*
* Campos de classificação contábil do pedido
*----------------------------------------------------------------------*
CLEAR w_account .
w_account-po_item = c_item . " (00010)
w_account-serial_no = c_nro_seq_cl_ctb . " (1)
w_account-creat_date = sy-datum . "
w_account-quantity = c_qtd_pedido . " (1)
w_account-gl_account = c_comissao_sobre_vendas. " (32207001)
w_account-costcenter = c_centro_custos_ctag . " (104405)
APPEND w_account TO t_account . " BAPIMEPOACCOUNT
*----------------------------------------------------------------------*
* Campos de classif.contábil do pedido (barra modificação)
*----------------------------------------------------------------------*
CLEAR w_accountx .
w_accountx-po_item = c_item .
w_accountx-serial_no = c_nro_seq_cl_ctb.
w_accountx-creat_date = abap_true .
w_accountx-quantity = abap_true .
w_accountx-gl_account = abap_true .
w_accountx-costcenter = abap_true .
APPEND w_accountx TO t_accountx . " BAPIMEPOACCOUNTX
*----------------------------------------------------------------------*
* Estrutura de comunicação limites
*----------------------------------------------------------------------*
CLEAR w_limite .
w_limite-pckg_no = c_nro_pacote_l1. " (0000000001)
APPEND w_limite TO t_limite . " BAPIESUHC
*----------------------------------------------------------------------*
* Linha de serviços
*----------------------------------------------------------------------*
w_servico-pckg_no = c_nro_pacote_l1 . " (0000000001)
w_servico-line_no = c_nro_linha_l1 . " (0000000001)
w_servico-outl_ind = abap_true . "
w_servico-subpckg_no = c_nro_subpacote_l1 . " (0000000003)
w_servico-quantity = c_qtd_pedido . " (1.00)
w_servico-base_uom = c_unidade_medida_ua. " (UA)
w_servico-price_unit = c_qtd_pedido . " (1)
w_servico-gr_price = c_preco_bruto . " (1)
APPEND w_servico TO t_servico . " BAPIESLLC
w_servico-pckg_no = c_nro_pacote_l3 . " (0000000003)
w_servico-line_no = c_nro_linha_l2 . " (0000000002)
w_servico-quantity = c_qtd_pedido . " (1.00)
w_servico-base_uom = c_unidade_medida_ua. " (UA)
w_servico-price_unit = c_qtd_pedido . " (1.00)
w_servico-gr_price = c_preco_bruto . " (1)
w_servico-matl_group = c_grp_merc_servicos. " (YBSVS1)
w_servico-service = c_servico_comissao . " (000000000003000151)
APPEND w_servico TO t_servico . " BAPIESLLC
*----------------------------------------------------------------------*
* Estrut.comunicação criar distrib.class.cont.linha serviço
*----------------------------------------------------------------------*
CLEAR w_esklc .
w_esklc-pckg_no = c_nro_pacote_l3 . " (0000000003)
w_esklc-line_no = c_nro_linha_l2 . " (0000000002)
w_esklc-serno_line = c_nro_seq_linha_servico. " (01)
w_esklc-serial_no = c_nro_seq_cl_ctb . " (01)
w_esklc-quantity = c_qtd_pedido . " (1.00)
APPEND w_esklc TO t_esklc . " BAPIESKLC
*----------------------------------------------------------------------*
* Criar pedido de compras - T-CODE ME21N
*----------------------------------------------------------------------*
DATA:
v_nro_pedido_compras TYPE bapimepoheader-po_number.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = w_header
poheaderx = w_headerx
no_price_from_po = abap_true
IMPORTING
exppurchaseorder = v_nro_pedido_compras
TABLES
return = t_bapiret2
poitem = t_item
poitemx = t_itemx
poschedule = t_schedule
poschedulex = t_schedulex
poaccount = t_account
poaccountx = t_accountx
pocond = t_cond
pocondx = t_condx
polimits = t_limite
poservices = t_servico
posrvaccessvalues = t_esklc.
IF v_nro_pedido_compras IS NOT INITIAL.
WRITE: v_nro_pedido_compras.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true.
ENDIF.
10-12-2014 6:02 PM
Hi Thiago, have you tried both options from the note that you mentioned?
Option 1
Set PO_PRICE as "2".
Option 2
Input value in POCOND and POCONDX to update the net price
In your code price has SO_PRICE as '1'.
Regards,
Felipe
10-12-2014 11:15 PM
10-12-2014 11:59 PM
What happens when you try both of the options from the note? In particular what happens when you actually fill the condition record tables? What is displayed in the condition record details of the created PO? I'm guess the condition records you manually pass in don't have any effect on the net price otherwise you wouldn't say it isn't working but do they show up in the condition record details as inactive?
The code you posted doesn't seem to have either of the suggestions from the note applied which makes it hard to know if there might have been some slip up while implementing those suggestions.
10-13-2014 12:27 AM
I suggest you to do the following:
w_item-po_price = '2'.
w_itemx-po_price = abap_true.
and also the fields:
w_item-calctype = 'B'.
w_itemx-calctype = abap_true
" I am not sure if the field below affects the price
w_item-price_unit = "your_field_for_price_unit"
w_itemx-price_unit = abap_true
Also take a look at 580225 - Purchasing BAPIs: Conditions and pricing
Regards,
Felipe
10-13-2014 10:22 AM
I tried and still not working:
In my test, I also filled the field "cond_value" from bapimepocond table but nothing worked. Is this field that I need to fill? I haven't found which field I need to fill...
*----------------------------------------------------------------------*
* Purchase Order Header Data
*----------------------------------------------------------------------*
DATA: v_vendor_number TYPE lfa1-lifnr.
v_vendor_number = '1000391'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = v_vendor_number
IMPORTING
output = v_vendor_number.
CLEAR w_header .
w_header-doc_type = c_pedido_normal . " (NB)
w_header-vendor = v_vendor_number . "
w_header-comp_code = c_gnatus_empresa . " (1000)
w_header-purch_org = c_gnatus_grupo . " (1000)
w_header-pur_group = c_felipe_zimmerman . " (100)
w_header-doc_date = sy-datum . "
w_header-currency = c_br_real . " (BRL)
w_header-incoterms1 = c_custo_seguro_frete . " (CIF)
*----------------------------------------------------------------------*
* Purchase Order Header Data (Change Parameter)
*----------------------------------------------------------------------*
CLEAR w_headerx .
w_headerx-doc_type = abap_true.
w_headerx-doc_date = abap_true.
w_headerx-incoterms1 = abap_true.
w_headerx-vendor = abap_true.
w_headerx-currency = abap_true.
w_headerx-comp_code = abap_true.
w_headerx-purch_org = abap_true.
w_headerx-pur_group = abap_true.
*----------------------------------------------------------------------*
* Purchase Order Item
*----------------------------------------------------------------------*
DATA: v_net_price TYPE lips-netpr.
v_net_price = '123.45'.
CLEAR w_item .
w_item-po_item = c_item . " (00010)
w_item-plant = c_gnatus_matriz . " (1000)
w_item-quantity = c_qtd_pedido . " (1)
w_item-po_unit = c_unidade_medida_ua. " (UA)
w_item-net_price = v_net_price . " (1)
w_item-po_price = '2' . " (1)
w_item-tax_code = c_iva_servico . " (SV)
w_item-acctasscat = c_centro_custos . " (K)
w_item-item_cat = c_prestacao_servico. " (D)
w_item-short_text = c_dsc_item . " (COMISSÃO VENDAS)
w_item-matl_group = c_grp_merc_servicos. " (YBSVS1).
w_item-pckg_no = c_nro_pacote_l1 . "
w_item-calctype = 'B' .
APPEND w_item TO t_item . " BAPIMEPOITEM
*----------------------------------------------------------------------*
* Purchase Order Item Data (Change Parameter)
*----------------------------------------------------------------------*
CLEAR w_itemx .
w_itemx-po_item = c_item .
w_itemx-plant = abap_true.
w_itemx-quantity = abap_true.
w_itemx-po_unit = abap_true.
w_itemx-net_price = abap_true.
w_itemx-po_price = abap_true.
w_itemx-tax_code = abap_true.
w_itemx-acctasscat = abap_true.
w_itemx-item_cat = abap_true.
w_itemx-short_text = abap_true.
w_itemx-matl_group = abap_true.
w_itemx-pckg_no = abap_true.
w_itemx-calctype = abap_true.
APPEND w_itemx TO t_itemx . " BAPIMEPOITEMX
*----------------------------------------------------------------------*
* Fields for Purchase Order Delivery Schedule Lines
*----------------------------------------------------------------------*
CLEAR w_schedule .
w_schedule-po_item = c_item .
w_schedule-delivery_date = sy-datum.
APPEND w_schedule TO t_schedule . " BAPIMEPOSCHEDULE
*----------------------------------------------------------------------*
* Fields for Schedule Lines in Purchase Order (Change Toolbar)
*----------------------------------------------------------------------*
CLEAR w_schedulex .
w_schedulex-po_item = c_item .
w_schedulex-delivery_date = abap_true.
APPEND w_schedulex TO t_schedulex . " BAPIMEPOACCOUNT
*----------------------------------------------------------------------*
* Account Assignment Fields for Purchase Order
*----------------------------------------------------------------------*
CLEAR w_account .
w_account-po_item = c_item . " (00010)
w_account-serial_no = c_nro_seq_cl_ctb . " (1)
w_account-creat_date = sy-datum . "
w_account-quantity = c_qtd_pedido . " (1)
w_account-gl_account = c_comissao_sobre_vendas. " (32207001)
w_account-costcenter = c_centro_custos_ctag . " (104405)
APPEND w_account TO t_account . " BAPIMEPOACCOUNT
*----------------------------------------------------------------------*
* Account Assignment Fields in Purchase Order (Change Toolbar)
*----------------------------------------------------------------------*
CLEAR w_accountx .
w_accountx-po_item = c_item .
w_accountx-serial_no = c_nro_seq_cl_ctb.
w_accountx-creat_date = abap_true .
w_accountx-quantity = abap_true .
w_accountx-gl_account = abap_true .
w_accountx-costcenter = abap_true .
APPEND w_accountx TO t_accountx . " BAPIMEPOACCOUNTX
*----------------------------------------------------------------------*
* Communication Structure: Limits
*----------------------------------------------------------------------*
CLEAR w_limite .
w_limite-pckg_no = c_nro_pacote_l1. " (0000000001)
APPEND w_limite TO t_limite . " BAPIESUHC
*----------------------------------------------------------------------*
* Communication Structure: Create Service Line
*----------------------------------------------------------------------*
w_servico-pckg_no = c_nro_pacote_l1 . " (0000000001)
w_servico-line_no = c_nro_linha_l1 . " (0000000001)
w_servico-outl_ind = abap_true . "
w_servico-subpckg_no = c_nro_subpacote_l1 . " (0000000003)
w_servico-quantity = c_qtd_pedido . " (1.00)
w_servico-base_uom = c_unidade_medida_ua. " (UA)
w_servico-price_unit = c_qtd_pedido . " (1)
w_servico-gr_price = c_preco_bruto . " (1)
APPEND w_servico TO t_servico . " BAPIESLLC
w_servico-pckg_no = c_nro_pacote_l3 . " (0000000003)
w_servico-line_no = c_nro_linha_l2 . " (0000000002)
w_servico-quantity = c_qtd_pedido . " (1.00)
w_servico-base_uom = c_unidade_medida_ua. " (UA)
w_servico-price_unit = c_qtd_pedido . " (1.00)
w_servico-gr_price = c_preco_bruto . " (1)
w_servico-matl_group = c_grp_merc_servicos. " (YBSVS1)
w_servico-service = c_servico_comissao . " (000000000003000151)
APPEND w_servico TO t_servico . " BAPIESLLC
*----------------------------------------------------------------------*
* Create Comm. Structure: Acct Assgt Distr. for Service Line
*----------------------------------------------------------------------*
CLEAR w_esklc .
w_esklc-pckg_no = c_nro_pacote_l3 . " (0000000003)
w_esklc-line_no = c_nro_linha_l2 . " (0000000002)
w_esklc-serno_line = c_nro_seq_linha_servico. " (01)
w_esklc-serial_no = c_nro_seq_cl_ctb . " (01)
w_esklc-quantity = c_qtd_pedido . " (1.00)
APPEND w_esklc TO t_esklc . " BAPIESKLC
**----------------------------------------------------------------------*
** Conditions in Purchase Order
**----------------------------------------------------------------------*
*w_cond-itm_number = c_item .
*w_cond-cond_value = v_net_price.
*APPEND w_cond TO t_cond . " bapimepocond
*
**----------------------------------------------------------------------*
** Change Toolbar: Conditions in Purchase Order
**----------------------------------------------------------------------*
*w_condx-itm_number = abap_true.
*w_condx-cond_value = abap_true.
*APPEND w_condx TO t_condx . " bapimepocondx
*----------------------------------------------------------------------*
* Create Purchase Order - T-CODE ME21N
*----------------------------------------------------------------------*
DATA:
v_po_number TYPE bapimepoheader-po_number.
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = w_header
poheaderx = w_headerx
no_price_from_po = abap_true
IMPORTING
exppurchaseorder = v_po_number
TABLES
return = t_bapiret2
poitem = t_item
poitemx = t_itemx
poschedule = t_schedule
poschedulex = t_schedulex
poaccount = t_account
poaccountx = t_accountx
pocond = t_cond
pocondx = t_condx
polimits = t_limite
poservices = t_servico
posrvaccessvalues = t_esklc.
IF v_po_number IS NOT INITIAL.
WRITE: v_po_number.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true.
ENDIF.
10-13-2014 5:58 PM
If you want to pass POCOND table you have to fill the following fields as described in the BAPI documentation:
- Item_Number - item number in the PO
- Cond_Value - condition value, e.g. 150,000
- Currency - currency key, e.g. USD; for percentage, please enter % in this field
- Change_ID - this field enables you to determine whether a condition is to be added (I -> insert), changed (U -> update), or deleted (D -> delete)
You just have filled two of them:
*w_cond-itm_number = c_item .
*w_cond-cond_value = v_net_price.
Regards,
Felipe
10-13-2014 6:16 PM
I don't want to fill the conditions, but I tested if I fill it could change the value but not worked
I made the worst work-around to fill the net price right:
After BAPI_PO_CREATE1 and BAPI_TRANSACTION_COMMIT , I did it:
DATA: w_ekpo TYPE ekpo.
SELECT SINGLE * FROM ekpo
INTO w_ekpo
WHERE ebeln = v_po_number.
IF sy-subrc = 0.
w_ekpo-netpr = v_net_price.
MODIFY ekpo FROM w_ekpo.
ENDIF.
I agree, it's horrible, but... worked