cancel
Showing results for 
Search instead for 
Did you mean: 

bapi smaple programs

Former Member
0 Kudos

send me for sample programs in bapi

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

For step by step Bapi.. Refer following link..

http://www.erpgenie.com/abap/bapi/example.htm

Reward pts if usefull.

Regards,

Dhan

Former Member
0 Kudos

hi,

refer this link.

BAPI-step by step

http://www.sapgenie.com/abap/bapi/example.htm

Former Member
0 Kudos

Hi ,

U can use following steps to find a BAPI

How to find function module or Bapi for particular transaction in sap?

If you mean that you need to know what BAPI's a particular tranx uses, which I can only assume that's what you mean, then you should access the code behind the transaction and search for 'CALL'. That normally is the standard method that think that most people use.

Suppose you want to find the bapi for creating a sales order, you usually use transaction VA01 for this.

1. Find out the package of the transaction.

Start Va01 go to system --> status.

Double click on transaction

Package is VA

Open this package in SE80

Open business engineering-->Business object types

Find the BO which sounds the most appropriate

I would suggest BUS2032 Sales Order

Double click.

Open methods.

Find the released method with from data or something similar in the name

, Createfromdat2

Position the cursor in it and click the program button

Scroll down to find the bapi used in this method

With this way you can also find out programs and FM's

2. Start va01 go to system-->status

Double click transaction VA01

Double click on package

Read the application component. (this is SD-SLS Sales)

Then open the transaction BAPI

Sales and distribution>Sales>sales order

createfromdat2

This simple code for PO creation from bapi


*tables for passing podata to bapi
DATA : gt_header   TYPE STANDARD TABLE OF bapimepoheader,
       gt_headerx  TYPE STANDARD TABLE OF bapimepoheaderx,
       gt_item     TYPE STANDARD TABLE OF bapimepoitem,
       gt_itemx    TYPE STANDARD TABLE OF bapimepoitemx,
       gt_account  TYPE STANDARD TABLE OF bapimepoaccount,
       gt_accountx TYPE STANDARD TABLE OF bapimepoaccountx,
*tables used for passing custom field data to bapi
       gt_custom   TYPE STANDARD TABLE OF bapiparex,
       gt_custdata_in TYPE STANDARD TABLE OF bapi_te_mepoaccounting,
       gt_custdata_ix TYPE STANDARD TABLE OF bapi_te_mepoaccountingx,
*tables used for cathing messages returned by bapi
       gt_return   TYPE STANDARD TABLE OF bapiret2,
       gt_return1   TYPE STANDARD TABLE OF bapiret2,
*Work area declaration for passing custom field data to bapi
       w_custom   LIKE LINE OF gt_custom,
       w_custdata_in LIKE LINE OF gt_custdata_in,
       w_custdata_ix LIKE LINE OF gt_custdata_ix,
*Work area declaration for passing podata to bapi
       w_header   LIKE LINE OF gt_header,
       w_headerx  LIKE LINE OF gt_headerx,
       w_item     LIKE LINE OF gt_item,
       w_itemx    LIKE LINE OF gt_itemx,
       w_account  LIKE LINE OF gt_account,
       w_accountx LIKE LINE OF gt_accountx,
*work area declaration for cathing messages returned by bapi
       w_return   LIKE LINE OF gt_return,
       w_return1  LIKE LINE OF gt_return1.

*----------------------------------------------------------------------*
*populating po dat into internal tables
w_header-comp_code  = 'AC02'.
w_header-doc_type   = 'TEST'.
w_header-vendor     = '0000000019'.
w_header-purch_org  = 'AC02'.
w_header-pur_group  = '901'.

w_headerx-comp_code  = 'X'.
w_headerx-doc_type   = 'X'.
w_headerx-vendor     = 'X'.
w_headerx-purch_org  = 'X'.
w_headerx-pur_group  = 'X'.

w_item-po_item      = '00001'.
w_item-short_text   = 'test po'.
w_item-po_unit      = 'CM'.
w_item-matl_group   = '01'.
w_item-po_unit      = 'EA'.
w_item-plant        = 'AV02'.
w_item-quantity     = '1.000'.
w_item-net_price    = '10.00'.
w_item-item_cat     = '0'.
w_item-acctasscat   = 'K'.
APPEND w_item TO gt_item.

w_itemx-po_item    = '00001'.
w_itemx-short_text = 'X'.
w_itemx-matl_group = 'X'.
w_itemx-po_unit    = 'X'.
w_itemx-plant      = 'X'.
w_itemx-stge_loc   = 'X'.
w_itemx-quantity   = 'X'.
w_itemx-tax_code   = 'X'.
w_itemx-net_price  = 'X'.
w_itemx-item_cat   = 'X'.
w_itemx-acctasscat = 'X'.
APPEND w_itemx TO gt_itemx.

w_account-po_item    = '00001'.
w_account-serial_no  = '01'.
w_account-quantity   = '1.000'.
w_account-gl_account = '000000099'.
w_account-costcenter = '00000011'.
APPEND w_account TO gt_account.

w_accountx-po_item    = '00001'.
w_accountx-serial_no  = '01'.
w_accountx-quantity   = 'X'.
w_accountx-gl_account = 'X'.
w_accountx-costcenter = 'X'.
APPEND w_accountx TO gt_accountx.


*----------------------------------------------------------------------*
*bapi to create po oreders
CALL FUNCTION 'BAPI_PO_CREATE1'
  EXPORTING
    poheader                     = w_header
    poheaderx                    = w_headerx
TABLES
  return                       = gt_return
  poitem                       = gt_item
  poitemx                      = gt_itemx
  poaccount                    = gt_account
  poaccountx                   = gt_accountx.
 
*bapi for po data commit
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  EXPORTING
    wait   = ' '
  IMPORTING
    return = w_return1.

*----------------------------------------------------------------------*
*clearing tables & work area
REFRESH:gt_account,gt_item,gt_itemx,gt_accountx.
CLEAR:w_header,w_headerx.

*----------------------------------------------------------------------*
*displaying message returned by bapi
LOOP AT gt_return INTO w_return.
  WRITE: w_return-type , w_return-id , w_return-number , w_return-message .
ENDLOOP.

Former Member
0 Kudos

Hi,

check the below links.

[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/200dd1cc-589e-2910-98a9-bb2c48b78dfa|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/200dd1cc-589e-2910-98a9-bb2c48b78dfa]

[http://www.saptechnical.com/Tutorials/BAPI/BAPIMainPage.htm|http://www.saptechnical.com/Tutorials/BAPI/BAPIMainPage.htm]

[http://www.erpgenie.com/abap/bapi/example.htm|http://www.erpgenie.com/abap/bapi/example.htm]

[http://www.sapdevelopment.co.uk/java/jco/bapi_jco.pdf|http://www.sapdevelopment.co.uk/java/jco/bapi_jco.pdf]

Check the t-code BAPI.

Reward if found helpful.

Regards,

Boobalan Suburaj

Former Member
0 Kudos

/message/5301527#5301527 [original link is broken]

Reward points..