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

Looking for Bapi

Former Member
0 Likes
576

hai ...

help me any one this is very very required plese help.

I am Looking for Standarad bapi. the requirement is plant and material and any ...

requiry fields is

Fullyqualifiedname

Type name

created on

modified on

description

icon index source

min

max

this is one of the product in

incuity....

plese help any body

regards

Satish.....

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
543

check this...

BAPI_MATERIAL_SAVEDATA

BAPI_MATERIAL_GET_ALL

3 REPLIES 3
Read only

Former Member
0 Likes
544

check this...

BAPI_MATERIAL_SAVEDATA

BAPI_MATERIAL_GET_ALL

Read only

Former Member
0 Likes
543

Hi Sathibabu,

Here is the sample BAPI code which might be helpful for you to use t he BAPI.

&************Reward Points if helpful****************&


*&---------------------------------------------------------------------*
*& Report  ZCC_BAPI_MM01
*&
*&---------------------------------------------------------------------*
*& Develper: Chidanand Chauhan
*&  Date: 04/27/2006
*&  Desc: Upload MM01 through BAPI
*&---------------------------------------------------------------------*

report  zcc_bapi_mm01 message-id zmm01bap.


*&--declration of tables

*tables :

*&--declration of structure.
types : begin of s_upload,
        material(18) type c,
        ind_sector(1) type c,
        mat_type(4) type c,
        basic_view(1) type c,
        purchase_view(1) type c,
        storage_view(1) type c,
        sale_view(1) type c,
        mrp_view(1) type c,
        mat_group(2) type c,              " start of client data
        base_uom(3) type c,
*        base_uom_iso(3) TYPE c,
        unit_of_wt(3) type c,
*        UNIT_OF_WT_ISO(3) TYPE C,
*        net_weight(13) TYPE c,
        division(2) type c,
        pur_status(2) type c,
        plant(4) type c,                " start of plantdata
        pur_group(3) type c,
        mrp_type(2) type c,
        mrp_ctrler(3) type c,
        period_ind(1) type c,
        lotsizekey(2) type c,
        proc_type(1) type c,
        minlotsize(13) type c,
        maxlotsize(13) type c,
*        proc_type TYPE beskz,
        inhseeprodt(2) type c,
        avaialcheck(2) type c,
        plannplant(4) type c,
        strgplant(4) type c,
        stge_loc(4) type c,
        langu(2) type c,
        " start of storage location
        materialdescription(40) type c,      " table data fro descrip
        sales_org(4) type c,                " sale data
        distr_channel(2) type c,
        alt_unit(3) type c,
        end of s_upload.

data : s_headdata type bapimathead,
       s_clientdata type bapi_mara,
       s_clientdatax type bapi_marax,
       s_plantdata type bapi_marc,
       s_plantdatax type bapi_marcx,
       s_planningdata type bapi_mpgd,
       s_planningdatax type bapi_mpgdx,
       s_storagelocationdata type bapi_mard,
       s_storagelocationdatax type bapi_mardx,
*       s_valuationdatax type bapi_mbew,
*       s_valuationdatax type bapi_mbewx,
       s_salesdata type bapi_mvke,
       s_saledatax type bapi_mvkex,
       s_return type bapiret2,
       s_return1 type bapireturn1.

*&--declration of internal tables.
data : t_upload type table of s_upload,
       t_maktx type table of bapi_makt,
       t_material_number type table of bapimatinr,
       t_measure type table of bapi_marm,
       t_measurex type table of bapi_marm.

*&--declration of work area.
data: w_upload type s_upload,
      w_maktx type bapi_makt,
      w_material_number type bapimatinr,
      w_measure type bapi_marm,
      w_measurex type bapi_marm.

*&--parameters for upload and download.
selection-screen begin of block ssn with frame title text-001 .
parameters: p_upload type ibipparms-path,
            d_chk type checkbox.
selection-screen end of block ssn.

*&--declration of variables.
data: v_filename type ibipparms-path,
      v_progname type sy-repid,
      f_path type string,
      sy_ucomm type sy-ucomm,
      z(60) type c.


initialization.
  refresh t_upload.
  refresh t_measure.
  v_progname = sy-repid.
*&--at selection screen.
at selection-screen.

at selection-screen on value-request for p_upload.
  perform f4_upload.

*&--Perform calling bapi.
start-of-selection.

*&--Perform uplaod of file in internal table.
  perform upload_file.
  perform bapi_create.

end-of-selection.
*&---------------------------------------------------------------------*
*&      Form  f4_upload
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form f4_upload .

  call function 'F4_FILENAME'
   exporting
     program_name        = sy-repid
     dynpro_number       = syst-dynnr
*   FIELD_NAME          = 'p_upload'
   importing
     file_name           = v_filename
     .
  if sy-subrc = 0.
    p_upload = v_filename.

  endif.

endform.                                                    " f4_upload
*&---------------------------------------------------------------------*
*&      Form  upload_file
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form upload_file .

  clear t_upload.
  f_path = v_filename.

  call function 'GUI_UPLOAD'
    exporting
      filename                      =  f_path
     filetype                      =  'ASC'
     has_field_separator           = 'X'
*     HEADER_LENGTH                 = 0
*     READ_BY_LINE                  = 'X'
*     DAT_MODE                      = ' '
*     CODEPAGE                      = ' '
*     IGNORE_CERR                   = ABAP_TRUE
*     REPLACEMENT                   = '#'
*     CHECK_BOM                     = ' '
*   IMPORTING
*     FILELENGTH                    =
*     HEADER                        =
    tables
      data_tab                      =  t_upload
   exceptions
     file_open_error               = 1
     file_read_error               = 2
     no_batch                      = 3
     gui_refuse_filetransfer       = 4
     invalid_type                  = 5
     no_authority                  = 6
     unknown_error                 = 7
     bad_data_format               = 8
     header_not_allowed            = 9
     separator_not_allowed         = 10
     header_too_long               = 11
     unknown_dp_error              = 12
     access_denied                 = 13
     dp_out_of_memory              = 14
     disk_full                     = 15
     dp_timeout                    = 16
     others                        = 17
            .
  if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.

endform.                    " upload_file
*&---------------------------------------------------------------------*
*&      Form  bapi_create
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form bapi_create .

  loop at t_upload into w_upload.

*&--moving wa of header structure.
    s_headdata-material = w_upload-material.
    s_headdata-ind_sector =  w_upload-ind_sector.
    s_headdata-matl_type = w_upload-mat_type.
    s_headdata-basic_view = w_upload-basic_view.
    s_headdata-sales_view = w_upload-sale_view.
    s_headdata-purchase_view = w_upload-purchase_view.
    s_headdata-mrp_view  = w_upload-mrp_view.
    s_headdata-storage_view = w_upload-storage_view.

*&--calling function to get material number, AT CREATE.

    if d_chk = 'X'.
      call function 'BAPI_MATERIAL_GETINTNUMBER'
        exporting
          material_type    = w_upload-mat_type
          industry_sector  = w_upload-ind_sector
          required_numbers = 1
        importing
          return           = s_return1
        tables
          material_number  = t_material_number.

      loop at t_material_number into w_material_number.
        s_headdata-material = w_material_number-material.
      endloop.
    endif.



*&--moving wa of client data .

    s_clientdata-matl_group = w_upload-mat_group.
    s_clientdata-base_uom = w_upload-base_uom.
*    s_clientdata-base_uom_iso = w_upload-base_uom_iso.
    s_clientdata-unit_of_wt = w_upload-unit_of_wt.
*    s_clientdata-unit_of_wt_ISO = w_upload-unit_of_wt_ISO.
*    s_clientdata-net_weight = w_upload-net_weight.
    s_clientdata-division = w_upload-division.
    s_clientdata-pur_status = w_upload-pur_status.


    s_clientdatax-matl_group = 'X'.
    s_clientdatax-base_uom = 'X'.
*    s_clientdataX-base_uom_iso = 'X'.
    s_clientdatax-unit_of_wt = 'X'.
*    s_clientdataX-unit_of_wt_ISO = 'X'.
*    s_clientdataX-net_weight = 'X'.
    s_clientdatax-division = 'X'.
    s_clientdatax-pur_status = 'X'.


*&--moving wa of plantdata
    s_plantdata-plant = w_upload-plant.
    s_plantdata-pur_group = w_upload-pur_group.
    s_plantdata-mrp_type = w_upload-mrp_type.
    s_plantdata-mrp_ctrler = w_upload-mrp_ctrler.
    s_plantdata-period_ind = w_upload-period_ind.
    s_plantdata-lotsizekey = w_upload-lotsizekey.
    s_plantdata-proc_type = w_upload-proc_type.
    s_plantdata-minlotsize = w_upload-minlotsize.
    s_plantdata-maxlotsize = w_upload-maxlotsize.
    s_plantdata-inhseprodt = w_upload-inhseeprodt.
    s_plantdata-availcheck = w_upload-avaialcheck.

    s_plantdatax-plant = w_upload-plant.
    s_plantdatax-pur_group = 'X'.
    s_plantdatax-mrp_type = 'X'.
    s_plantdatax-mrp_ctrler = 'X'.
    s_plantdatax-period_ind = 'X'.
    s_plantdatax-lotsizekey ='X'.
    s_plantdatax-proc_type = 'X'.
    s_plantdatax-minlotsize ='X'.
    s_plantdatax-maxlotsize = 'X'.
    s_plantdatax-inhseprodt = 'X'.
    s_plantdatax-availcheck = 'X'.


*&--moving planningdata.

    s_planningdata-plant = w_upload-plannplant.

    s_planningdatax-plant = w_upload-plannplant.
*&--moving wa storage location.
    s_storagelocationdata-plant = w_upload-strgplant.
    s_storagelocationdata-stge_loc = w_upload-stge_loc.

    s_storagelocationdatax-plant = w_upload-strgplant.
    s_storagelocationdatax-stge_loc = w_upload-stge_loc.

*&--moving wa sales
    s_salesdata-sales_org = w_upload-sales_org.
    s_salesdata-distr_chan = w_upload-distr_channel.

    s_saledatax-sales_org = w_upload-sales_org.
    s_saledatax-distr_chan = w_upload-distr_channel.

*&--append material description
    w_maktx-langu = w_upload-langu.
    w_maktx-matl_desc = w_upload-materialdescription.
    append w_maktx to t_maktx.

*&--appending measurement
    w_measure-alt_unit = w_upload-alt_unit.
    append w_measure to t_measure.

    w_measurex-alt_unit = w_upload-alt_unit.
    append w_measurex to t_measurex.

*&--calling bapi function.
    call function 'BAPI_MATERIAL_SAVEDATA'
      exporting
        headdata                   =   s_headdata
       clientdata                 =    s_clientdata
       clientdatax                =    s_clientdatax
       plantdata                  =    s_plantdata
       plantdatax                 =    s_plantdatax
       planningdata               =   s_planningdata
       planningdatax              =   s_planningdatax
       storagelocationdata        =  s_storagelocationdata
       storagelocationdatax       =  s_storagelocationdatax
       salesdata                  =  s_salesdata
       salesdatax                 =  s_saledatax

     importing
       return                     =  s_return
     tables
       materialdescription        =  t_maktx
              .
    if sy-subrc = 0 .
      z = s_return-message.
      message i002 with z.
    endif.

  endloop.

endform.                    " bapi_create

Read only

Former Member
0 Likes
543

Hi,

Listed the function modules...

BAPI_MATERIAL_GETINTNUMBER

BAPI_MATERIAL_SAVE_DATA

BAPI_MATERIAL_GET_ALL

Regards

Narin Nandivada.