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_INCOMINGINVOICE_CREATE multiple Account assignment problem

Former Member
0 Kudos

Hi Friends,

I am using BAPI: BAPI_INCOMINGINVOICE_CREATE to create Invoice for respective service entry sheet of Purchase order.

In PO level I am having multiple account assignments, So while creating invoice I need to handle this in BAPI, can you help to populate the revalent data for account assignment,.

Code: for account asignment in BAPI

LOOP AT t_po_item.

  • Populate payable invoice items with service entry sheet

w_gross = w_gross + t_po_item-zpinamt.

li_item_pay-invoice_doc_item = li_item_pay-invoice_doc_item + 1.

li_item_pay-po_number = t_po_item-ebeln.

li_item_pay-po_item = t_po_item-ebelp.

li_item_pay-item_amount = t_po_item-zpinamt.

li_item_pay-sheet_no = t_po_item-lblni. " service entry sheet

APPEND li_item_pay.

  • Populate retainage invoice items with service entry sheet

w_ret_gross = w_ret_gross + t_po_item-zrtamt.

li_item_ret-invoice_doc_item = li_item_ret-invoice_doc_item + 1.

li_item_ret-po_number = t_po_item-ebeln.

li_item_ret-po_item = t_po_item-ebelp.

li_item_ret-item_amount = t_po_item-zrtamt.

li_item_ret-sheet_no = t_po_item-lblni. " service entry sheet

APPEND li_item_ret.

  • Get the details with ref to service entry sheet

CALL FUNCTION 'BAPI_ENTRYSHEET_GETDETAIL'

EXPORTING

entrysheet = t_po_item-lblni

  • LONG_TEXTS = ' '

  • IMPORTING

  • ENTRYSHEET_HEADER =

TABLES

entrysheet_account_assignment = lit_po_acct

entrysheet_services = lit_serpo_acc

entrysheet_srv_accass_values = lit_ser_acc.

lv_act_item = lv_act_item + 1.

LOOP AT lit_po_acct.

  • populate the account asignment data for Payable Invoice

IF NOT lit_po_acct-accass_val IS INITIAL.

lit_pay_acct_asgn-invoice_doc_item = lv_act_item.

lit_pay_acct_asgn-serial_no = lit_pay_acct_asgn-serial_no + 1.

lit_pay_acct_asgn-item_amount = ( t_po_item-zpinamt * lit_po_acct-PERCENTAGE ) / 100. " pass the amount at PO retainge level

lit_pay_acct_asgn-profit_ctr = lit_po_acct-profit_ctr.

lit_pay_acct_asgn-co_area = lit_po_acct-co_area.

lit_pay_acct_asgn-network = lit_po_acct-network.

lit_pay_acct_asgn-activity = t_po_item-vornr.

lit_pay_acct_asgn-CMMT_ITEM = lit_po_acct-cmmt_item_long.

  • lit_pay_acct_asgn-CMMT_ITEM_LONG = lit_po_acct-cmmt_item_long.

lit_pay_acct_asgn-gl_account = lit_po_acct-gl_account.

lit_pay_acct_asgn-tax_code = lit_po_acct-tax_code.

lit_pay_acct_asgn-costcenter = lit_po_acct-costcenter.

APPEND lit_pay_acct_asgn.

ENDIF.

ENDLOOP.

ENDLOOP.

Thanks,

Veerendra.

5 REPLIES 5

Former Member
0 Kudos

Hi

See the sample code for the same BAPI and modify accordingly

REPORT z_yaktest3 NO STANDARD PAGE HEADING MESSAGE-ID zi455.

*----


  • Internal table declaration *

----


DATA: gt_headerdata TYPE STANDARD TABLE OF bapi_incinv_create_header

INITIAL SIZE 0,

gt_itemdata TYPE STANDARD TABLE OF bapi_incinv_create_item

INITIAL SIZE 0,

gt_accountingdata TYPE STANDARD TABLE OF bapi_incinv_create_account

INITIAL SIZE 0,

gt_return TYPE STANDARD TABLE OF bapiret2

INITIAL SIZE 0.

DATA: gs_headerdata LIKE bapi_incinv_create_header.

DATA: gs_itemdata LIKE bapi_incinv_create_item.

DATA: gs_accountingdata TYPE bapi_incinv_create_account.

DATA: gs_return TYPE bapiret2.

DATA: l_date TYPE sy-datum.

l_date = sy-datum - 15.

  • Error flag *

DATA: l_errflag(1) TYPE c.

*----


  • Build Invoice header

*----


  • Document Type (Invoice)

gs_headerdata-invoice_ind = 'X'.

gs_headerdata-doc_type = 51.

  • Document Date

gs_headerdata-doc_date = l_date.

  • Posting Date

gs_headerdata-pstng_date = l_date.

  • Reference Document No

gs_headerdata-ref_doc_no = 323348.

gs_headerdata-gross_amount = 31.

  • Currency

gs_headerdata-currency = 'USD'.

  • Company Code

gs_headerdata-comp_code = 'D3'.

    • Baseline Date

gs_headerdata-bline_date = l_date.

*

**Tax Indicator

*gs_headerdata-calc_tax_ind = 'X'.

*----


  • Build order item(s) - Only 1 is used in this example

*----


  • Document Item

gs_itemdata-invoice_doc_item = 000001.

  • Purchase Order Number

gs_itemdata-po_number = 3700000011.

  • Purchase Order Item

gs_itemdata-po_item = 00010.

  • Quantity

gs_itemdata-quantity = 31.

gs_itemdata-po_unit = 'Z00'.

  • Item Amount

gs_itemdata-item_amount = 31.

gs_itemdata-tax_code = 'O0'.

gs_itemdata-taxjurcode = '0100000000'.

APPEND gs_itemdata TO gt_itemdata.

    • Document Item

*gs_itemdata-invoice_doc_item = '00002'.

*

    • Purchase Order Number

*gs_itemdata-po_number = '4700000158'.

*

    • Purchase Order Item

*gs_itemdata-po_item ='00020' .

*

    • Quantity

*gs_itemdata-quantity = '5'.

*gs_itemdata-po_unit = 'Z00'.

*

    • Item Amount

*gs_itemdata-item_amount = '5'.

*gs_itemdata-tax_code = 'O0'.

*gs_itemdata-taxjurcode = '0100000000'.

*

*APPEND gs_itemdata TO gt_itemdata.

*

  • Accounting Data

***gs_accountingdata-costcenter = 'DUMMY CCTR'.

*gs_accountingdata-invoice_doc_item = '00001'.

*gs_accountingdata-xunpl = 'X'.

*gs_accountingdata-tax_code = 'O0'.

*gs_accountingdata-taxjurcode = '0100000000'.

*gs_accountingdata-ITEM_AMOUNT = 100.

*gs_accountingdata-gl_account = '0003805101'.

*

*APPEND gs_accountingdata TO gt_accountingdata.

*CLEAR :gs_accountingdata.

*Call the BAPI to Create the Return Order

data: gv_INVOICE type BAPI_INCINV_FLD-INV_DOC_NO,

gv_YEAR type BAPI_INCINV_FLD-FISC_YEAR.

CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'

EXPORTING

headerdata = gs_headerdata

IMPORTING

INVOICEDOCNUMBER = gv_INVOICE

FISCALYEAR = gv_YEAR

TABLES

return = gt_return

itemdata = gt_itemdata.

  • accountingdata = gt_accountingdata.

PERFORM error.

*----


  • Check and write Return table

*----


FORM error.

LEAVE TO LIST-PROCESSING.

CLEAR l_errflag.

LOOP AT gt_return INTO gs_return.

WRITE: / gs_return-type, gs_return-message(200).

IF gs_return-type = 'E'.

l_errflag = 'X'.

ENDIF.

ENDLOOP.

PERFORM commit.

ENDFORM. " ERROR INPUT

*----


  • No errors - Commit

*----


FORM commit.

IF l_errflag IS INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDIF.

ENDFORM. " COMMIT INPUT

Reward points if useful

Regards

Anji

0 Kudos

Hi Anji Thanks for the reply,

Here I am having the situation like,

In Item level: invoice item 00001 PO 4500001223 item 10 amounut 175

So this invoice item 00001 got two account assignments

1. G/L account 655646 amount 150

2. G/L account 655022 amount 175.

In this case I am passing account assignment data with 2 rows and sequential number is 1 and 2. also passing proficentre , cost centre, tax code.

PLease tell me if anything else is required.

Thanks,

Veerendra.

0 Kudos

sorry anji in account assignment small correction in my last reply,

So this invoice item 00001 got two account assignments

1. G/L account 655646 amount 150

2. G/L account 655022 amount 25.

thanks

0 Kudos

Good morning!

Someone knows how to fill the table BAPI_INCINV_CREATE_ACCOUNT this BAPI when the purchase order is charging for Class Cost (knttp = K) and distribution amounts (vrtkz = 1).

I am having trouble as fill in terms of units and amount as I cast the error "The invoiced amount is higher than the amount MS"

Thanks for your support!

===========

Buenos Días!!!

Alguien sabe como llenar la tabla BAPI_INCINV_CREATE_ACCOUNT de esta BAPI cuando la Orden de Compra tiene imputación por Clase Coste (knttp = K) y distribución por cantidades ( vrtkz = 1).

Estoy teniendo problemas como llenarla en cuanto a unidades e importes ya que me arroja el error que "La cantidad facturada es superior a la cantidad EM'

Gracias por su apoyo!!

================

0 Kudos

Hi there

I know its been years since you asked the question however the manner in which to do this is to allow for unplanned account assignment, the shortfall of this process is that you will not be able to add text on each line item.

Unplanned account assignment from Invoice Verification (field XUNPL) or sequential number of account assignment (field SERIAL_NO)

Example of entries:

A purchase order item has three account assignments.

You want to change the current account assignment:

Enter ' ' in the field XUNPL and the lines that you want to change in the field SERIAL_NO, for example '2'.

You want to add an unplanned account assignment:

Enter 'X' in the field XUNPL and leave the field SERIAL_NO blank.

Regards

Tatenda