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: 

invoice creation through BAPI

Former Member
0 Kudos
184

Hi experts,

I want to create invoices through bapi FM, I have the data in ME23N , By this data i have to create.

So kindly tell me what are the necessary data i have to pick up and place into the

BAPI FM or tell me what i have to consider.

waiting for ur reply,

Thanks in advance.

Regards

Srinivas

1 ACCEPTED SOLUTION

Former Member
0 Kudos
101

Hi,

Check these FM's,

BAPI_ACC_DOCUMENT_POST.

BAPI_INCOMINGINVOICE_CREATE Invoice Verification: Post Invoice

BAPI_ACC_INVOICE_RECEIPT_POST

BAPI_INCOMINGINVOICE_PARK

Thanks,

Reward If Helpful.

2 REPLIES 2

Former Member
0 Kudos
101

Hi

use the bapi

BAPI_INCOMING_INVOICE

see the sample code

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

Regards

Anji

Former Member
0 Kudos
102

Hi,

Check these FM's,

BAPI_ACC_DOCUMENT_POST.

BAPI_INCOMINGINVOICE_CREATE Invoice Verification: Post Invoice

BAPI_ACC_INVOICE_RECEIPT_POST

BAPI_INCOMINGINVOICE_PARK

Thanks,

Reward If Helpful.