Application Development and Automation 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: 
Read only

Reg:BAPI Use

former_member197425
Active Participant
0 Likes
572

Hi,

Can anyone please tell me how to use BAPI.I had created a BAPI

and it is visible in BOR .But I dont knew how to use a created BAPI.

So please provide me the information how to use it.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
540

Go to SE37 and release the API enabled Function module. In the Object created in the BOR, set the status of Object Type Component to Released.

You can then display the BAPI in the BAPI Explorer. Invoke the same using the T-code BAPI.

This BAPI can be called in the way you call FM in your report.

Have a look at below link which gives details with Example:

[Use of BAPI|http://www.erpgenie.com/sap/abap/bapi/example.htm]

I hope it helps.

Best Regards,

Vibha

Please mark all the helpful answers

3 REPLIES 3
Read only

Former Member
0 Likes
540

hi,

You can call the BAPI from pattern button... the way you call a normal function module ... here is an example how a BAPI is used in a program ...


DATA: l_headerdata LIKE  bapi_incinv_create_header,
        l_invoicedocnumber LIKE  bapi_incinv_fld-inv_doc_no,
        l_fiscalyear LIKE  bapi_incinv_fld-fisc_year,
      i_itemdata LIKE bapi_incinv_create_item OCCURS 0 WITH HEADER LINE,
        i_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
  DATA: l_additionalheaderdata LIKE  bapi_incinv_save_header_backgr,
  l_refdoccategory LIKE  bapi_incinv_fld-ref_doc_category.
  LOOP AT i_list_cab WHERE check = 'X'.
    CLEAR l_headerdata.
    l_headerdata-doc_type = 'RS'.
    l_headerdata-invoice_ind = ''.
    l_headerdata-doc_date = i_list_cab-bldat.
    l_headerdata-pstng_date = i_list_cab-budat.
    l_headerdata-ref_doc_no = i_list_cab-xblnr.
    l_headerdata-comp_code = 'YW01'.
    l_headerdata-currency = i_list_cab-waers.
    l_headerdata-exch_rate = i_list_cab-kursf.
    l_headerdata-gross_amount = i_list_cab-rmwwr.
    l_headerdata-bline_date = i_list_cab-zfbdt.
    l_headerdata-del_costs_taxc = i_list_cab-mwskz.
    l_headerdata-diff_inv = i_list_cab-lifnr.
    l_headerdata-alloc_nmbr = i_list_cab-id_archivo.
    l_headerdata-dsct_amount =  0.
    l_headerdata-calc_tax_ind = 'X'.
    l_headerdata-del_costs_taxc = i_list_cab-mwskz.
 
    LOOP AT i_list_pos WHERE xblnr = i_list_cab-xblnr.
      i_itemdata-invoice_doc_item = i_list_pos-buzei.
      i_itemdata-po_number = i_list_pos-ebeln.
      i_itemdata-po_item   = i_list_pos-ebelp.
      i_itemdata-tax_code = i_list_cab-mwskz.
      i_itemdata-item_amount = i_list_pos-wrbtr.
      i_itemdata-quantity = i_list_pos-menge.
      i_itemdata-po_unit = i_list_pos-meins.
 
      SELECT SINGLE bprme FROM ekpo
        INTO i_itemdata-po_pr_uom
       WHERE ebeln = i_list_pos-ebeln
         AND ebelp = i_list_pos-ebelp.
      APPEND i_itemdata.
    ENDLOOP.
 
    CALL FUNCTION 'BAPI_INCOMINGINVOICE_PARK'
      EXPORTING
        headerdata                = l_headerdata
*   ADDRESSDATA               =
      IMPORTING
        invoicedocnumber          = l_invoicedocnumber
        fiscalyear                = l_fiscalyear
      TABLES
        itemdata                  = i_itemdata
*   ACCOUNTINGDATA            =
*   GLACCOUNTDATA             =
*   MATERIALDATA              =
*   TAXDATA                   =
*   WITHTAXDATA               =
*   VENDORITEMSPLITDATA       =
        return                    = i_return.
 
****    PERFORM generar_doc_prelim_mm.
    IF NOT l_invoicedocnumber IS INITIAL.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.
      WRITE: / l_invoicedocnumber.
    ENDIF.

Read only

Former Member
0 Likes
541

Go to SE37 and release the API enabled Function module. In the Object created in the BOR, set the status of Object Type Component to Released.

You can then display the BAPI in the BAPI Explorer. Invoke the same using the T-code BAPI.

This BAPI can be called in the way you call FM in your report.

Have a look at below link which gives details with Example:

[Use of BAPI|http://www.erpgenie.com/sap/abap/bapi/example.htm]

I hope it helps.

Best Regards,

Vibha

Please mark all the helpful answers

Read only

Former Member