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: 

Re: BAPI for MIRO

Former Member
0 Kudos

Hi Experts,

Once the GR is posted successfully for all the POs, we need to do Invoice Receipt against the POs. We do this manually with MIRO with reference to PO. I need to use BAPI for this i.e BAPI_INCOMINGINVOICE_CREATE, what are the mandatory fields for this bapi, please let me know with one example.

thanks,

santhosh

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try this sample code

loop at it_ekpo .

    itemdata-invoice_doc_item =  sy-tabix .
    it_material-invoice_doc_item = sy-tabix.
    it_material-material = it_ekpo-matnr.
    it_material-val_area = it_ekpo-werks.
    it_material-db_cr_ind = 'X'.
    it_material-tax_code = it_ekpo-mwskz.
    it_material-quantity = it_ekpo-menge.
    it_material-base_uom_iso = it_ekpo-meins.
    itemdata-po_number  = it_ekpo-ebeln .
    itemdata-po_item = it_ekpo-ebelp .
    itemdata-item_amount = it_ekpo-netpr * it_ekpo-menge .
    itemdata-quantity = it_ekpo-menge .
    itemdata-po_unit  =  it_ekpo-meins .
    append itemdata to itemdatat .
    append it_material.
  endloop .

  headerdata-invoice_ind =  'X' .
  headerdata-doc_date    = sy-datum .
  headerdata-pstng_date  = sy-datum .
  headerdata-ref_doc_no  = 'Test-Inv' .
  headerdata-comp_code   = '0101' .
  headerdata-currency    =  'INR'..
  headerdata-gross_amount = '990.00'.

it_tax-tax_code = 'V0'.
it_tax-tax_amount = '90'.
it_tax-tax_base_amount = '990.00'.
append it_tax.


call function 'BAPI_INCOMINGINVOICE_CREATE'
    exporting
      headerdata                = headerdata
   importing
     invoicedocnumber          =    invoicedocnumber
     fiscalyear                =    fiscalyear
    tables
      itemdata                  = itemdatat
      materialdata              = it_material
      taxdata                   = it_tax
      return                    = return .
  call function 'BAPI_TRANSACTION_COMMIT'.

Regards

Vinod

11 REPLIES 11

Former Member
0 Kudos

Hi,

Go to SE 37 Transction give the FM name and click the Function Module documentation it will give you the mandatory vlaue to be passed in the FM. Anyway for your reference find below

HeaderData table

o INVOICE_IND (Post invoice/credit memo): X

o DOC_DATE (Document date): 02.19.2001

o PSTING_DATE (Posting date): 02.21.2001

o COMP_CODE (Company code): 1000

o GROSS_AMOUNT (Gross amount): 110

o CURRENCY (Currency): USD

o CALC_TAX_IND (Calculate tax): X

ItemData table

o INVOICE_DOC_ITEM (Item in the invoice document): 00001

o PO_NUMBER (PO number): 4500015172

o PO_ITEM (PO item): 00010

o TAX_CODE (Tax code): V1

o ITEM_AMOUNT (Item amount): 100

former_member125931
Active Participant
0 Kudos

Please refer [http://sap.ittoolbox.com/groups/technical-functional/sap-dev/bapi_incominginvoice_create-170985]

Former Member
0 Kudos

Hi,

Try this sample code

loop at it_ekpo .

    itemdata-invoice_doc_item =  sy-tabix .
    it_material-invoice_doc_item = sy-tabix.
    it_material-material = it_ekpo-matnr.
    it_material-val_area = it_ekpo-werks.
    it_material-db_cr_ind = 'X'.
    it_material-tax_code = it_ekpo-mwskz.
    it_material-quantity = it_ekpo-menge.
    it_material-base_uom_iso = it_ekpo-meins.
    itemdata-po_number  = it_ekpo-ebeln .
    itemdata-po_item = it_ekpo-ebelp .
    itemdata-item_amount = it_ekpo-netpr * it_ekpo-menge .
    itemdata-quantity = it_ekpo-menge .
    itemdata-po_unit  =  it_ekpo-meins .
    append itemdata to itemdatat .
    append it_material.
  endloop .

  headerdata-invoice_ind =  'X' .
  headerdata-doc_date    = sy-datum .
  headerdata-pstng_date  = sy-datum .
  headerdata-ref_doc_no  = 'Test-Inv' .
  headerdata-comp_code   = '0101' .
  headerdata-currency    =  'INR'..
  headerdata-gross_amount = '990.00'.

it_tax-tax_code = 'V0'.
it_tax-tax_amount = '90'.
it_tax-tax_base_amount = '990.00'.
append it_tax.


call function 'BAPI_INCOMINGINVOICE_CREATE'
    exporting
      headerdata                = headerdata
   importing
     invoicedocnumber          =    invoicedocnumber
     fiscalyear                =    fiscalyear
    tables
      itemdata                  = itemdatat
      materialdata              = it_material
      taxdata                   = it_tax
      return                    = return .
  call function 'BAPI_TRANSACTION_COMMIT'.

Regards

Vinod

0 Kudos

Hi Experts,

I found this fields but i didn't find correct po no for this how to give correct number.

thanks ,

santhosh .

0 Kudos

Hi Experts,

what r the fields i can forward in item data from which table i can find those fields. please let me know where i can find related fields for item data table.

thanks,

santhosh .

0 Kudos

In ME2N you can find PO and related information...

0 Kudos

Hi,

Read the function module documentation.

Thanks,

Ram.

0 Kudos

Hi,

Item related data can be extracted from EKPO (PO Item level ) Table.

Regards

Vinod

0 Kudos

Hi Experts,

what are the fields for this i need to pass fields from the table where i can find related fields for below headerdata. no need to pass direct value.

headerdata-ref_doc_no = 'Test-Inv' .

headerdata-comp_code = '0101' .

headerdata-currency = 'INR'..

headerdata-gross_amount = '990.00'.

it_tax-tax_code = 'V0'.

it_tax-tax_amount = '90'.

it_tax-tax_base_amount = '990.00'.

thanks,

santhosh.

0 Kudos

Header information from EKKO (PO Header) and Tax related information from conditions records of PO (KONV).

Regards

Vinod

Former Member
0 Kudos

thank you