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

bapi its urgent

Former Member
0 Likes
1,207

Hi all advanced regards.

can anydoby give the complete flow of bapi.

iam trying to do the sales order bapi, but i dont know from where shoud i start.

plz provide me any document which will give the complete flow of the bapi.

thanks in advance.

Hi all advanced regards.

can anydoby give the complete flow of bapi.

iam trying to do the sales order bapi, but i dont know from where shoud i start.

plz provide me any document which will give the complete flow of the bapi.

thanks in advance.

6 REPLIES 6
Read only

Former Member
0 Likes
889

Programming a BAPI consists of some tasks like:

• Defining BAPI Data structures ( using SE11 )

• Creating BAPI Function Modules (For each method)

• Defining BAPI Methods in the BOR

• Generate and release

1. Defining BAPI Data structures: This is the basic step followed while creating BAPIs. All the relevant structures that are required for BAPI have to be created using T-Code SE11. The structures can be created for Import/Tables parameters.

2. Creating BAPI Function Modules: We must create new function group for each BAPI. If the BAPIs are related then the same can be grouped under the same FUNCTION GROUP to enable the sharing of global data amongst the related BAPIs.

3. Defining BAPI Methods in the BOR: When creating a new object type in BOR (Business Object Repository), there can be two possibilities. Either it is created as a subtype of an existing business object or it is created as a new business object from scratch. Create a business object using the T-Code SWO1. The business object gets created with the standard interface that contains an Interface IFSAP, an Attribute ObjectType, and two methods namely ExistenceCheck and Display. All these cannot be changed. You can add a method to the business object. For this, we will choose from the menu path, Utillities -> API methods -> Add method. To use the business object Object type status has to be set to Implemented.

4. Generate and Release: 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.

Also have a look at below links.

http://www.sappoint.com/abap/bapiintro.pdf

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCMIDAPII/CABFAAPIINTRO.pdf

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CABFABAPIREF/CABFABAPIPG.pdf

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESDE8/BCFESDE8.pdf

http://help.sap.com/saphelp_nw04/helpdata/en/a5/3ec9f74ac011d1894e0000e829fbbd/frameset.htm

http://www.allsaplinks.com/bapi.html

http://www.allsaplinks.com/bapi_example.html

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

http://searchsap.techtarget.com/originalContent/0,289142,sid21_gci948835,00.html

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

I hope it helps.

Best Regards,

Vibha

<b>*Please mark all the helpful answers</b>

Read only

Former Member
0 Likes
889

you want to create BAPI or update some transaction using bapi???

If you are using BAPI to update any transaction you can refer to the folloeing bapi...It is used to create fixed asset.Similarly u can code for your BAPI.

FORM map_fixassets  CHANGING p_input_table TYPE t_input_table
                             p_asset_table TYPE t_asset_table
                             p_cost_table TYPE t_cost_table
                             p_depr_table TYPE t_depr_table
                             p_error_table TYPE t_error_table
                             p_t093c       TYPE  t_t093c_table
                             p_csks        TYPE  t_csks_table.

  DATA:
        l_testrun TYPE bapi1022_misc-testrun,
        la_generaldata TYPE bapi1022_feglg001,
        la_generaldatax TYPE bapi1022_feglg001x,
        la_inventory TYPE bapi1022_feglg011,
        la_inventoryx TYPE bapi1022_feglg011x,
        la_postinginformation TYPE bapi1022_feglg002,
        la_postinginformationx TYPE bapi1022_feglg002x,
        la_key TYPE bapi1022_key,
        la_timedependentdata TYPE bapi1022_feglg003,
        la_timedependentdatax TYPE bapi1022_feglg003x,
        la_allocations TYPE bapi1022_feglg004,
        la_allocationsx TYPE bapi1022_feglg004x,
        la_origin TYPE bapi1022_feglg009,
        la_originx TYPE bapi1022_feglg009x,
        la_assetcreated TYPE bapi1022_reference,
        li_depreciationareas TYPE TABLE OF bapi1022_dep_areas,
        la_depreciationareas LIKE LINE OF li_depreciationareas,
        li_depreciationareasx TYPE TABLE OF bapi1022_dep_areasx,
        la_depreciationareasx LIKE LINE OF li_depreciationareasx,
        li_cumulatedvalues TYPE TABLE OF bapi1022_cumval,
        la_cumulatedvalues LIKE LINE OF li_cumulatedvalues,
        li_postedvalues TYPE TABLE OF bapi1022_postval,
        la_postedvalues LIKE LINE OF li_postedvalues,
        li_transactions TYPE TABLE OF bapi1022_trtype,
        la_transactions LIKE LINE OF li_transactions.


  DATA: l_anlkl TYPE anla-anlkl,
        l_flag TYPE c.

  DATA: l_message TYPE string.

  CLEAR: g_no_read, g_no_valid, g_no_invalid, g_no_load, g_no_failed,
         wa_input, l_testrun, la_generaldata, la_generaldatax, la_inventory,
         la_inventoryx, la_postinginformation, la_postinginformationx, la_key,
         la_timedependentdata, la_timedependentdatax, la_allocations, la_allocationsx,
         la_origin, la_originx, li_depreciationareas, la_depreciationareas,
         li_depreciationareasx, la_depreciationareasx, li_cumulatedvalues,
         la_cumulatedvalues, li_postedvalues, la_postedvalues, li_transactions,
         la_transactions, wa_error_file.

  IF p_create = 'X'.       "Determine whether testrun or actual run.
    l_testrun = space.
  ELSE.
    l_testrun = 'X'.
  ENDIF.


  SORT p_asset_table BY lclass.
  SORT p_cost_table BY ldept.
  SORT p_depr_table BY ldepr.
  SORT p_t093c BY bukrs.
  SORT p_csks BY kostl.


  LOOP AT p_input_table INTO wa_input.

    CLEAR: l_anlkl,
           l_flag.

    g_no_read = g_no_read + 1.

* To pick up the asset class from the asset class file corresponding to the legacy class
    READ TABLE p_asset_table INTO wa_asset
           BINARY SEARCH WITH KEY lclass = wa_input-lclass.

    IF sy-subrc = 0.

      l_anlkl = wa_asset-anlkl.

      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = l_anlkl
        IMPORTING
          output = l_anlkl.

* To validate asset class
      CALL FUNCTION 'AM_ASSET_CLASS_READ'
        EXPORTING
          i_anlkl                = l_anlkl
        TABLES
          t_ankb                 = i_ankb
          t_ankv                 = i_ankv
        EXCEPTIONS
          klasse_nicht_vorhanden = 1
          i_anlkl_fehlt          = 2
          OTHERS                 = 3.

      IF sy-subrc <> 0.      " asset class not valid
        MOVE-CORRESPONDING wa_input TO wa_error_file.
        wa_error_file-mssg1 = text-028.
        l_flag = 'X'.
      ELSE.

        la_generaldata-assetclass = l_anlkl.
      ENDIF.

    ELSE.

      MOVE-CORRESPONDING wa_input TO wa_error_file.
      wa_error_file-mssg1 = text-071.
      l_flag = 'X'.
    ENDIF.


    CALL FUNCTION 'ZFAA_FORMAT_FIELDS'
      EXPORTING
        zinput  = wa_input-txt50
      IMPORTING
        zoutput = wa_input-txt50.

    CALL FUNCTION 'ZFAA_FORMAT_FIELDS'
      EXPORTING
        zinput  = wa_input-txa50
      IMPORTING
        zoutput = wa_input-txa50.



    la_generaldata-descript   = wa_input-txt50.
    la_generaldata-descript2  = wa_input-txa50.
    la_generaldata-serial_no  = wa_input-sernr.
    la_generaldata-invent_no  = wa_input-invnr.

    la_generaldatax-assetclass = 'X'.
    la_generaldatax-descript   = 'X'.
    la_generaldatax-descript2  = 'X'.
    la_generaldatax-serial_no  = 'X'.
    la_generaldatax-invent_no  = 'X'.


    la_inventory-note             = wa_input-note.
    la_inventoryx-note            = 'X'.


    la_postinginformation-cap_date  = wa_input-aktiv.
    la_postinginformationx-cap_date = 'X'.


* To pick up the cost center from cost center file corresponding to legacy dept
    READ TABLE p_cost_table INTO wa_cost
           BINARY SEARCH WITH KEY ldept = wa_input-kostl.


    IF sy-subrc = 0.

* To validate company code
      READ TABLE p_t093c INTO wa_t093c BINARY SEARCH WITH KEY bukrs = wa_cost-bukrs.

      IF sy-subrc <> 0.      "company code not valid

        IF l_flag <> 'X'.
          MOVE-CORRESPONDING wa_input TO wa_error_file.
          l_flag = 'X'.
          wa_error_file-mssg1 = text-029.
        ELSE.
          CONCATENATE wa_error_file-mssg1 text-029
         INTO wa_error_file-mssg1 SEPARATED BY ','.
*        wa_error_file-mssg2 = text-029.
        ENDIF.
      ELSE.

        la_key-companycode  = wa_cost-bukrs.
      ENDIF.

* to validate cost centre
      READ TABLE p_csks INTO wa_csks BINARY SEARCH WITH KEY kostl = wa_cost-kostl.

      IF sy-subrc <> 0.     "cost center not valid

        IF l_flag <> 'X'.
          MOVE-CORRESPONDING wa_input TO wa_error_file.
          l_flag = 'X'.
          wa_error_file-mssg1 = text-030.
        ELSE.
          CONCATENATE wa_error_file-mssg1 text-030
          INTO wa_error_file-mssg1 SEPARATED BY ','.
        ENDIF.

*        wa_error_file-mssg3 = text-030.
      ELSE.

        la_timedependentdata-costcenter  = wa_cost-kostl.
        la_timedependentdata-plant       = wa_cost-werks.
        la_timedependentdata-location    = wa_cost-loc.
        la_timedependentdata-room        = wa_input-room.
        la_timedependentdatax-costcenter = 'X'.
        la_timedependentdatax-plant      = 'X'.
        la_timedependentdatax-location   = 'X'.
        la_timedependentdatax-room       = 'X'.
      ENDIF.
    ELSE.

      IF l_flag <> 'X'.
        MOVE-CORRESPONDING wa_input TO wa_error_file.
        l_flag = 'X'.
        wa_error_file-mssg1 = text-072.

      ELSE.
        CONCATENATE wa_error_file-mssg1 text-072
        INTO wa_error_file-mssg1 SEPARATED BY ','.
      ENDIF.

*      wa_error_file-mssg2 = text-072.

    ENDIF.

    g_no_valid = g_no_valid + 1.

    la_allocations-evalgroup5  = wa_input-gdlgrp.
    la_allocationsx-evalgroup5 = 'X'.

    CALL FUNCTION 'ZFAA_FORMAT_FIELDS'
      EXPORTING
        zinput  = wa_input-liefe
      IMPORTING
        zoutput = wa_input-liefe.

    CALL FUNCTION 'ZFAA_FORMAT_FIELDS'
      EXPORTING
        zinput  = wa_input-typbz
      IMPORTING
        zoutput = wa_input-typbz.

    la_origin-vendor        = wa_input-liefe.
    la_origin-type_name     = wa_input-typbz.
    la_origin-orig_asset    = wa_input-aibn1.
    la_originx-vendor       = 'X'.
    la_originx-type_name    = 'X'.
    la_originx-orig_asset   = 'X'.

*      IF  wa_input-valuedate(4) <> sy-datum(4).

* for depr 01
* To pick up the depr key from dept input file corresponding to legacy depr key
    READ TABLE p_depr_table INTO wa_depr
               BINARY SEARCH WITH KEY ldepr = wa_input-afasl_01.

    IF sy-subrc = 0.

      la_depreciationareas-area             = wa_input-afabe_01.
      la_depreciationareas-dep_key          = wa_depr-afasl.
      la_depreciationareas-ulife_yrs        = wa_input-ndjar_01.
      la_depreciationareas-ulife_prds       = wa_input-ndper_01.
      la_depreciationareas-exp_ulife_yrs    = wa_input-exp_year_01.
      la_depreciationareas-exp_ulife_prds   = wa_input-exp_period_01.

      APPEND la_depreciationareas TO li_depreciationareas.
      CLEAR: la_depreciationareas.

      la_depreciationareasx-area            = wa_input-afabe_01.
      la_depreciationareasx-dep_key         = 'X'.
      la_depreciationareasx-ulife_yrs       = 'X'.
      la_depreciationareasx-ulife_prds      = 'X'.
      la_depreciationareasx-exp_ulife_yrs   = 'X'.
      la_depreciationareasx-exp_ulife_prds  = 'X'.
      APPEND la_depreciationareasx TO li_depreciationareasx.
      CLEAR: la_depreciationareasx.

      la_cumulatedvalues-area = wa_input-afabe_01.
      la_cumulatedvalues-acq_value = wa_input-comm_acq_01.
      la_cumulatedvalues-ord_dep   = wa_input-acc_ord_depr_01.
      APPEND la_cumulatedvalues TO li_cumulatedvalues.
      CLEAR: la_cumulatedvalues.

      la_postedvalues-area    = wa_input-afabe_01.
      la_postedvalues-ord_dep = wa_input-ord_depr_post_01.
      APPEND la_postedvalues TO li_postedvalues.
      CLEAR: la_postedvalues.

    ELSE.

      IF l_flag <> 'X'.
        MOVE-CORRESPONDING wa_input TO wa_error_file.
        l_flag = 'X'.
        CONCATENATE wa_input-afasl_01 text-110 '01'
          INTO wa_error_file-mssg1 SEPARATED BY ','.
      ELSE.
        CONCATENATE wa_error_file-mssg1 wa_input-afasl_01 text-110 '01'
          INTO wa_error_file-mssg1 SEPARATED BY ','.
      ENDIF.

    ENDIF.

* for depr 10
* To pick up the depr key from dept input file corresponding to legacy depr key
    READ TABLE p_depr_table INTO wa_depr
              BINARY SEARCH WITH KEY ldepr  = wa_input-afasl_10.

    IF sy-subrc = 0.

      la_depreciationareas-area             = wa_input-afabe_10.
      la_depreciationareas-dep_key          = wa_depr-afasl.
      la_depreciationareas-ulife_yrs        = wa_input-ndjar_10.
      la_depreciationareas-ulife_prds       = wa_input-ndper_10.
      la_depreciationareas-exp_ulife_yrs    = wa_input-exp_year_10.
      la_depreciationareas-exp_ulife_prds   = wa_input-exp_period_10.
      APPEND la_depreciationareas TO li_depreciationareas.
      CLEAR: la_depreciationareas.

      la_depreciationareasx-area            = wa_input-afabe_10.
      la_depreciationareasx-dep_key         = 'X'.
      la_depreciationareasx-ulife_yrs       = 'X'.
      la_depreciationareasx-ulife_prds      = 'X'.
      la_depreciationareasx-exp_ulife_yrs   = 'X'.
      la_depreciationareasx-exp_ulife_prds  = 'X'.
      APPEND la_depreciationareasx TO li_depreciationareasx.
      CLEAR: la_depreciationareasx.

      la_cumulatedvalues-area = wa_input-afabe_10.
      la_cumulatedvalues-acq_value = wa_input-comm_acq_10.
      la_cumulatedvalues-ord_dep   = wa_input-acc_ord_depr_10.
      la_cumulatedvalues-spe_dep   = wa_input-spe_depr_10.
      APPEND la_cumulatedvalues TO li_cumulatedvalues.
      CLEAR: la_cumulatedvalues.

    ELSE.

      IF l_flag <> 'X'.
        MOVE-CORRESPONDING wa_input TO wa_error_file.
        l_flag = 'X'.
        CONCATENATE wa_input-afasl_10 text-110 '10'
          INTO wa_error_file-mssg1 SEPARATED BY ','.
      ELSE.
        CONCATENATE wa_error_file-mssg1 wa_input-afasl_10 text-110 '10'
          INTO wa_error_file-mssg1 SEPARATED BY ','.
      ENDIF.

    ENDIF.


* for depr 11
* To pick up the depr key from dept input file corresponding to legacy depr key
    READ TABLE p_depr_table INTO wa_depr
             BINARY SEARCH WITH KEY ldepr   = wa_input-afasl_11.

    IF sy-subrc = 0.

      la_depreciationareas-area             = wa_input-afabe_11.
      la_depreciationareas-dep_key          = wa_depr-afasl.
      la_depreciationareas-ulife_yrs        = wa_input-ndjar_11.
      la_depreciationareas-ulife_prds       = wa_input-ndper_11.
      la_depreciationareas-exp_ulife_yrs    = wa_input-exp_year_11.
      la_depreciationareas-exp_ulife_prds   = wa_input-exp_period_11.
      APPEND la_depreciationareas TO li_depreciationareas.
      CLEAR: la_depreciationareas.

      la_depreciationareasx-area            = wa_input-afabe_11.
      la_depreciationareasx-dep_key         = 'X'.
      la_depreciationareasx-ulife_yrs       = 'X'.
      la_depreciationareasx-ulife_prds      = 'X'.
      la_depreciationareasx-exp_ulife_yrs   = 'X'.
      la_depreciationareasx-exp_ulife_prds  = 'X'.
      APPEND la_depreciationareasx TO li_depreciationareasx.
      CLEAR: la_depreciationareasx.

      la_cumulatedvalues-area = wa_input-afabe_11.
      la_cumulatedvalues-ord_dep   = wa_input-acc_ord_depr_11.
      la_cumulatedvalues-spe_dep   = wa_input-spe_depr_11.
      APPEND la_cumulatedvalues TO li_cumulatedvalues.
      CLEAR: la_cumulatedvalues.

    ELSE.

      IF l_flag <> 'X'.
        MOVE-CORRESPONDING wa_input TO wa_error_file.
        l_flag = 'X'.
        CONCATENATE wa_input-afasl_11 text-110 '11'
          INTO wa_error_file-mssg1 SEPARATED BY ','.
      ELSE.
        CONCATENATE wa_error_file-mssg1 wa_input-afasl_11 text-110 '11'
          INTO wa_error_file-mssg1 SEPARATED BY ','.
      ENDIF.

    ENDIF.


* for depr 30
* To pick up the depr key from dept input file corresponding to legacy depr key
    READ TABLE p_depr_table INTO wa_depr
               BINARY SEARCH WITH KEY ldepr  = wa_input-afasl_30.

    IF sy-subrc = 0.

      la_depreciationareas-area             = wa_input-afabe_30.
      la_depreciationareas-dep_key          = wa_depr-afasl.
      la_depreciationareas-ulife_yrs        = wa_input-ndjar_30.
      la_depreciationareas-ulife_prds       = wa_input-ndper_30.
      la_depreciationareas-exp_ulife_yrs    = wa_input-exp_year_30.
      la_depreciationareas-exp_ulife_prds   = wa_input-exp_period_30.
      APPEND la_depreciationareas TO li_depreciationareas.
      CLEAR: la_depreciationareas.

      la_depreciationareasx-area            = wa_input-afabe_30.
      la_depreciationareasx-dep_key         = 'X'.
      la_depreciationareasx-ulife_yrs       = 'X'.
      la_depreciationareasx-ulife_prds      = 'X'.
      la_depreciationareasx-exp_ulife_yrs   = 'X'.
      la_depreciationareasx-exp_ulife_prds  = 'X'.
      APPEND la_depreciationareasx TO li_depreciationareasx.
      CLEAR: la_depreciationareasx.

      la_cumulatedvalues-area = wa_input-afabe_30.

      la_cumulatedvalues-acq_value = wa_input-comm_acq_30.  "MOD001+

      la_cumulatedvalues-ord_dep   = wa_input-acc_ord_depr_30.
      APPEND la_cumulatedvalues TO li_cumulatedvalues.
      CLEAR: la_cumulatedvalues.

*Begin of  MOD001-
*          la_postedvalues-area    = wa_input-afabe_30.
*          la_postedvalues-ord_dep = wa_input-ord_depr_post_30.
*          APPEND la_postedvalues TO li_postedvalues.
*          CLEAR: la_postedvalues.
*End of MOD001-

    ELSE.

      IF l_flag <> 'X'.
        MOVE-CORRESPONDING wa_input TO wa_error_file.
        l_flag = 'X'.
        CONCATENATE wa_input-afasl_30 text-110 '30'
          INTO wa_error_file-mssg1 SEPARATED BY ','.
      ELSE.
        CONCATENATE wa_error_file-mssg1 wa_input-afasl_30 text-110 '30'
          INTO wa_error_file-mssg1 SEPARATED BY ','.
      ENDIF.

    ENDIF.


* for depr 40
* To pick up the depr key from dept input file corresponding to legacy depr key
    READ TABLE p_depr_table INTO wa_depr
               BINARY SEARCH WITH KEY ldepr = wa_input-afasl_40.

    IF sy-subrc = 0.

      la_depreciationareas-area             = wa_input-afabe_40.
      la_depreciationareas-dep_key          = wa_depr-afasl.
      la_depreciationareas-ulife_yrs        = wa_input-ndjar_40.
      la_depreciationareas-ulife_prds       = wa_input-ndper_40.
      la_depreciationareas-exp_ulife_yrs    = wa_input-exp_year_40.
      la_depreciationareas-exp_ulife_prds   = wa_input-exp_period_40.
      APPEND la_depreciationareas TO li_depreciationareas.
      CLEAR: la_depreciationareas.

      la_depreciationareasx-area            = wa_input-afabe_40.
      la_depreciationareasx-dep_key         = 'X'.
      la_depreciationareasx-ulife_yrs       = 'X'.
      la_depreciationareasx-ulife_prds      = 'X'.
      la_depreciationareasx-exp_ulife_yrs   = 'X'.
      la_depreciationareasx-exp_ulife_prds  = 'X'.
      APPEND la_depreciationareasx TO li_depreciationareasx.
      CLEAR: la_depreciationareasx.

      la_cumulatedvalues-area = wa_input-afabe_40.
      la_cumulatedvalues-ord_dep   = wa_input-acc_ord_depr_40.
      APPEND la_cumulatedvalues TO li_cumulatedvalues.
      CLEAR: la_cumulatedvalues.

    ELSE.

      IF l_flag <> 'X'.
        MOVE-CORRESPONDING wa_input TO wa_error_file.
        l_flag = 'X'.
        CONCATENATE wa_input-afasl_40 text-110 '40'
          INTO wa_error_file-mssg1 SEPARATED BY ','.
      ELSE.
        CONCATENATE wa_error_file-mssg1 wa_input-afasl_40 text-110 '40'
          INTO wa_error_file-mssg1 SEPARATED BY ','.
      ENDIF.

    ENDIF.

    IF wa_error_file IS NOT INITIAL.
      wa_error_file-type   = 'E'.
      APPEND wa_error_file TO p_error_table.
      CLEAR: wa_error_file.
    ENDIF.

    IF l_flag <> 'X'.

      IF  wa_input-valuedate(4) <> sy-datum(4).

        CALL FUNCTION 'BAPI_FIXEDASSET_OVRTAKE_CREATE'
          EXPORTING
            key                 = la_key
            testrun             = l_testrun
            generaldata         = la_generaldata
            generaldatax        = la_generaldatax
            inventory           = la_inventory
            inventoryx          = la_inventoryx
            postinginformation  = la_postinginformation
            postinginformationx = la_postinginformationx
            timedependentdata   = la_timedependentdata
            timedependentdatax  = la_timedependentdatax
            allocations         = la_allocations
            allocationsx        = la_allocationsx
            origin              = la_origin
            originx             = la_originx
          IMPORTING
            assetcreated        = la_assetcreated
          TABLES
            depreciationareas   = li_depreciationareas
            depreciationareasx  = li_depreciationareasx
            cumulatedvalues     = li_cumulatedvalues
            postedvalues        = li_postedvalues
            return              = i_return.


      ELSE.

        la_transactions-current_no = '00001'.
        la_transactions-area     = wa_input-area_p1.
        la_transactions-valuedate = wa_input-valuedate.
        la_transactions-assettrtyp = wa_input-tran_type.
        la_transactions-amount     = wa_input-amount_p1.
        APPEND la_transactions TO li_transactions.
        CLEAR:la_transactions.

        la_transactions-current_no = '00001'.
        la_transactions-area     = wa_input-area_p2.
        la_transactions-valuedate = wa_input-valuedate.
        la_transactions-assettrtyp = wa_input-tran_type.
        la_transactions-amount     = wa_input-amount_p2.
        APPEND la_transactions TO li_transactions.
        CLEAR:la_transactions.

        la_transactions-current_no = '00001'.
        la_transactions-area     = wa_input-area_p3.
        la_transactions-valuedate = wa_input-valuedate.
        la_transactions-assettrtyp = wa_input-tran_type.
        la_transactions-amount     = wa_input-amount_p3.
        APPEND la_transactions TO li_transactions.
        CLEAR:la_transactions.


        CALL FUNCTION 'BAPI_FIXEDASSET_OVRTAKE_CREATE'
          EXPORTING
            key                 = la_key
            testrun             = l_testrun
            generaldata         = la_generaldata
            generaldatax        = la_generaldatax
            inventory           = la_inventory
            inventoryx          = la_inventoryx
            postinginformation  = la_postinginformation
            postinginformationx = la_postinginformationx
            timedependentdata   = la_timedependentdata
            timedependentdatax  = la_timedependentdatax
            allocations         = la_allocations
            allocationsx        = la_allocationsx
            origin              = la_origin
            originx             = la_originx
          IMPORTING
            assetcreated        = la_assetcreated
          TABLES
            depreciationareas   = li_depreciationareas
            depreciationareasx  = li_depreciationareasx
            cumulatedvalues     = li_cumulatedvalues
            postedvalues        = li_postedvalues
            transactions        = li_transactions
            return              = i_return.


      ENDIF.


      IF NOT i_return[] IS INITIAL.

        CLEAR: wa_return,
               wa_error_file,
               l_message.


        LOOP AT i_return INTO wa_return.

          IF wa_return-type   = 'S'.

            wa_error_file-type = wa_return-type.
            g_no_load = g_no_load + 1.

            IF l_testrun <> 'X'.

              CONCATENATE text-009 la_assetcreated-asset
                  INTO l_message.

              CLEAR: la_assetcreated.

              CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
            ELSE.

              l_message = text-064.
            ENDIF.

            EXIT.
          ELSE.

            IF l_message IS INITIAL.
              CONCATENATE l_message wa_return-message INTO l_message.
            ELSE.
              CONCATENATE l_message wa_return-message INTO l_message SEPARATED BY ','.
            ENDIF.

          ENDIF.

          CLEAR: wa_return.
        ENDLOOP.


        MOVE-CORRESPONDING wa_input TO wa_error_file.

        IF wa_error_file-type <> 'S'.
          wa_error_file-type = 'E'.
          g_no_failed = g_no_failed + 1.
        ENDIF.

        wa_error_file-mssg1     = l_message.

        APPEND wa_error_file TO p_error_table.
        CLEAR: wa_error_file, l_message.

      ENDIF.


    ELSE.
      g_no_invalid = g_no_invalid + 1.

    ENDIF.

    CLEAR: i_return, wa_input, la_generaldata, la_generaldatax, la_inventory,
        la_inventoryx, la_postinginformation, la_postinginformationx, la_key,
        la_timedependentdata, la_timedependentdatax, la_allocations, la_allocationsx,
        la_origin, la_originx, li_depreciationareas, la_depreciationareas,
        li_depreciationareasx, la_depreciationareasx, li_cumulatedvalues,
        la_cumulatedvalues, li_postedvalues, la_postedvalues, li_transactions,
        la_transactions.
  ENDLOOP.
ENDFORM.

Read only

0 Likes
889

If you find the above example too complex, then you can also refer to the following bapi of material creation.

REPORT  z34332_bdc_create_material              .

data: la_headdata type BAPIMATHEAD,
      la_clientdata type BAPI_MARA,
      la_CLIENTDATAX type BAPI_MARAX,
      la_return type BAPIRET2.

data: i_materialdescription type table of BAPI_MAKT,
      wa_materialdescription like line of i_materialdescription.

la_headdata-MATERIAL = '000000000000000004'.
la_headdata-IND_SECTOR = 'M'.
la_headdata-MATL_TYPE = 'FERT'.

la_clientdata-BASE_UOM = 'FT3'.
la_CLIENTDATAX-BASE_UOM = 'X'.
la_clientdata-MATL_GROUP = '01'.
la_CLIENTDATAX-MATL_GROUP = 'X'.

wa_materialdescription = 'TEST'.
append wa_materialdescription to i_materialdescription.
clear: wa_materialdescription.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
  EXPORTING
    headdata                   = la_headdata
   CLIENTDATA                 = la_clientdata
   CLIENTDATAX                = la_CLIENTDATAX
*   PLANTDATA                  =
*   PLANTDATAX                 =
*   FORECASTPARAMETERS         =
*   FORECASTPARAMETERSX        =
*   PLANNINGDATA               =
*   PLANNINGDATAX              =
*   STORAGELOCATIONDATA        =
*   STORAGELOCATIONDATAX       =
*   VALUATIONDATA              =
*   VALUATIONDATAX             =
*   WAREHOUSENUMBERDATA        =
*   WAREHOUSENUMBERDATAX       =
*   SALESDATA                  =
*   SALESDATAX                 =
*   STORAGETYPEDATA            =
*   STORAGETYPEDATAX           =
*   FLAG_ONLINE                = ' '
*   FLAG_CAD_CALL              = ' '
 IMPORTING
   RETURN                     = la_return
 TABLES
   MATERIALDESCRIPTION        = i_materialdescription
*   UNITSOFMEASURE             =
*   UNITSOFMEASUREX            =
*   INTERNATIONALARTNOS        =
*   MATERIALLONGTEXT           =
*   TAXCLASSIFICATIONS         =
*   RETURNMESSAGES             =
*   PRTDATA                    =
*   PRTDATAX                   =
*   EXTENSIONIN                =
*   EXTENSIONINX               =
          .

write: la_return-TYPE, ',', la_return-MESSAGE.
clear: la_headdata, la_return, la_clientdata, la_clientdatax.

Read only

Former Member
0 Likes
889

Hi Prasad,

go through the link below :

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

you will get step by step creation of BAPI.

reward points if helpful.

Regards,

Hemant

Read only

Former Member
0 Likes
889
Read only

Former Member
0 Likes
889

Hi,

Check this link for a sample code for creating sales order using BAPI.

https://wiki.sdn.sap.com/wiki/display/Snippets/ABAP-Simpleprogramtocreatesalesorderusing+BAPI

Thanks

Naren