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 for invoice

Former Member
0 Kudos

Hi,

Can any one tell me the BAPI to create invoice with reference to a Delivey document number.

5 REPLIES 5

Former Member
0 Kudos

BAPI_INCOMINGINVOICE_CREATE

Headerdata

DOC_DATE 02/08/2005

INVOICE_IND X Post Invoice

PSTNG_DATE 02/08/2005

COMP_CODE 5010 Hospira Inc.

CURRENCY/ CURRENCY_ISO USD United States Dollar

GROSS_AMOUNT 100.0000

DOC_TYPE RE PO Invoice

REF_DOC_NO 1 Billing document no

EXCH_RATE 1.00000

CALC_TAX_IND X

HEADER_TXT header text

Item Data

INVOICE_DOC_ITEM 000001 Invoice Document no

PO_NUMBER 4500125768 PO No

PO_ITEM 1 PO item no

ITEM_AMOUNT 100.0000

QUANTITY 10.000

PO_UNIT EA Each

REF_DOC 5000000007 Goods Receipt No

REF_DOC_YEAR 2005 GR year

REF_DOC_IT 0001 Goods Receipt item no

TAX_CODE I0 AP, not relevant to tax

ITEM_TEXT Text

Please give me reward point if it is useful.

Thanks

Murali Poli

0 Kudos

Hi Murali,

Thanks for reply.

Actually the reference for my delivery is Sales Order not PO.Also can u explain what REF_DOC_NO 1 Billing document no means??can i use this bapi for sales document too..

Thanks,

Challa.

0 Kudos

Hi Bhasker,

see the sample for the BAPI code

BAPI_BILLINGDOC_CREATEMULTIPLE.

DATA: t_success TYPE STANDARD TABLE OF bapivbrksuccess WITH HEADER LINE.

DATA: t_billing TYPE STANDARD TABLE OF bapivbrk WITH HEADER LINE.

DATA: t_return TYPE STANDARD TABLE OF bapireturn1 WITH HEADER LINE.

t_billing-salesorg = vbak-vkorg.

t_billing-DISTR_CHAN = vbak-vtweg.

t_billing-DIVISION = vbak-spart.

t_billing-DOC_TYPE = vbak-auart.

t_billing-ref_doc = vbak-vbeln.

t_billing-ref_item = vbap-posnr.

t_billing-doc_number = vbak-vbeln.

t_billing-ITM_NUMBER = vbap-posnr.

t_billing-ordbilltyp = 'BILLING TYPE'.

t_billing-price_date = sy-datum.

t_billing-ref_doc_ca = vbak-vbtyp.

t_billing-sold_to = vbak-kunnr.

t_billing-material = vbap-matnr.

t_billing-plant = vbap-werks.

APPEND t_billing.

CALL FUNCTION 'BAPI_BILLINGDOC_CREATEMULTIPLE'

TABLES

billingdatain = t_billing

return = t_return

success = t_success.

commit work.

Regards

Anji

0 Kudos

Hi Anji,

Thank You..I heared a lot about You..i was wondering whether u will respond to this question or not..

what i understand from the sample code is creating a invoice against a sales order...but in my program there is another condition to create a invoice against a delivery..and the reference for this delivery is a saled order.can i use the same bapi for this too..if yes can i use likp-vbeln instead of vbak-vbeln ..canu tell me what i need to pass in the other fields

t_billing-salesorg =

t_billing-DISTR_CHAN =

t_billing-DIVISION =

t_billing-DOC_TYPE =

t_billing-ref_doc = .

t_billing-ref_item =.

t_billing-doc_number =

t_billing-ITM_NUMBER =

t_billing-ordbilltyp =.

t_billing-price_date = sy-datum.

t_billing-ref_doc_ca =

t_billing-sold_to =

t_billing-material =

t_billing-plant = .

APPEND t_billing.

thanks,

challa

Former Member
0 Kudos

hi

good

use the BAPI 'BAPI_INCOMINGINVOICE_CREATE' for invoice creation and bapi BAPI_INCINV_CREATE_HEADER for invoice header creation.Below is code for invoice creation.From Bapi call function in the code, u will get to know what header data , item data and accounting data i have to consider and take into account.

Reward if useful.

Thanks.

method DO_HANDLE_EVENT.

data zinvheader_it type ZRMINV_HEAD_TAB.

data: zinvheader type BAPI_INCINV_CREATE_HEADER.

data: ddate type BLDAT.

data: pdate type BUDAT.

if htmlb_event is bound and htmlb_event->server_event = 'onsave'.

data: temp_tab1 type zrminvhead.

zinvheader-doc_type = 'RE'.

zinvheader-doc_date = request->get_form_field( 'IDate' ).

  • CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

  • EXPORTING

  • DATE_EXTERNAL = zinvheader-doc_date

  • ACCEPT_INITIAL_DATE =

  • IMPORTING

  • DATE_INTERNAL = ddate

  • EXCEPTIONS

  • DATE_EXTERNAL_IS_INVALID = 1

  • OTHERS = 2

  • .

  • IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  • ENDIF.

  • zinvheader-doc_date = ddate.

zinvheader-pstng_date = request->get_form_field( 'PDate' ).

zinvheader-comp_code = request->get_form_field( 'CCode' ).

zinvheader-gross_amount = request->get_form_field( 'Amt' ).

zinvheader-partner_bk = request->get_form_field( 'PBank' ).

zinvheader-currency = request->get_form_field( 'Curr' ).

zinvheader-invoice_ind = 'X'.

zitem1-invoice_doc_item = request->get_form_field( 'IDItem' ).

zitem1-po_number = request->get_form_field( 'po_num' ).

zitem1-po_item = request->get_form_field( 'po_item' ).

zitem1-tax_code = request->get_form_field( 'TCode' ).

zitem1-item_amount = request->get_form_field( 'IAmt' ).

zitem1-quantity = request->get_form_field( 'quantity' ).

zitem1-po_unit = request->get_form_field( 'po_unit' ).

append zitem1 to zitem.

CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'

EXPORTING

HEADERDATA = zinvheader

  • ADDRESSDATA =

IMPORTING

INVOICEDOCNUMBER = inv_no

  • FISCALYEAR =

TABLES

ITEMDATA = zitem

  • ACCOUNTINGDATA =

  • GLACCOUNTDATA =

  • MATERIALDATA =

  • TAXDATA =

  • WITHTAXDATA =

  • VENDORITEMSPLITDATA =

RETURN = ZRET

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

  • IMPORTING

  • RETURN =

.

IF INV_NO = ' '.

inv_no = 'Try Again'.

ENDIF.

reward point if helpful.

thanks

mrutyun^