BAPI create invoice

I use BAPI_ACC_INVOICE_RECEIPT_CHECK to create automatically an invoice but I don't know how to add parameters to tables to create an invoice with 3 positions: for example with amount 200 , -195, -5
How many there will be positions with:
IT_ACCOUNTPAYABLE--ITEMNO_ACC
IT_CURRENCYAMOUNT-ITEMNO_ACC
IT_ACCOUNTGL-ITEMNO_ACC
Every position have an own account number

hi,
Please find the below links.
http://www.sapdev.co.uk/java/jco/bapi_jco.pdf
http://sapabaplive.blogspot.com/search/label/BAPI
Sample code:
Invoice data is sent by the vendors in a text file and an inbound
interface is required to create Vendor Invoices in SAP.
The file contains the Purchase Order information, material quantity
received from vendor along with the amount.
Here the requirement becomes a little complex as there might be
several ocuurences of same Purchase Order item in one invoice.
Only a incomplete sample coding is given here and it can only be used
as a base for writing a program.
Populate internal Table I_ITAB from the data uploaded
from text data file.
Populate Item Table from item data in data file
Processing for header records of data file.
set up header data for BAPI call.
Check whwther it's an Incoice or Credit Memo.
And populate Invoice indicator accordingly.
IF I_ITAB-TRANS EQ '-'.
I_HEADER-INVOICE_IND = C_X.
ELSE.
CLEAR I_HEADER-INVOICE_IND.
ENDIF.
I_HEADER-PSTNG_DATE = I_ITAB-BUDAT.
I_HEADER-DOC_DATE = I_ITAB-BLDAT.
I_HEADER-CURRENCY = W_WAERS.
I_HEADER-GROSS_AMOUNT = I_ITAB-DMBTR.
I_HEADER-COMP_CODE = I_ITAB-BUKRS.
I_HEADER-HEADER_TXT = I_ITAB-SGTXT.
I_HEADER-REF_DOC_NO = I_ITAB-XBLNR.
IF NOT I_ITAB-INV_REC_DATE IS INITIAL.
I_HEADER-INV_REC_DATE = I_ITAB-INV_REC_DATE.
ELSE.
I_HEADER-INV_REC_DATE = I_ITAB-BLDAT.
ENDIF.
I_HEADER-PYMT_METH = I_ITAB-ZLSCH.
APPEND I_HEADER.
Populate Item Table from item data in data file
lv_count = 0.
LOOP AT I_ITAB.
Processing for header records of data file.
lv_count = lv_count + 1.
Item Data
I_ITEM-INVOICE_DOC_ITEM = lv_COUNT.
I_ITEM-PO_NUMBER = I_ITAB-EBELN.
I_ITEM-PO_ITEM = I_ITAB-EBELP.
I_ITEM-TAX_CODE = I_ITAB-MWSKZ2.
I_ITEM-ITEM_AMOUNT = I_ITAB-NETWR.
Populate quantities if not a blanket order
IF I_ITAB-BLANKET EQ SPACE.
I_ITEM-QUANTITY = I_ITAB-MENGE.
PERFORM GET_MEINS USING I_ITAB-EBELN " Use table EKPO
I_ITAB-EBELP
CHANGING I_ITEM-PO_UNIT.
I_ACCOUNTINGDATA-PO_UNIT = I_ITEM-PO_UNIT.
IF I_ITEM-QUANTITY EQ 0.
I_ITEM-PO_UNIT = SPACE.
ENDIF.
ENDIF.
Item Text
I_ITEM-ITEM_TEXT = I_ITAB-ITEM_TEXT.
APPEND I_ITEM.
Populate Accounting Data
IF I_ITAB-BLANKET EQ SPACE.
I_ACCOUNTINGDATA-INVOICE_DOC_ITEM = lv_COUNT.
I_ACCOUNTINGDATA-SERIAL_NO = '01'.
I_ACCOUNTINGDATA-TAX_CODE = I_ITAB-MWSKZ2.
I_ACCOUNTINGDATA-ITEM_AMOUNT = I_ITAB-NETWR.
SELECT SINGLE SAKTO KOSTL VBELN VBELP ANLN1 ANLN2 DABRZ
FISTL GEBER GRANT_NBR GSBER IMKEY KOKRS KSTRG PAOBJNR
PRCTR PS_PSP_PNR AUFNR MENGE
FROM EKKN
INTO (I_ACCOUNTINGDATA-GL_ACCOUNT, I_ACCOUNTINGDATA-COSTCENTER,
I_ACCOUNTINGDATA-SD_DOC, I_ACCOUNTINGDATA-SDOC_ITEM,
I_ACCOUNTINGDATA-ASSET_NO, I_ACCOUNTINGDATA-SUB_NUMBER,
I_ACCOUNTINGDATA-REF_DATE, I_ACCOUNTINGDATA-FUNDS_CTR,
I_ACCOUNTINGDATA-FUND, I_ACCOUNTINGDATA-GRANT_NBR,
I_ACCOUNTINGDATA-BUS_AREA, I_ACCOUNTINGDATA-RL_EST_KEY,
I_ACCOUNTINGDATA-CO_AREA, I_ACCOUNTINGDATA-COSTOBJECT,
I_ACCOUNTINGDATA-PROFIT_SEGM_NO, I_ACCOUNTINGDATA-PROFIT_CTR,
I_ACCOUNTINGDATA-WBS_ELEM, I_ACCOUNTINGDATA-ORDERID,
I_ACCOUNTINGDATA-QUANTITY)
WHERE EBELN EQ I_ITAB-EBELN
AND EBELP EQ I_ITAB-EBELP
AND ZEKKN EQ '01'.
IF EKKO-BSART NE 'LTV'.
CLEAR I_ACCOUNTINGDATA-QUANTITY.
CLEAR I_ACCOUNTINGDATA-PO_UNIT.
ENDIF.
APPEND I_ACCOUNTINGDATA.
ENDIF.
ENDLOOP.
The following coding is to solve the problem
mentioned in OSS Note 518338.
Same PO item within several invoice items.
SORT I_ITEM BY PO_NUMBER PO_ITEM.
LOOP AT I_ITEM.
ON CHANGE OF I_ITEM-PO_NUMBER OR I_ITEM-PO_ITEM.
W_COUNTER = 1.
LOOP AT I_ITEM WHERE PO_NUMBER = I_ITEM-PO_NUMBER
AND PO_ITEM = I_ITEM-PO_ITEM.
IF W_COUNTER EQ 1.
I_ACCOUNTINGDATA-SERIAL_NO = '01'.
I_ACCOUNTINGDATA-XUNPL = ' '.
ELSE.
I_ACCOUNTINGDATA-SERIAL_NO = ' '.
I_ACCOUNTINGDATA-XUNPL = 'X'.
ENDIF.
MODIFY I_ACCOUNTINGDATA
TRANSPORTING SERIAL_NO XUNPL
WHERE INVOICE_DOC_ITEM = I_ITEM-INVOICE_DOC_ITEM.
W_COUNTER = W_COUNTER + 1.
ENDLOOP.
To solve the repetition of PO item in subsequent invoices.
ELSEIF SY-TABIX EQ 1.
W_COUNTER = 1.
LOOP AT I_ITEM WHERE PO_NUMBER = I_ITEM-PO_NUMBER
AND PO_ITEM = I_ITEM-PO_ITEM.
IF W_COUNTER EQ 1.
I_ACCOUNTINGDATA-SERIAL_NO = '01'.
I_ACCOUNTINGDATA-XUNPL = ' '.
ELSE.
I_ACCOUNTINGDATA-SERIAL_NO = ' '.
I_ACCOUNTINGDATA-XUNPL = 'X'.
ENDIF.
MODIFY I_ACCOUNTINGDATA
TRANSPORTING SERIAL_NO XUNPL
WHERE INVOICE_DOC_ITEM = I_ITEM-INVOICE_DOC_ITEM.
W_COUNTER = W_COUNTER + 1.
ENDLOOP.
ENDON.
ENDLOOP.
Changes over for OSS Note 518338.
SORT I_ITEM BY INVOICE_DOC_ITEM PO_NUMBER PO_ITEM.
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
EXPORTING
HEADERDATA = I_HEADER
IMPORTING
INVOICEDOCNUMBER = W_BELNR
FISCALYEAR = W_GJAHR
TABLES
ITEMDATA = I_ITEM
ACCOUNTINGDATA = I_ACCOUNTINGDATA
TAXDATA = I_TAX
RETURN = I_RETURN.
if sy-subrc 0.
message e999(re) with 'Problem occured'.
else.
loop at return.
if not return is initial.
clear bapi_retn_info.
move-corresponding return to bapi_retn_info.
if return-type = 'A' or return-type = 'E'.
error_flag = 'X'.
endif.
append bapi_retn_info.
endif.
endloop.
if error_flag = 'X'.
message e999(re) with 'Problem occured'.
rollback work.
else.
Return Table from BAPI call is empty
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = I_RETURN.
endif.
endif.
hope this helps.
regs,
hema.

Similar Messages

  • How to create invoice using bapi  base on delivery number with example

    hi,
    Pl give me one example to create invoice using bapi base on delivery number (PGI).

    Use this code
    * Pass the delivery no to the FM to create the invoice
          wa_vbsk-smart = u2018Fu2019.
            wa_komfk-vbeln = nast-objky. u201CuF0DF-----delivery number
            APPEND wa_komfk TO it_komfk.
            CLEAR wa_komfk.
    *    To fill the message structure
    *        l_wa_error-vbeln_vl = nast-objky. " Delivery No.
    *        l_wa_error-fkart = wa_ztab-bil_doc_type." Billing Doc type
            CALL FUNCTION 'RV_INVOICE_CREATE'
                    EXPORTING
    *                 delivery_date             = 0
                     invoice_date              = v_date  u201C<- date
    *                 invoice_type              = '    '
    *                 pricing_date              = 0
                     vbsk_i                    = wa_vbsk
                     with_posting              = u2018Du2019
    *                 select_date               = 0
                     i_no_vblog                = ' '
                     i_analyze_mode            = ' '
                     id_utasy                  = ' '
                     id_utswl                  = ' '
                     id_utsnl                  = ' '
                     id_no_enqueue             = ' '
                     id_new_cancellation       = ' '
    **             IMPORTING
    *               VBSK_E                    =
    *               OD_BAD_DATA               =
    *               DET_REBATE                =
                    TABLES
                      xkomfk                    = it_komfk
                      xkomv                     = it_komv
                      xthead                    = it_thead
                      xvbfs                     = it_vbfs
                      xvbpa                     = it_vbpa
                      xvbrk                     = it_xvbrk
                      xvbrp                     = it_vbrp
                      xvbss                     = it_vbss
    *               XKOMFKGN                  =
    *               XKOMFKKO                  =

  • Problems in creating Invoice using BAPI

    Hello Friends,
    I am using a BAPI BAPI_BILLINGDOC_CREATEMULTIPLE to create invoice from a sales order, but i am not able to change the payer value.
    The payer is by default taken from Sales-Order, even if i change it in Payer value passed to BAPI.
    Please suggest me a solution.
    Sandeep.

    To answer your question I would need to know what stack trace comes back with.
    I also need to know the set up.. Is the applet running on you personal machine and what operating system are you using.
    Lee

  • Bapi for invoice create

    hi ,
    i want to create invoice ..the reference number will be delivery...is there any bapi/fm to do this..i tried bapi_billingdocu_createmultiple..but its not working..if there isn't any bapi what isthe other way...its an urgent thing..thank you..
    Thanks,
    Challa

    Check this thread for more details. It gives different aspects of creating Invoice document using BAPI for various scenarios.
    Re: invoice creation through BAPI

  • Bapi to create Invoice with reference to SalesOrder

    Hi All,
    I want to create Invoice with reference to SalesOrder ,
    can anybody help me regarding
    --> what is the Bapi to Create Invoice with reference to SalesOrder
    --> what are the import parameters
    Thanks in Advance
    Regards
    Srinivas

    Hi Giuseppi,
    Thanks to your reply,
    i have used BAPI_BILLINGDOC_CREATEMULTIPLE , i have given the following input values in the BILLINGDATAIN
      -- salesorg,distrchan,division,doc-type,sold-to,plant,material,doc-number,item-number , when  i execute the Bapi , i got the DocNo:0090021983 , but i did not find that DocNo. by executing the Bapi BAPI_BILLINGDOC_GETLIST.
    i found the short description for
    BAPI_BILLINGDOC_CREATEMULTIPLE -- is for Individual Customer Billing Document, is it the correct Bapi to create invoice
    what is the correct Bapi to create invoice based on the salesorder.
    RV_INVOICE_CREATE OR GN_INVOICE_CREATE OR BAPI_BILLINGDOC_CREATEMULTIPLE.
    Can u specify the import parameters for that Bapi.
    Thanks & Regards
    Srinivas

  • BAPI or FM to create Invoice in SRM , without reference to PO ?

    Dear Colleagues,
    We have a situation where we have to create invoices in SRM from a file from a legacy system, that means we have no POs in SRM.
    Which process, BAPI or Function Module would you recommend me? Is it possible to create "standard" invoices in SRM with a BAPI, and have those invoices be displayed afterward in the standard SRM functionality/transactions, plus have a subsequent invoice created in the backend?
    Will award point to helpful answers.
    Many thanks,
    David

    Thanks for your help, but I still dont know which FM is best, or what is the difference.
    Can i use this FM to post an invoice without reference to a PO? How do I fill/pass the vendor and item data? Do you have any example on how to pass the data to the FM?
    Which FM are called by the system when a vendor creates a NON-PO Invoice? Any idea?
    If I use the FM to transfer to backend, will the invoice go through all standard verifications in SRM and R/3?
    Thanks again, regards
    David

  • Call BAPI to Create Invoice During PGI(VL01N) via BADI

    Hi,
    Requirement: During PGI (VL01N), we have implemented a BADI (IF_EX_DELIVERY_PUBLISH) in method (PUBLISH_AFTER_SAVE) to call BAPI (BAPI_BILLINGDOC_CREATEMULTIPLE) to create invoice simultaneously with the PGI. In DEV box, the call BAPI is working fine (invoice is created). However in QA box there is a update termination occuring in the call BAPI, thus no invoice is being created. The thing is, how do I locate why the BAPI is terminating in QA but not in DEV? Is the BADI used correct? I have searched SAP Notes related to this termination when doing PGI in VL01N. Up to now we still do not know why in DEV is okay in QA it is not.
    SAP Notes:
    782447 Runtime error SAPSQL_ARRAY_INSERT_DUPREC when posting GIs
    777409 Foreign trade: Update termination EXPIMP_POSTING
    ST22 dump analysis:
    In the source code you have the termination point in line 51
    of the (Include) program "LV50EU05".
    The program "SAPLV50E" was started in the update system.
    The termination is caused because exception "CX_SY_OPEN_SQL_DB" occurred in
    procedure "EXPIMP_POSTING" "(FUNCTION)", but it was neither handled locally nor
    declared
    in the RAISING clause of its signature.
    The procedure is in program "SAPLV50E "; its source code begins in line
    1 of the (Include program "LV50EU05 ".
    Source code:
    DESCRIBE TABLE XEIKP LINES LIN.
    IF LIN GT 0.
       INSERT EIKP FROM TABLE XEIKP.         <<< the dump is happening in this standard logic
       REFRESH XEIKP.
    ENDIF.
    Edited by: Mawi C. Ng on Sep 2, 2009 2:24 PM

    Hi,
      Based on the DUMP i can say that in the below statement :
    INSERT EIKP FROM TABLE XEIKP. <<< the dump is happening in this standard logic
    The program is trying to insert lines which have duplicate key values check the btable XEIKP at this point and see if the records that are there do they have key fields values that already exist. You can put a break-point at that statement and check.
    Regards,
    Himanshu

  • BAPI needed to create invoice and creditmemo

    Hi all,
          Is there any BAPI available to create invoice and creditmemo when material no is not given.
          My requirement is to create credit memo and  invoice through FB75 or FB70 transaction. I am able to achieve the same through BDC. Is there any BAPI availabe for the same to create credit memo or invoice to avoid BDC.
          Input given to the program is a excel file in which i have the following fields
          Transaction -- which separates credit memo or
                         invoice
          Company code, purchase order number, GL account
          number, cost center, profit center, amount etc...
    Please let me know some pointers.
    Regards,
    Karthik.

    GN_INVOICE_CREATE or BAPI_BILLINGDOC_CREATEMULTIPLE
    Please find the sample code for Billing document BAPI.
    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

  • Creating invoice through bapi

    Hi experts,
    I am creating invoice by using BAPI_INCOMINGINVOICE_CREATE.
    this is for Invoice with Planned Delivery Costs.
    Here i am giving the following data.
    header data
    INVOICE_IND = x
    DOC_TYPE = kr
    doc_date
    post-date
    reff-doc-no = 3006828
    comp-code =
    diff-inv = 1110025
    curr = inr
    gr-amount = 50
    bline-date
    headertext
    del-costs
    del-costs-tax = v0
    po-ref-no = 3006828
    item data:
    invoice = 000001
    po-number =3006828
    po-it
    ref-doc
    ref-year
    ref-doc-it
    tax
    item-amount
    quantity
    po-unit
    po-pr-uom
    cond-type
    item-text
    Accounting data:
    invoice doc item = 000001
    serial no = 01
    tax = v0
    item amount = 50
    quantity = 5
    po unit =
    cmmt- item
    fund-cntr
    bus-area
    these are data I have given but it is not posted the invoice
    the following message is coming
    <b>account assignment 01 for purchasing document does not exist</b>
    Plz tell me what i have to do for this

    Hi nagaraj,
                  Can u tell me where can i find the purchase order is existed with
       Account group or not?
            thanks in advance
    regards,
    srinivas

  • Automaticaly created invoice related to the sales order

    Hi gurus,
    I have question for you.
    I will create the automatic creation of sales order via BAPi, but after creation of sales order I would like to have also automatic creation of SD invoice. Is there any setting that the invoice can be issued immediately after sales order creation or I need to use another BAPI to do this.
    Is there any chance to create invoice for services (without delivery note) automaticaly after Sales order creation.
    Thanks in advance
    Saso

    Hi gurus,
    Is there any chance to create invoice for services (without delivery note) automaticaly after Sales order creation.----> Yes u can create SD invoice without Delivery note , but it depends upon ur Config Setting ?
    I have question for you.
    I will create the automatic creation of sales order via BAPi, but after creation of sales order I would like to have also automatic creation of SD invoice. Is there any setting that the invoice can be issued immediately after sales order creation or I need to use another BAPI to do this-->Better Option is Use Another BAPI to create SD Invoice.
    Regards
    Prabhu

  • BAPI for invoice creation with reference SalesOrder

    hi Mr Anjireddy,
    i am able to create invoice with the bapi BAPI_BILLING_CREATEMULTIPLE, here i'm giving the RefDocNo of the SalesOrder, the invoice is generated but i'm not gettting the NetValue, TaxValue.
    plz give the information for that prob,
    eswar

    Hi Vinod,
    This is just idea.
    Get Purchase Requisition details using
    <b>BAPI_REQUISITION_GETDETAIL</b> and then use <b>BAPI_PO_CREATE1</b>. I think there is no Direct BAPI.
    *******Poorna*********

  • BAPI for invoice MM SIMULATION

    Hi,
    I'm looking for a BAPI that does what the Simulate button do in the MIR4 MM Invoice.
    Could anyone recommend something?
    Thank you in advance.

    hi Andrew ,
    i think there is no such BAPI which creates Invoice  in SIMULATION Mode.
    <b>BAPI_INCOMINGINVOICE_CREATE ---> will not give complete picture of Accouting entry. So we cannt use this BAPI.</b>
    Message was edited by:
            Prabhu Peram

  • Using BAPI_ACC_INVOICE_RECEIPT_POST to create Invoice Receipt

    Hi,
    I'm using the above BAPI to create invoice receipts (to mimic MIRO) but if I enter the OBJ_TYPE RMRP it gives me an error:
    'Incorrect entry in field OBJ_TYPE: RMRP'
    I've checked table TTYP and this object type does exist.  Has anyone come across this error before?
    Basically I want to be able to pass it a Purchase Order document number and it should create an invoice receipt document like it does in MIRO.  I'm on version 4.6c but do have access to 640 and I know nothing about financials (I leave that to the FI/CO consultants).
    Any help would be appreciated.
    Gill

    Hi Gill,
    I need to meet the same requirement 'Enter Invoice with Reference to Purchase Order MIRO'. I was reading the threat you created. Which BADI did you use to create invoice with reference to PO? If you can provide and tip or test program that which fields I need to provide in BAPI.
    Thanks for ur help

  • Create invoice with out sales order or delivery

    Hi,
    is it possible to create invoice with out sales document or delivery. A scenario, where you buy some article and get the invoice and pay the money.

    need to raise direct VF01 for a customer. Is there any Bapi
    Go to SE37, input BAPI_BILLINGDOC_CREATEMULTIPLE and execute. 
    1)  There press F8
    2)  Double click on the value "BILLINGDATAIN"
    3)  Input Sales Organization, Dis.Chnl, Div, Order Type, Bill date, Sold to etc., and press F3
    4)  Now execute (F8)
    5)  Press "Success"
    thanks
    G. Lakshmipathi

  • Creating invoice and posting  with FB60 (Without PO reference)

    Hi All,
    I need to create vendor invoice (without PO reference) as we do using FB60.
    How it can be done?
    Is there any BAPI which can be used ?
    I have used BAPI_INCOMINGINVOICE_CREATE to create vendor invoice with PO reference.
    Is the same BAPI we can use for creating invoice without PO reference? how to use ? or any other solution.
    Thank you very much....

    Hi Ashvender,
    Thanks for Replying....
    You are right we create IV with PO reference using MIRO and
    We create FI invoice by FB60 i.e without PO reference. But i want to upload data from excel sheet for without PO reference for FB60 as per given template below
    <b>Invoices with no reference to PO - FB60 format</b>
    Vendor       Date         reference        header txt    Bus area    G/L account    
    tax code   TAX amnt   Amount     WBS code                  Cost centre   Value 
    5000000    20.09.06    reference123     headertxt      1001          418002             v2             17.50         117.5        0506-PR-000001-CAP   4100             117.5
    Apart from BDC is there any BAPI we can use?

Maybe you are looking for

  • Bounce Management in SAP CRM 2007

    Hi Experts, we have SAP CRM 2007 and I have a few questions about Bounce Management. It is a very simple scenario, so it´s fine if only hard bounces for incoming EMails are handled. 1) Do you need ERMS for that simple form of Bounce Mgt? 2) Is the Us

  • Where should I put trustedprincipal.conf in

    Hi experts, We have BOE XI 3.1 in our server. We configured trusted authentication in CMC of our server machine, and created a trustedprincipal.conf in D:\Program Files\Business Objects\BusinessObjects Enterprise 12.0\win32_x86 of my client machine.

  • Iphone (iOS4.3) to macbook bluetooth fail

    I can no longer connect my iPhone to my macbook, for tethering or otherwise. Reset network settings, reset both devices, resetup like 10 time. I keep getting this message on my iPhone after I setup, when i try to connect via my iPhone. 'Connection Un

  • Reinstalling older products

    I use DreamWeaver 8 and PhotoShop Elements 4 and am unable to upgrade at this time. However, my laptop recently died. Unfortunately, when I went to reinstall to my new computer, I found that my installation disks have been accidentally packed and put

  • How do i activate push notifications

    I've just updated to 7.03, I constantly get a message to activeate push notifications in iTunes. How do i do this?