‎2014 Oct 10 2:41 PM
Hi guys,
I'm facing the follow error when I'm trying to create a PO using BAPI_PO_CREATE1:
MESSAGE e436(06)
"In case of account assignment, please enter acc. assignment data for item"
Does anyone could help me?
REPORT z103 NO STANDARD PAGE HEADING.
*----------------------------------------------------------------------
TYPE-POOLS: abap.
TYPES:
BEGIN OF ty_representante,
lifnr TYPE lfa1-lifnr ,
END OF ty_representante .
DATA: t_representante TYPE STANDARD TABLE OF ty_representante,
w_representante LIKE LINE OF t_representante.
w_representante-lifnr = '200020'.
APPEND w_representante TO t_representante.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* Tabelas Internas *
*----------------------------------------------------------------------*
DATA:
t_item TYPE STANDARD TABLE OF bapimepoitem ,
t_itemx TYPE STANDARD TABLE OF bapimepoitemx ,
t_divisao_remessa TYPE STANDARD TABLE OF bapimeposchedule,
t_divisao_remessax TYPE STANDARD TABLE OF bapimeposchedulx,
t_cl_contabil TYPE STANDARD TABLE OF bapimepoaccount ,
t_cl_contabilx TYPE STANDARD TABLE OF bapimepoaccountx,
t_limite TYPE STANDARD TABLE OF bapiesuhc ,
t_servico TYPE STANDARD TABLE OF bapiesllc ,
t_cl_ctb_servico TYPE STANDARD TABLE OF bapiesklc ,
t_bapi_return TYPE STANDARD TABLE OF bapiret2 .
*----------------------------------------------------------------------*
* Work-Areas / Field-Symbols *
*----------------------------------------------------------------------*
DATA:
w_cabecalho TYPE bapimepoheader ,
w_cabecalhox TYPE bapimepoheaderx ,
w_item LIKE LINE OF t_item ,
w_itemx LIKE LINE OF t_itemx ,
w_divisao_remessa LIKE LINE OF t_divisao_remessa ,
w_divisao_remessax LIKE LINE OF t_divisao_remessax,
w_cl_contabil LIKE LINE OF t_cl_contabil ,
w_cl_contabilx LIKE LINE OF t_cl_contabilx ,
w_limite LIKE LINE OF t_limite ,
w_servico LIKE LINE OF t_servico ,
w_cl_ctb_servico LIKE LINE OF t_cl_ctb_servico ,
w_bapi_return LIKE LINE OF t_bapi_return .
*----------------------------------------------------------------------*
* Variáveis *
*----------------------------------------------------------------------*
DATA:
v_nro_pedido_compras TYPE bapimepoheader-po_number,
v_nro_pacote TYPE bapiesllc-pckg_no ,
v_short_text TYPE bapiesllc-short_text ,
v_base_uom TYPE bapiesllc-base_uom ,
v_base_uom1 TYPE mara-meins .
*----------------------------------------------------------------------*
* Constantes *
*----------------------------------------------------------------------*
CONSTANTS:
c_item TYPE ebelp VALUE 00010 ,
c_gnatus_matriz TYPE t001w-werks VALUE '0050' ,
c_gnatus_empresa TYPE t001-bukrs VALUE '0050' ,
c_gnatus_grupo TYPE t024e-ekorg VALUE '0050' ,
c_gnatus_divisao TYPE tgsb-gsber VALUE '1000' ,
c_felipe_zimmerman TYPE t024-ekgrp VALUE '001' ,
c_centro_custos_ctag TYPE csks-kostl VALUE '0000404140' ,
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_comissao_vendas TYPE txz01 VALUE 'Comissão Vendas' ,
c_servicos TYPE t023-matkl VALUE 'SE13' ,
c_pedido_normal TYPE t161-bsart VALUE 'NB' ,
c_comissao_sobre_vendas TYPE ska1-saknr VALUE '0000111000' ,
c_servico_comissao TYPE asmd-asnum VALUE '000000000003000000',
c_nro_seq_cl_ctb TYPE dzekkn VALUE 1 .
*----------------------------------------------------------------------*
* InÃcio *
*----------------------------------------------------------------------*
LOOP AT t_representante INTO w_representante.
FREE:
t_bapi_return, t_item, t_itemx, t_divisao_remessa,
t_divisao_remessax, t_cl_contabil, t_cl_contabilx,
t_limite, t_servico, t_cl_ctb_servico.
CLEAR v_nro_pacote.
* Linhas do pacote de serviços
SELECT MAX( packno )
FROM esll
INTO v_nro_pacote.
v_nro_pacote = v_nro_pacote + 1.
*----------------------------------------------------------------------*
* Pedido dds.cabeçalho
*----------------------------------------------------------------------*
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = w_representante-lifnr
IMPORTING
output = w_representante-lifnr.
CLEAR w_cabecalho .
w_cabecalho-doc_type = c_pedido_normal .
w_cabecalho-vendor = w_representante-lifnr.
w_cabecalho-comp_code = c_gnatus_empresa .
w_cabecalho-purch_org = c_gnatus_grupo .
w_cabecalho-pur_group = c_felipe_zimmerman .
w_cabecalho-doc_date = sy-datum .
w_cabecalho-currency = c_br_real .
w_cabecalho-incoterms1 = c_custo_seguro_frete .
*----------------------------------------------------------------------*
* bapimepoheaderx
*----------------------------------------------------------------------*
CLEAR w_cabecalhox .
w_cabecalhox-doc_type = abap_true.
w_cabecalhox-doc_date = abap_true.
w_cabecalhox-incoterms1 = abap_true.
w_cabecalhox-vendor = abap_true.
w_cabecalhox-currency = abap_true.
w_cabecalhox-comp_code = abap_true.
w_cabecalhox-purch_org = abap_true.
w_cabecalhox-pur_group = abap_true.
*----------------------------------------------------------------------*
* bapimepoitem
*----------------------------------------------------------------------*
CLEAR w_item .
w_item-po_item = c_item .
w_item-plant = c_gnatus_matriz .
w_item-quantity = c_qtd_pedido .
w_item-po_unit = c_unidade_medida_ua.
w_item-net_price = c_preco_liquido .
w_item-po_price = c_preco_bruto .
w_item-tax_code = c_iva_servico .
w_item-acctasscat = c_centro_custos .
w_item-item_cat = c_prestacao_servico.
w_item-short_text = c_comissao_vendas .
w_item-matl_group = c_servicos .
w_item-pckg_no = v_nro_pacote .
APPEND w_item TO t_item .
*----------------------------------------------------------------------*
* bapimepoitemx
*----------------------------------------------------------------------*
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 .
*----------------------------------------------------------------------*
* bapimeposchedule
*----------------------------------------------------------------------*
CLEAR w_divisao_remessa .
w_divisao_remessa-po_item = c_item .
w_divisao_remessa-delivery_date = sy-datum .
APPEND w_divisao_remessa TO t_divisao_remessa.
*----------------------------------------------------------------------*
* bapimeposchedulx
*----------------------------------------------------------------------*
CLEAR w_divisao_remessax .
w_divisao_remessax-po_item = c_item .
w_divisao_remessax-delivery_date = abap_true .
APPEND w_divisao_remessax TO t_divisao_remessax.
*----------------------------------------------------------------------*
* bapimepoaccount
*----------------------------------------------------------------------*
CLEAR w_cl_contabil .
w_cl_contabil-po_item = c_item .
w_cl_contabil-serial_no = c_nro_seq_cl_ctb .
w_cl_contabil-creat_date = sy-datum .
w_cl_contabil-quantity = c_qtd_pedido .
w_cl_contabil-gl_account = c_comissao_sobre_vendas.
w_cl_contabil-costcenter = c_centro_custos_ctag .
APPEND w_cl_contabil TO t_cl_contabil .
*----------------------------------------------------------------------*
* bapimepoaccountx
*----------------------------------------------------------------------*
CLEAR w_cl_contabilx .
w_cl_contabilx-po_item = c_item .
w_cl_contabilx-serial_no = c_nro_seq_cl_ctb.
w_cl_contabilx-creat_date = abap_true .
w_cl_contabilx-quantity = abap_true .
w_cl_contabilx-gl_account = abap_true .
w_cl_contabilx-costcenter = abap_true .
APPEND w_cl_contabilx TO t_cl_contabilx .
*----------------------------------------------------------------------*
* bapiesuhc
*----------------------------------------------------------------------*
CLEAR w_limite .
w_limite-pckg_no = v_nro_pacote. " Nº pacote
APPEND w_limite TO t_limite .
*----------------------------------------------------------------------*
* bapiesllc
*----------------------------------------------------------------------*
CLEAR w_servico .
w_servico-pckg_no = v_nro_pacote .
w_servico-ext_line = c_item .
w_servico-line_no = c_item .
w_servico-service = c_servico_comissao .
w_servico-gr_price = c_preco_bruto .
w_servico-quantity = c_qtd_pedido .
w_servico-base_uom = c_unidade_medida_ua.
APPEND w_servico TO t_servico .
*----------------------------------------------------------------------*
* bapiesklc
*----------------------------------------------------------------------*
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
EXPORTING
input = w_servico-base_uom
language = sy-langu
IMPORTING
output = v_base_uom1
EXCEPTIONS
OTHERS = 2.
IF v_base_uom1 IS INITIAL.
v_base_uom = w_servico-base_uom.
ELSE.
v_base_uom = v_base_uom1.
ENDIF.
CLEAR w_cl_ctb_servico .
w_cl_ctb_servico-pckg_no = v_nro_pacote .
w_cl_ctb_servico-line_no = c_item .
w_cl_ctb_servico-serno_line = c_nro_seq_cl_ctb.
w_cl_ctb_servico-quantity = c_qtd_pedido .
w_cl_ctb_servico-serial_no = c_nro_seq_cl_ctb.
APPEND w_cl_ctb_servico TO t_cl_ctb_servico .
*----------------------------------------------------------------------*
* Criar pedido de compras - T-CODE ME21N
*----------------------------------------------------------------------*
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = w_cabecalho
poheaderx = w_cabecalhox
IMPORTING
exppurchaseorder = v_nro_pedido_compras
TABLES
return = t_bapi_return
poitem = t_item
poitemx = t_itemx
poschedule = t_divisao_remessa
poschedulex = t_divisao_remessax
poaccount = t_cl_contabil
poaccountx = t_cl_contabilx
polimits = t_limite
poservices = t_servico
posrvaccessvalues = t_cl_ctb_servico.
IF v_nro_pedido_compras IS NOT INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true.
ELSE.
LOOP AT t_bapi_return INTO w_bapi_return.
WRITE: / w_bapi_return-message.
ENDLOOP.
ENDIF.
ENDLOOP.
‎2014 Oct 10 3:08 PM
Hi,
PLease check whether the Item categroy 'D' is maintained?
I can see the message in include FBGENMAC. Please put a break Point in the include and check whether it helps.
Regards,
K.S
‎2014 Oct 10 3:08 PM
Hi,
PLease check whether the Item categroy 'D' is maintained?
I can see the message in include FBGENMAC. Please put a break Point in the include and check whether it helps.
Regards,
K.S
‎2014 Oct 10 4:04 PM
Thanks, K.S but I couldn't insert a break point in this include, FBGENMAC because I didn't find SAPLMEPO in choosen list.
When I debugged the BAPI, I found the message in LMEPOF2B include:
It's weird...
Any suggestion?
‎2014 Oct 10 7:34 PM
Thiago, hope that this note solve your problem 1373051 - BAPI_PO_CREATE1 returns error msg. 06 436 for service item
If not, are you able to do the process via ME21N?
Regards,
Felipe
‎2014 Oct 10 7:57 PM
Thank you very much, Felipe, but this note can't be implemented in our system:
The functional made me a PO using ME21N and send me some prints. It's working via T-CODE
So crazy...
Any other suggestion?
‎2014 Oct 10 8:07 PM
‎2014 Oct 10 8:41 PM
There is something wrong in the first link, the guy who did CTRL + C , CTRL + V made it wrong... everything is with strange chars like "u20180000000003u2019".
The second one is the same, but with correct characters...!
Thank you very much, Felipe, it worked...!