Reg BAPI_MATERIAL_SAVEDATA

Hi All,
  I am using   BAPI_MATERIAL_SAVEDATA to upload data into the sap system.
  I flagged all the required views and required fields.
Fields flagged :  MATHEAD-BASIC_VIEW = 'X'.
                        MATHEAD-MRP_VIEW = 'X'.   MATHEAD LIKE BAPIMATHEAD
          PLANTDATAX-PLANT = 'X'.           PLANTDATA LIKE BAPI_MARC
     PLANTDATAX-ABC_ID = 'X'.      PLANTDATAX LIKE BAPI_MARCX
     PLANTDATAX-MRP_CTRLER = 'X'.
     PLANTDATAX-PLND_DELRY = 'X'.
     PLANTDATAX-SAFETY_STK = 'X'.
     PLANTDATAX-MAX_STOCK = 'X'.
     PLANTDATAX-INHSEPRODT = 'X'.
     PLANTDATAX-HANDLG_GRP = 'X'.
     PLANTDATAX-MIN_SAFETY_STK = 'X'.
     The data is being read from the excel file into the corresponding fields of the structure PLANTDATA .
       And then i passed these 3 structures as parameters in the Function Module.The FM is getting executed successfully.
            But it is not getting updated into the SAP.

hi
good
pls check this code
*& Report ZMMR_DELETEPO                                               *
*&  Author                    : Bikash Agarwal
*&  Description               : VTLS PO Change
*&  Program Objective         : Places a DELETION indicator for the PO
*&                              items given in the VTLS data
*&  Remarks                   : NA
REPORT ZMMR_DELETEPO NO STANDARD PAGE HEADING MESSAGE-ID zisb.
tables : zvtls_sap.
*C-- Types Declarations
TYPES : BEGIN OF tp_flatfile_vtls,
        ebeln(10),
        ebelp type ekpo-ebelp,
        END OF tp_flatfile_vtls.
*=====================================================================
                  INTERNAL TABLES DECLARATION
*=====================================================================
DATA:  t_flatfile_vtls TYPE tp_flatfile_vtls OCCURS 0 WITH HEADER LINE.
data : begin of t_sapdata occurs 0,
       po like zvtls_sap-posap,
       item like zvtls_sap-itemsap,
       end of t_sapdata.
data : begin of t_flatfile_vtls1 occurs 0,
       po(10),
       item like zvtls_sap-itemsap,
       end of t_flatfile_vtls1.
data : begin of t_update occurs 0,
       mandt like zvtls_sap-mandt,
       povtls like zvtls_sap-povtls,
       itemvtls like zvtls_sap-itemvtls,
       posap like zvtls_sap-posap,
       itemsap like zvtls_sap-itemsap,
       aedat like zvtls_sap-aedat,
       paedt like zvtls_sap-paedt,
       loekz like zvtls_sap-loekz,
       end of t_update.
data : begin of t_poheader occurs 0,
       po like zvtls_sap-posap,
       end of t_poheader.
data : begin of t_poitem occurs 0,
       po like zvtls_sap-posap,
       item like zvtls_sap-itemsap,
       end of t_poitem.
DATA : BEGIN OF T_MESSAGE OCCURS 0,
       MSGTY,
       MSGID(2),
       MSGNO(3),
       MSGTX(100),
       PO like zvtls_sap-povtls,
       item like zvtls_sap-itemvtls,
       END OF T_MESSAGE.
DATA : BEGIN OF t_bapi_poheader OCCURS 0.
        INCLUDE STRUCTURE bapimepoheader.
DATA : END OF t_bapi_poheader.
DATA : BEGIN OF t_bapi_poheaderx OCCURS 0.
        INCLUDE STRUCTURE bapimepoheaderx.
DATA : END OF t_bapi_poheaderx.
DATA : BEGIN OF t_bapi_poitem OCCURS 0.
        INCLUDE STRUCTURE bapimepoitem.
DATA : END OF t_bapi_poitem.
DATA : BEGIN OF t_bapi_poitemx OCCURS 0.
        INCLUDE STRUCTURE bapimepoitemx.
DATA : END OF t_bapi_poitemx.
DATA : BEGIN OF t_bapireturn OCCURS 0.
        INCLUDE STRUCTURE bapiret2.
DATA : END OF t_bapireturn.
*=====================================================================
                  V A R I A B L E S
*=====================================================================
DATA: w_success(6)  TYPE n,
      w_bklas like t023-bklas,
      w_curryear(4),
      w_begda like sy-datum,
      w_endda like sy-datum,
      w_begyr(4),
      w_endyr(4),
      w_currmon(2),
      w_assetclass like ankt-anlkl,
      w_price type p,
      w_recordsap type i,
      w_povtls(10),
      w_count type i.
DATA:  w_filepath TYPE rlgrap-filename,
       w_rc TYPE sy-subrc,
       w_sscrfields_ucomm1   TYPE sscrfields-ucomm,
       w_file1 TYPE string,
       w_file2 TYPE FILENAME-FILEINTERN.
*=====================================================================
                  C O N S T A N T S
*=====================================================================
CONSTANTS: c_x              TYPE  c         VALUE 'X',
           c_hyp            TYPE  c         VALUE '-',
           c_err            TYPE  bdc_mart  VALUE 'E'.
CONSTANTS:  c_slash(1)            TYPE c VALUE '/',
            c_hash(1)             TYPE c VALUE '#',
            c_pipe                TYPE c VALUE '|',
            c_1                   TYPE i VALUE 1,
            c_zero                TYPE n VALUE '0',
            c_rg1(3)              TYPE c VALUE 'rg1',
            c_gr3(3)              TYPE c VALUE 'GR3',
            c_gr2(3)              TYPE c VALUE 'GR2',
            c_e(1)                TYPE c VALUE 'E',
            c_filepath(8)         TYPE c VALUE '/interf/',
            c_filetype(10)        TYPE c VALUE 'ASC'.
CONSTANTS : c_bapimepoheaderx   TYPE x030l-tabname
                               VALUE 'bapimepoheaderx',
           c_bapimepoitem      TYPE  x030l-tabname
                               VALUE 'bapimepoitem',
           c_bapimepoaccount   TYPE  x030l-tabname
                               VALUE 'bapimepoaccount',
           c_t_bapi_poheader(15)        TYPE c
                                        VALUE 't_bapi_poheader',
           c_t_bapi_poitem(13)          TYPE c
                                        VALUE 't_bapi_poitem',
           c_t_bapi_poitemx(14)         TYPE c
                                        VALUE 't_bapi_poitemx',
           c_t_bapi_poheaderx(16)       TYPE c
                                        VALUE 't_bapi_poheaderx'.
CLASS cl_abap_char_utilities DEFINITION LOAD.
CONSTANTS:con_tab  TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
*======================================================================
                       SELECTION SCREEN
*======================================================================
SELECTION-SCREEN BEGIN OF BLOCK inputpath WITH FRAME TITLE text-001.
SELECTION-SCREEN : BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
PARAMETERS : p_fore RADIOBUTTON GROUP rg1
                    USER-COMMAND pc,
             p_back RADIOBUTTON GROUP rg1 DEFAULT 'X'.
SELECTION-SCREEN : END OF BLOCK blk2.
SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-003.
PARAMETERS :  p_file1 LIKE rlgrap-filename OBLIGATORY MODIF ID gr2.
PARAMETERS :  p_afile1 LIKE rlgrap-filename OBLIGATORY MODIF ID gr3.
SELECTION-SCREEN : END OF BLOCK blk1.
SELECTION-SCREEN END OF BLOCK inputpath.
*C-- Initialization Event
INITIALIZATION.
  CLEAR w_filepath.
  CONCATENATE c_filepath sy-sysid c_slash sy-mandt c_slash INTO
  w_filepath.
  CONDENSE w_filepath NO-GAPS.
  p_file1 = text-008.
  p_afile1 = text-009.
*======================================================================
                       SELECTION SCREEN EVENTS
*======================================================================
*C-- Selection Screen Output
AT SELECTION-SCREEN OUTPUT.
  IF p_fore = c_x.
    w_sscrfields_ucomm1 = space.
  ELSE.
    w_sscrfields_ucomm1 = c_rg1.
  ENDIF.
  LOOP AT SCREEN.
*C--Modify selection screen if presentation
*C--or application server radio button is chosen
    IF w_sscrfields_ucomm1 = space.
      IF screen-group1 = c_gr3.
        screen-active = c_zero.
      ENDIF.
    ELSE.
      IF screen-group1 = c_gr2.
        screen-active = c_zero.
      ENDIF.
    ENDIF.
    if screen-name = 'P_AFILE1'.
      screen-input = 0.
    ENDIF.
    MODIFY SCREEN.
  ENDLOOP.
*C-- Selection Screen VALUE-REQUEST FOR File path
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file1.
  IF p_fore EQ c_x.
    CALL FUNCTION 'F4_FILENAME'
      EXPORTING
        program_name  = syst-cprog
        dynpro_number = syst-dynnr
      IMPORTING
        file_name     = p_file1.
  ENDIF.
*C-- At Start of the Selection Process
START-OF-SELECTION.
  IF p_fore EQ c_x.
    w_file1 = p_file1.
  ELSE.
    w_file2 = p_afile1.
  ENDIF.
  IF p_fore EQ c_x. " Presentaion Server
*C--Validations for the input files
    PERFORM validate_pre_file USING p_file1.
*C-- Load the contents of the input file into the internal table
    PERFORM upload_file TABLES t_flatfile_vtls
                        USING w_file1
                        CHANGING w_rc.
    IF w_rc <> 0.
      MESSAGE s006 DISPLAY LIKE c_e.
    ENDIF.
  ELSE. " Application Server
*C--Validations for the input files
    PERFORM validate_app_file USING  w_file2.
*C-- Load the contents of the input file into the internal table
    PERFORM upload_file_app TABLES t_flatfile_vtls
                            USING w_file2
                            CHANGING w_rc.
  ENDIF.
  loop at t_flatfile_vtls.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = t_flatfile_vtls-ebeln
      IMPORTING
        output = t_flatfile_vtls1-po.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = t_flatfile_vtls-ebelp
      IMPORTING
        output = t_flatfile_vtls1-item.
    append t_flatfile_vtls1.
    clear t_flatfile_vtls1.
  endloop.
  perform get_podata.
  loop at t_poheader.
    perform move_to_bapi.
    perform call_bapi.
  endloop.
  PERFORM STORE_MESSAGES TABLES T_MESSAGE.
*&      Form  validate_pre_file
    Routine to validate presentation server file path.
     -->fp_name  text
FORM validate_pre_file USING fp_name TYPE rlgrap-filename.
  DATA : l_result,
         l_filename TYPE string.
  l_filename = fp_name.
  CLEAR l_result.
  CALL METHOD cl_gui_frontend_services=>file_exist
    EXPORTING
      file                 = l_filename
    RECEIVING
      result               = l_result
    EXCEPTIONS
      cntl_error           = 1
      error_no_gui         = 2
      wrong_parameter      = 3
      not_supported_by_gui = 4
      OTHERS               = 5.
  IF sy-subrc <> 0.
    MESSAGE s007 DISPLAY LIKE c_e.
    LEAVE LIST-PROCESSING.
  ELSEIF l_result IS INITIAL.
    MESSAGE s008 DISPLAY LIKE c_e.
    LEAVE LIST-PROCESSING.
  ENDIF.
ENDFORM.                    " validate_pre_file_hdr
*&      Form  validate_app_file
      text - Checks if the path entered and filename is correct
FORM validate_app_file USING  fp_file  TYPE FILENAME-FILEINTERN.
  data : l_fname(60).
  CALL FUNCTION 'FILE_GET_NAME'
    EXPORTING
      LOGICAL_FILENAME = FP_FILE
      OPERATING_SYSTEM = SY-OPSYS
    IMPORTING
      FILE_NAME        = L_FNAME
    EXCEPTIONS
      FILE_NOT_FOUND   = 1
      OTHERS           = 2.
  IF SY-SUBRC = '0'.
    OPEN DATASET  L_FNAME FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc NE 0.
      MESSAGE s007 DISPLAY LIKE c_e.
    ELSE.
      CLOSE DATASET l_fname.
    ENDIF.
  ENDIF.
ENDFORM.                    " validate_app_file
*&      Form  upload_file
      Routine to upload data from file to tables.
     -->P_fp_flatfile
     -->P_fp_file
     <--P_fp_rc
FORM  upload_file TABLES   fp_flatfile
                  USING    fp_file TYPE string
                  CHANGING fp_rc TYPE sy-subrc.
  IF fp_flatfile[] IS INITIAL.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                = fp_file
        filetype                = c_filetype
        has_field_separator     = c_x
      TABLES
        data_tab                = fp_flatfile
      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.
    MOVE sy-subrc TO fp_rc.
  ENDIF.
ENDFORM.  " upload_file
*&      Form  upload_file_app
      text
     -->FP_FLATFILEtext
     -->FP_FILE    text
     -->FP_RC      text
FORM  upload_file_app TABLES   fp_flatfile
                      USING    fp_file TYPE FILENAME-FILEINTERN
CHANGING fp_rc TYPE sy-subrc.
  DATA: l_string TYPE tedata-data.
  DATA: wa_data_file TYPE tp_flatfile_vtls,
        l_wllength TYPE i,
        FNAME(60).
  CALL FUNCTION 'FILE_GET_NAME'
    EXPORTING
      LOGICAL_FILENAME = FP_FILE
      OPERATING_SYSTEM = SY-OPSYS
    IMPORTING
      FILE_NAME        = FNAME
    EXCEPTIONS
      FILE_NOT_FOUND   = 1
      OTHERS           = 2.
  IF SY-SUBRC = 0.
    OPEN DATASET  FNAME FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc NE 0.
*C-- commented by Bikash
     MESSAGE s107(yaero_ps) DISPLAY LIKE c_e.
      message e008.
    ELSE.
      DO.
        CLEAR: l_string.
        READ DATASET  FNAME INTO l_string LENGTH l_wllength.
        IF sy-subrc NE 0.
          EXIT.
        ELSE.
          SPLIT l_string AT con_tab INTO   wa_data_file-ebeln
                                           wa_data_file-ebelp.
          APPEND wa_data_file TO fp_flatfile.
        ENDIF.
      ENDDO.
      CLOSE DATASET  FNAME.
    ENDIF.
  ENDIF.
ENDFORM.  " upload_file_app
*&      Form  get_podata
      text
form get_podata.
  select *
  into table t_update
  from zvtls_sap
  for all entries in t_flatfile_vtls1
   where itemvtls = t_flatfile_vtls1-item
  and povtls = t_flatfile_vtls1-po.
  sort t_update by posap itemsap.
  loop at t_update.
    at new posap.
      t_poheader-po = t_update-posap.
      append t_poheader.
      clear t_poheader.
    endat.
    t_poitem-po = t_update-posap.
    t_poitem-item = t_update-itemsap.
    append t_poitem.
    clear t_poitem.
    t_update-paedt = sy-datum.
    t_update-loekz = 'X'.
    modify t_update.
  endloop.
  modify zvtls_sap from table t_update.
endform.                    "get_podata
*&      Form  move_to_bapi
      text
form move_to_bapi.
  t_bapi_poheader-po_number = t_poheader-po.
  CLEAR t_bapi_poheaderx.
  PERFORM fill_check_structure USING c_bapimepoheaderx
                                     c_t_bapi_poheader
                                     c_t_bapi_poheaderx
                                     c_x.
  refresh : t_bapi_poitem,t_bapi_poitemx.
  loop at t_poitem where po = t_poheader-po.
    clear t_bapi_poitem.
    t_bapi_poitem-po_item = t_poitem-item.
    t_bapi_poitem-delete_ind = 'X'.
    CLEAR t_bapi_poitemx.
    PERFORM fill_check_structure USING c_bapimepoitem
                                       c_t_bapi_poitem
                                       c_t_bapi_poitemx
                                       c_x.
    t_bapi_poitemx-po_item = t_poitem-item.
    t_bapi_poitemx-po_itemx = c_x.
    APPEND t_bapi_poitem.
    APPEND t_bapi_poitemx.
    clear t_bapi_poitem.
    clear t_bapi_poitemx.
  endloop.
endform.                    "move_to_bapi
*&      Form  call_bapi
      This form Routine is used to commit the data records
FORM call_bapi .
  DATA : l_msgty      TYPE c,
         l_msgid(2)   TYPE c,
         l_msgno(3)   TYPE c,
         l_msgtx(100) TYPE c,
         l_errflag    TYPE c.
  CLEAR: t_bapireturn.
  REFRESH: t_bapireturn.
  CALL FUNCTION 'BAPI_PO_CHANGE'
    EXPORTING
      PURCHASEORDER = T_POHEADER-PO
      POHEADER      = T_BAPI_POHEADER
      POHEADERX     = T_BAPI_POHEADERX
    TABLES
      RETURN        = T_BAPIRETURN
      POITEM        = T_BAPI_POITEM
      POITEMX       = T_BAPI_POITEMX.
  READ TABLE t_bapireturn WITH KEY type = c_err TRANSPORTING NO FIELDS.
  IF sy-subrc NE 0.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait = c_x.
  ENDIF.
*C-- Write messages
  WRITE: / 'PO Number', t_poheader-po.
  clear : t_update,w_povtls.
  read table t_update with key posap = t_poheader-po.
  w_povtls = t_update-povtls.
  CLEAR l_errflag.
  LOOP AT t_bapireturn.
    CLEAR: l_msgty, l_msgid, l_msgno, l_msgtx.
    l_msgty = t_bapireturn-type.
    l_msgid = t_bapireturn-id.
    l_msgno = t_bapireturn-number.
    l_msgtx = t_bapireturn-message.
    WRITE: / l_msgty, l_msgid, l_msgno, l_msgtx.
    if l_msgtx cs t_poheader-po.
      w_count = w_count + 1.
      loop at t_update.
        if sy-tabix = w_count.
          t_message-item = t_update-itemvtls.
        endif.
      endloop.
    endif.
    t_message-msgty = l_msgty.
    t_message-msgid = l_msgid.
    t_message-msgno = l_msgno.
    t_message-msgtx = l_msgtx.
    t_message-po = w_povtls.
    append t_message.
    clear t_message.
    IF l_msgty EQ c_err.
      l_errflag = c_x.
    ENDIF.    " l_msgty EQ 'E'
  ENDLOOP.
  ULINE.
  IF l_errflag NE c_x.
    w_success = w_success + 1.
  ENDIF.    " l_errflag NE C_X
endform.                    "call_bapi
*&      Form  fill_check_structure
      This form Routine will check whether the specified structure
      exist/active
FORM fill_check_structure  USING    fp_tabname TYPE any
                                    fp_orgtabname TYPE any
                                    fp_chktabname TYPE any
                                    fp_check TYPE c.
  FIELD-SYMBOLS : <fs_chk>, <fs_org>.
  DATA:    l_char1(61)  TYPE c,
           l_char2(61)  TYPE c.
  DATA:    BEGIN OF tl_nametab OCCURS 60.
          INCLUDE STRUCTURE x031l.
  DATA:    END OF tl_nametab.
  REFRESH tl_nametab.
  CALL FUNCTION 'RFC_GET_NAMETAB'
    EXPORTING
      tabname          = fp_tabname
    TABLES
      nametab          = tl_nametab
    EXCEPTIONS
      table_not_active = 1
      OTHERS           = 2.
  IF sy-subrc <> 0.
    CLEAR tl_nametab.
  ENDIF.
  LOOP AT tl_nametab.
    CLEAR: l_char1, l_char2.
    CONCATENATE fp_chktabname c_hyp tl_nametab-fieldname INTO l_char1.
    ASSIGN (l_char1) TO <fs_chk>.
    CONCATENATE fp_orgtabname c_hyp tl_nametab-fieldname INTO l_char2.
    ASSIGN (l_char2) TO <fs_org>.
    IF <fs_org> IS NOT INITIAL.
      <fs_chk> = fp_check.
    ENDIF.
  ENDLOOP.
ENDFORM.                    " fill_check_structure
*&      Form  STORE_MESSAGES
      text
     -->FP_MESSAGEStext
FORM STORE_MESSAGES TABLES FP_MESSAGES STRUCTURE T_MESSAGE.
  DATA: wl_output_data LIKE t_MESSAGE.
  DATA: l_catstr TYPE string.
  DATA: l_fieldvalue TYPE string.
  DATA: l_index TYPE i VALUE 1.
  DATA: L_FNAME(60).
  FIELD-SYMBOLS <fs>.
  CLEAR l_catstr.
  CALL FUNCTION 'FILE_GET_NAME'
    EXPORTING
      LOGICAL_FILENAME = '/USR/SAP/VTLS/POCHANGE/LOG'
      OPERATING_SYSTEM = SY-OPSYS
    IMPORTING
      FILE_NAME        = L_FNAME
    EXCEPTIONS
      FILE_NOT_FOUND   = 1
      OTHERS           = 2.
  IF SY-SUBRC = '0'.
    IF fp_messages[] IS NOT INITIAL.
      OPEN DATASET L_FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc NE 0.
        LEAVE LIST-PROCESSING.
      ELSE.
        LOOP AT fp_messages INTO wl_output_data.
          DO.
           ASSIGN COMPONENT l_index OF STRUCTURE wl_output_data TO <fs>.
            IF sy-subrc <> 0.
              EXIT.
            ENDIF.
            MOVE <fs> TO l_fieldvalue.
            IF l_catstr IS NOT INITIAL.
              CONCATENATE l_catstr l_fieldvalue INTO l_catstr SEPARATED
              BY con_tab.
            ELSE.
              MOVE l_fieldvalue TO l_catstr.
            ENDIF.
            l_index = l_index + c_1.
            CLEAR l_fieldvalue.
            CLEAR <fs>.
          ENDDO.
          l_index = c_1.
          TRANSFER l_catstr TO L_FNAME .
          CLEAR wl_output_data.
          CLEAR l_catstr.
        ENDLOOP.
        CLOSE  DATASET L_FNAME.
      ENDIF.
    ENDIF.
  ENDIF.
ENDFORM.                    "STORE_MESSAGES
reward point if helpful.
thanks
mrutyun^

Similar Messages

  • How to select a custom view in BAPI_MATERIAL_SAVEDATA

    In our company we have defined some CUSTOM views for different materials. I want to select a custom view in the header data but don't see an option. The only options I see are as follows:
    MATERIAL
    IND_SECTOR
    MATL_TYPE
    BASIC_VIEW
    SALES_VIEW
    PURCHASE_VIEW
    MRP_VIEW
    FORECAST_VIEW
    WORK_SCHED_VIEW
    PRT_VIEW
    STORAGE_VIEW
    WAREHOUSE_VIEW
    QUALITY_VIEW
    ACCOUNT_VIEW
    COST_VIEW
    INP_FLD_CHECK
    MATERIAL_EXTERNAL
    MATERIAL_GUID
    MATERIAL_VERSION
    How can I select a view (in BAPI_MATERIAL_SAVEDATA) that's not a standard SAP view?
    Please help!
    Thanks.

    Hi,
    which views do you select in the structure HEADDATA? Do you select STORAGE_VIEW?
    Cheers

  • Error while creating a material using Bapi_material_savedata

    Hi,
    there is an error encountered while creating a material using BAPI_MATERIAL_SAVEDATA..
    The Error description is " Material description is not transfered " even after supplying the Material description and other mandatory field information like industrial sector, material type ,basic view indicator,Base UOM,Base UOM ISO code.
    Please let me know the solution, if you know.

    Hi,
    Please search the SCN for the answers
    https://www.sdn.sap.com/irj/scn/advancedsearch?query=errorinBAPI_MATERIAL_SAVEDATA+&cat=sdn_all

  • Problem  while Creating /Maintaing Data in R/3 (BAPI_MATERIAL_SAVEDATA)

    Hi,
          I am Developing a WebDynPro(Java) appln to connect R/3.For this i used BAPI_MATERIAL_SAVEDATA which module is for Creating/Updating  Material Data.I have Used the materialName,Description,Uniof Measure,Material Type as Input to R/3. while running The Appln it is fine to Connect R/3 and Its Bringing return Msges as "1)Trying To Create Material 2)The Material Cannot Be Maintained since no Maintainable data Transferred".That is I can not Create/SAVE material Data..Whether Anything might be wrong while Transferring Data ?What Type Of Pblm is This ? Did u ever come across The Pblm like this ? How to solve This ?
    Please Help Me Out

    Hi,
    In the Import parameters HEADDATA shows it is a Mandatory and for the remaining Structures you just instantiate it and Set it to the BAPI Element.
    Ex:- ComplexType_ZBAPI_FICA currentRelation = new ComplexType_ZBAPI_FICA();
    chgRelation.setCURR_BP_RELATIONSHIP(currentRelation);
    //chgRelation - BAPI Element
    //ComplexType_ZBAPI_FICA - Import type
    Regards,
    Sridhar
    Message was edited by: Sridhar kanchanapalli

  • Mail can't send email from 123-reg accounts

    Hi all,
    I've got an issue with Mac Mail can’t send email from 123-reg accounts.
    I know there is a lot of articles on simular matters and some I have tried out with no luck, others are just speaking a whole other language.
    Any help would be greatly recived, here's my situation below:
    Running a iMac 2.8GHz Intel Core i5 on OS X 10.8.3
    I’m using 3 accounts on Macs Mail client, one is my iCloud account that is working fine and the other two are my 123-reg accounts that I use for business purposes. I’ve been working like this for a couple of years now and about 6 months ago I upgrade my operating system from Snow Leopard to Mountain Lion.
    2 or 3 months ago I randomly got a problem where I was unable to send any emails from my 123-reg account, I could only receive emails. I checked my settings and they were all correct and unchanged so I attempted to delete them and recreate the account but with no such luck.
    I then decided to check if it was a problem at 123-regs end and attempted to log into web mail. This worked and was able to both send and receive emails so eliminated that possibility.
    I also have these accounts set up on my iPhone, so checked if there was any issues and everything was working fine. I then checked my iphone details and made sure the same was on my desktop and still no such luck.
    I’ve tried out some of the articles I’ve found on here (the ones written in plain English) still no results. I’m not very IT illiterate and just wondered if anyone else has got any ideas, whether there is something specific with 123-reg accounts and Mac Mail?
    Many thanks.

    Thanks
    I just had another hunt around looking at posts and discovered that it was because I recently changed to BT Infinity and they had a block on.
    I didn't even think to question the ISP.
    https://discussions.apple.com/message/21173608#21173608

  • Report using BAPI_MATERIAL_SAVEDATA

    Hi All,
    can anyone send me the report where
    BAPI_MATERIAL_SAVEDATA is used to create the material.
    if anyone has then plz share with me.
    Thanks
    Sanjeev

    Hi All,
    can anyone send me the report where
    BAPI_MATERIAL_SAVEDATA is used to create the material.
    if anyone has then plz share with me.
    Thanks
    Sanjeev

  • Reg: Message and BPM

    Hi
    I'm having a scenario where i use a JDBC adapter to extract data from a DB. As a result of the query say, 10 rows are returned as message to XI server. I have a transformation (BPM) set and the receiver(target system) is a file. When i open the file to see its contents i can see only the first record been transfered. The mapping part used for the transformation node is having IF condition. But all the fetched records satisfies the conditions in the mapping.
    Pls let me know the corrective step.
    reg: Prabhu

    Hi,
    1)Check the input XML i.e all 10 records are coming into XI . This you can check in SXMB_MONI
    2) Then you can test the mapping in the integration Reposiotry .. So now you can get if any mapping problem. For this , check is the occurence of target strcuture is 1..n or 0.n
    /people/michal.krawczyk2/blog/2005/09/16/xi-how-to-test-your-mapping-in-real-life-scenarios
    3) If mapping is correct , then check the RWB->Message Monitoring->Message Display Tool and check the payload.
    4) If this is correct, then check the File COntent Conversion of the Receiver File Adapter.
    Hope this helps,
    Regards,
    Moorthy

  • Need help in using FM BAPI_MATERIAL_SAVEDATA

    Gurus,
    I need help in using the FM BAPI_MATERIAL_SAVEDATA. The FM is returning a message that says "The field MARA-MEINS/BAPI_MARA-BASE_UOM(_ISO) is defined as a required field; it does not contain an entry".
    I have supplied the necessary details and yet the FM won't push through.
    If possible, please post sample codes.
    Below is my sample code:
    ===============================================
    REPORT  zmm_materialupload.
    eject
    $$******************************************************************************
    $$    TYPES
    $$******************************************************************************
    eject
    $$******************************************************************************
    $$    INTERNAL TABLES (custom structure
    $$******************************************************************************
    eject
    $$******************************************************************************
    $$    RANGES
    $$******************************************************************************
    eject
    $$******************************************************************************
    $$    FIELD-SYMBOLS
    $$******************************************************************************
    eject
    $$******************************************************************************
    $$    PARAMETERS & SELECT-OPTIONS
    $$******************************************************************************
    SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE text-001.
    *SELECT-OPTIONS: s_matnr FOR mara-matnr.
    SELECT-OPTIONS: s_mtart FOR mara-mtart.
    SELECT-OPTIONS: s_mbrsh FOR mara-mbrsh DEFAULT 'P'.
    SELECT-OPTIONS: s_werks FOR marc-werks DEFAULT '1000' OBLIGATORY.
    SELECT-OPTIONS: s_lgort FOR marc-lgpro DEFAULT 'OPSL' OBLIGATORY.
    PARAMETERS: p_path  LIKE rlgrap-filename DEFAULT 'C:\Documents and Settings\training_11\Desktop\Book4 (2ITEMS).txt' OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK 1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          field_name = 'P_FNAME'
        IMPORTING
          file_name  = p_path.
    eject
    $$******************************************************************************
    $$    START-OF-SELECTION
    $$******************************************************************************
    START-OF-SELECTION.
      PERFORM check_input.
      PERFORM get_file.
      PERFORM filter_input.
    PERFORM populate_tabs.
      PERFORM bapi_mat.
    eject
    $$******************************************************************************
    $$    FORMS
    $$******************************************************************************
    FORM bapi_mat.
      LOOP AT it_tab INTO wa_tab.
        CALL FUNCTION 'BAPI_MATERIAL_GETINTNUMBER'
          EXPORTING
            material_type    = wa_tab-mtart
            industry_sector  = wa_tab-mbrsh
            required_numbers = 1
          TABLES
            material_number  = it_matnr.
      ENDLOOP.
      LOOP AT it_matnr INTO wa_matnr.
        READ TABLE it_tab INTO wa_tab INDEX sy-tabix.
        wa_tab-matnr = wa_matnr-material.
        MODIFY it_tab FROM wa_tab INDEX sy-tabix.
      ENDLOOP.
      PERFORM populate_tabs.
      CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
        EXPORTING
         headdata                   = it_headdata
        clientdata                 = it_clientdata
        clientdatax                = it_clientdatax
        plantdata                  = it_plantdata
        plantdatax                 = it_plantdatax
        FORECASTPARAMETERS         =
        FORECASTPARAMETERSX        =
        PLANNINGDATA               =
        PLANNINGDATAX              =
        STORAGELOCATIONDATA        =
        STORAGELOCATIONDATAX       =
        valuationdata              = it_valuationdata
        valuationdatax             = it_valuationdatax
         WAREHOUSENUMBERDATA        =
        WAREHOUSENUMBERDATAX       =
        SALESDATA                  =
        SALESDATAX                 =
        STORAGETYPEDATA            =
        STORAGETYPEDATAX           =
        flag_online                = ' '
        flag_cad_call              = ' '
        NO_DEQUEUE                 = ' '
        NO_ROLLBACK_WORK           = ' '
       IMPORTING
         return                     = it_return
       TABLES
         materialdescription        = it_materialdescription
         unitsofmeasure             = it_unitsofmeasure
         unitsofmeasurex            = it_unitsofmeasurex
         internationalartnos        = it_internationalartnos
         materiallongtext           = it_materiallongtext
         taxclassifications         = it_taxclassifications
         returnmessages             = it_returnmessages
        PRTDATA                    =
        PRTDATAX                   =
        EXTENSIONIN                =
        EXTENSIONINX               =
      IF sy-subrc = 0.
      ENDIF.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait   = 'X'
        IMPORTING
          return = it_return.
    ENDFORM.                    "bapi_mat
    *&      Form  GET_FILE
          text
    FORM get_file.
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
          text = 'Getting data from file...'.
      MOVE: p_path TO gv_file.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = gv_file
          filetype                = 'ASC'
          has_field_separator     = 'X'
          read_by_line            = 'X'
        TABLES
          data_tab                = it_tab
        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.                    "GET_FILE
    *&      Form  check_input
          text
    FORM check_input.
    Material Type
      IF s_mtart-low IS INITIAL AND s_mtart-high IS INITIAL.
       s_mtart = 'IEQ'.
       s_mtart-low = 'ABF'.        "Waste
       s_mtart-high = 'ZTRD'.      "Stock Items
       APPEND s_mtart.
      ENDIF.
      IF s_mtart-low IS NOT INITIAL AND s_mtart-high IS INITIAL.
        MOVE: s_mtart-low TO s_mtart-high.
      ENDIF.
    Industry Sector
      IF s_mbrsh-low IS INITIAL AND s_mbrsh-high IS INITIAL.
       s_mbrsh = 'IEQ'.
       SELECT mbrsh
       FROM mara
       INTO TABLE it_mbrsh.
       s_mbrsh-low = wa_mbrsh-mbrsh.
       LOOP AT it_mbrsh INTO wa_mbrsh.
         s_mbrsh-high = wa_mbrsh-mbrsh.
       ENDLOOP.
       APPEND s_mbrsh.
      ENDIF.
      IF s_mbrsh-low IS NOT INITIAL AND s_mbrsh-high IS INITIAL.
        MOVE: s_mbrsh-low TO s_mbrsh-high.
      ENDIF.
    Plant
      IF s_werks-low IS INITIAL AND s_werks-high IS INITIAL.
        s_werks = 'IEQ'.
        s_werks-low = '1000'.
        s_werks-high = '2000'.
      ENDIF.
      IF s_werks-low IS NOT INITIAL AND s_werks-high IS INITIAL.
        MOVE: s_werks-low TO s_werks-high.
      ENDIF.
    Storage Location
      IF s_lgort-low IS NOT INITIAL AND s_lgort-high IS INITIAL.
        MOVE: s_lgort-low TO s_lgort-high.
      ENDIF.
    ENDFORM.                    "check_input
    *&      Form  Filter_input
          text
    FORM filter_input.
      SORT it_tab BY matnr mtart mbrsh werks lgort.
      LOOP AT it_tab INTO wa_tab.
       IF wa_tab-mtart NOT IN s_mtart.
         DELETE it_tab WHERE mtart NOT IN s_mtart.
       ENDIF.
       IF wa_tab-mbrsh NOT IN s_mbrsh.
         DELETE it_tab WHERE mbrsh NOT IN s_mbrsh.
       ENDIF.
        IF wa_tab-werks NOT IN s_werks.
          DELETE it_tab WHERE werks NOT IN s_werks.
        ENDIF.
        IF wa_tab-lgort NOT IN s_lgort.
          DELETE it_tab WHERE lgort NOT IN s_lgort.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "Filter_input
    *&      Form  populate_tabs
          text
    FORM    populate_tabs.
      LOOP AT it_tab INTO wa_tab.
        MOVE: wa_tab-matnr TO wa_headdata-material,
              wa_tab-mbrsh TO wa_headdata-ind_sector,
              wa_tab-mtart TO wa_headdata-matl_type,
                       'X' TO wa_headdata-basic_view,
                       'X' TO wa_headdata-sales_view,
                       'X' TO wa_headdata-purchase_view,
                       'X' TO wa_headdata-mrp_view,
                       'X' TO wa_headdata-account_view.
             wa_tab-matkl TO wa_clientdata-matl_group,
             wa_tab-meins TO wa_clientdata-base_uom,
             wa_tab-groes TO wa_clientdata-size_dim,
             wa_tab-gewei TO wa_clientdata-unit_of_wt,
             wa_tab-ntgew TO wa_clientdata-net_weight,
                      'X' TO wa_clientdatax-matl_group,
                      'X' TO wa_clientdatax-base_uom,
                      'X' TO wa_clientdata-size_dim,
                      'X' TO wa_clientdatax-unit_of_wt,
                      'X' TO wa_clientdatax-net_weight,
             wa_tab-werks TO wa_plantdata-plant,
             wa_tab-ekgrp TO wa_plantdata-pur_group,
             wa_tab-prctr TO wa_plantdata-profit_ctr,
             wa_tab-werks TO wa_plantdatax-plant,
                      'X' TO wa_plantdatax-pur_group,
                      'X' TO wa_plantdatax-profit_ctr,
             wa_tab-werks TO wa_valuationdata-val_area,
             wa_tab-bklas TO wa_valuationdata-val_class,
             wa_tab-peinh TO wa_valuationdata-price_unit,
             wa_tab-verpr TO wa_valuationdata-moving_pr,
             wa_tab-stprs TO wa_valuationdata-std_price,
             wa_tab-xlifo TO wa_valuationdata-lifo_fifo,
             wa_tab-werks TO wa_valuationdatax-val_area,
                      'X' TO wa_valuationdatax-val_class,
                      'X' TO wa_valuationdatax-price_unit,
                      'X' TO wa_valuationdatax-moving_pr,
                      'X' TO wa_valuationdatax-std_price,
                      'X' TO wa_valuationdatax-lifo_fifo.
        APPEND wa_headdata TO it_headdata.
       APPEND wa_clientdata TO it_clientdata.
       APPEND wa_plantdata TO it_plantdata.
       APPEND wa_valuationdata TO it_valuationdata.
       MODIFY it_tab FROM wa_tab TRANSPORTING matnr.
      ENDLOOP.
    ENDFORM.                    "populate_tabs
    $$******************************************************************************

    Hai.
    check the below example.
    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.
    regards.
    sowjanya.b.

  • Report problem with BAPI_MATERIAL_SAVEDATA (help required)

    hi all,
    i am using this source code to create material using
    BAPI_MATERIAL_SAVEDATA.
    when i am executing the program,
    i am getting message the material no 512 transferred without leading 0.
    but when i am checking the mara table i am not getting the material 512 created.
    my program is as follows plz check where i am wrong ? why i am not able to create the material using this program.what changes i have to make in this program so that i will be successful in creating material.?
    *& Report  ZCREATE_MATERIAL
    *& Developer
    *& Date:   &DATE
                   STRUCTURE  DECLARATIONS                             *
    Report:zcreate_material.
    TABLES: BAPIMATHEAD,  "Headerdata
            BAPI_MARA,    "Clientdata
            BAPI_MARAX,   "Clientdatax
            BAPI_MARC,    "Plantdata
            BAPI_MARCX,   "Plantdatax
            BAPI_MAKT,    "Material description
            BAPIRET2.     "Return messages
    DATA:V_FILE TYPE STRING.
    DATA:
      BEGIN OF LSMW_MATERIAL_MASTER,
        MATNR(018) TYPE C,  "Material number
        MTART(004) TYPE C,  "Material type
        MBRSH(001) TYPE C,  "Industry sector
        WERKS(004) TYPE C,  "Plant
        MAKTX(040) TYPE C,  "Material description
       DISMM(002) TYPE C,  "Extra Field Added In the Program as
    *itsrequired
        MEINS(003) TYPE C,  "Base unit of measure
       MATKL(009) TYPE C,  "Material group
       SPART(002) TYPE C,  "Division
       LABOR(003) TYPE C,  "Lab/office
       PRDHA(018) TYPE C,  "Product hierarchy
       MSTAE(002) TYPE C,  "X-plant matl status
       MTPOS_MARA(004) TYPE C,  "Gen item cat group
       BRGEW(017) TYPE C,  "Gross weight
       GEWEI(003) TYPE C,  "Weight unit
       NTGEW(017) TYPE C,  "Net weight
       GROES(032) TYPE C,  "Size/Dimensions
       MAGRV(004) TYPE C,  "Matl grp pack matls
       BISMT(018) TYPE C,  "Old material number
       WRKST(048) TYPE C,  "Basic material
       PROFL(003) TYPE C,  "DG indicator profile
       KZUMW(001) TYPE C,  "Environmentally rlvt
       BSTME(003) TYPE C,  "Order unit
       VABME(001) TYPE C,
       EKGRP(003) TYPE C,  "Purchasing group
       XCHPF(001) TYPE C,  "Batch management
       EKWSL(004) TYPE C,  "Purchasing key value
       WEBAZ(003) TYPE C,  "GR processing time
       MFRPN(040) TYPE C,  "Manufacturer part number
       MFRNR(010) TYPE C,  "Manufacturer number
       VPRSV(001) TYPE C,  "Price control indicator
       STPRS(015) TYPE C,  "Standard price
       BWPRH(014) TYPE C,  "Commercial price1
       BKLAS(004) TYPE C,  "Valuation class
      END OF LSMW_MATERIAL_MASTER.
                   INTERNAL TABLE DECLARATIONS                         *
    *to store the input data
    DATA:
      BEGIN OF it_matmaster OCCURS 0.
            INCLUDE STRUCTURE LSMW_MATERIAL_MASTER.
    DATA:END OF it_matmaster.
    *for material description
    DATA:BEGIN OF IT_MATERIALDESC OCCURS 0.
         INCLUDE STRUCTURE BAPI_MAKT .
    DATA:END OF IT_MATERIALDESC.
    *to return messages
    DATA:BEGIN OF IT_RETURN OCCURS 0.
         INCLUDE STRUCTURE BAPIRET2.
    DATA:END OF IT_RETURN.
    SELECTION SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.
    PARAMETERS:P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1 .
    AT SELECTION SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          PROGRAM_NAME  = SYST-CPROG
          DYNPRO_NUMBER = SYST-DYNNR
          FIELD_NAME    = 'P_FILE'
        IMPORTING
          FILE_NAME     = P_FILE.
                   TO UPLOAD THE DATA                                  *
    START-OF-SELECTION.
    V_FILE = P_FILE.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                      = V_FILE
       FILETYPE                      = 'ASC'
       HAS_FIELD_SEPARATOR           = 'X'
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      tables
        data_tab                      =  IT_MATMASTER
    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.
                   DATA POPULATIONS                                    *
    LOOP AT  IT_MATMASTER.
      BAPIMATHEAD-MATERIAL = IT_MATMASTER-MATNR.
      BAPIMATHEAD-IND_SECTOR = IT_MATMASTER-Mbrsh.
      BAPIMATHEAD-MATL_TYPE = IT_MATMASTER-Mtart.
      BAPIMATHEAD-BASIC_VIEW = 'X'.
    BAPIMATHEAD-PURCHASE_VIEW = 'X'.
    BAPIMATHEAD-ACCOUNT_VIEW = 'X'.
    BAPI_MARA-MATL_GROUP = IT_MATMASTER-MATKL.
    BAPI_MARA-OLD_MAT_NO = IT_MATMASTER-BISMT.
      BAPI_MARA-BASE_UOM = IT_MATMASTER-MEINS.
    BAPI_MARA-BASIC_MATL = IT_MATMASTER-WRKST.
    BAPI_MARA-MFR_NO = IT_MATMASTER-MFRNR.
    BAPI_MARAX-MATL_GROUP = 'X'.
    BAPI_MARAX-OLD_MAT_NO = 'X'.
      BAPI_MARAX-BASE_UOM = 'X'.
    BAPI_MARAX-BASIC_MATL = 'X'.
    BAPI_MARAX-MFR_NO = 'X'.
    BAPI_MARC-PLANT = IT_MATMASTER-WERKS.
    BAPI_MARC-PUR_GROUP = IT_MATMASTER-EKGRP.
    BAPI_MARCX-PLANT = IT_MATMASTER-WERKS.
    BAPI_MARCX-PUR_GROUP = 'X'.
      IT_MATERIALDESC-LANGU = 'EN'.
      IT_MATERIALDESC-MATL_DESC = IT_MATMASTER-MAKTX.
      append IT_materialdesc.
      CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
        EXPORTING
          headdata                   = BAPIMATHEAD
          CLIENTDATA                 = BAPI_MARA
          CLIENTDATAX                = BAPI_MARAx
        PLANTDATA                  = BAPI_MARc
        PLANTDATAX                 = BAPI_MARcx
        FORECASTPARAMETERS         =
        FORECASTPARAMETERSX        =
        PLANNINGDATA               =
        PLANNINGDATAX              =
        STORAGELOCATIONDATA        =
        STORAGELOCATIONDATAX       =
        VALUATIONDATA              =
        VALUATIONDATAX             =
        WAREHOUSENUMBERDATA        =
        WAREHOUSENUMBERDATAX       =
        SALESDATA                  =
        SALESDATAX                 =
        STORAGETYPEDATA            =
        STORAGETYPEDATAX           =
        FLAG_ONLINE                = ' '
        FLAG_CAD_CALL              = ' '
       IMPORTING
         RETURN                     = IT_RETURN
       TABLES
         MATERIALDESCRIPTION        = IT_MATERIALDESC
        UNITSOFMEASURE             =
        UNITSOFMEASUREX            =
        INTERNATIONALARTNOS        =
        MATERIALLONGTEXT           =
        TAXCLASSIFICATIONS         =
        RETURNMESSAGES             =
        PRTDATA                    =
        PRTDATAX                   =
        EXTENSIONIN                =
        EXTENSIONINX               =
      Bapi to commit the changes
        IF sy-subrc <> 0.
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
            EXPORTING
              wait = 'X'.
        ENDIF.
    WRITE:/    IT_RETURN-TYPE,
            2   IT_RETURN-ID,
            22  IT_RETURN-NUMBER,
            25  IT_RETURN-MESSAGE.
               IT_RETURN-LOG_NO,
               IT_RETURN-LOG_MSG_NO,
               IT_RETURN-MESSAGE_V1,
               IT_RETURN-MESSAGE_V2,
               IT_RETURN-MESSAGE_V3,
               IT_RETURN-MESSAGE_V4,
               IT_RETURN-PARAMETER,
               IT_RETURN-ROW,
               IT_RETURN-FIELD,
               IT_RETURN-SYSTEM.
    ENDLOOP.
    thanks
    sanjeev

    Actually your COMMIT call not at all executed.
    IF sy-subrc <> 0.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    wait = 'X'.
    ENDIF.
    The sy-subrc = 0 after the BAPI executed, the right way is after BAPI call check the bapi RETURN table has any error, if not commit the BAPI otherwise rollback.

  • BAPI_MATERIAL_SAVEDATA not updating the materials

    Hi Folks,
    I am trying using the BAPI_MATERIAL_SAVEDATA to change the MRP Type of the existing articles. Basically to mass update the articles.I am passing the Material only to the BAPIMATHEAD parameter and also populating the BAPI_MARC where the MRP type has to be changed and I also populate the corresponding BAPI_MARCX with 'X' that has to be changed to the Function Module. I could find when debugging the error message E 091 MH 'You must use retail functions to process the article' that is generated from another function module MATERIAL_MAINTAIN_DARK 'within BAPI_MATERIAL_SAVEDATA. I am using the FM as given below.
    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
      EXPORTING
        headdata                   = i_bapimathead
      CLIENTDATA                 = i_bapimara
      CLIENTDATAX                = i_bapimarax
        PLANTDATA                  = i_bapimarc
        PLANTDATAX                 = i_bapimarcx
    IMPORTING
       RETURN                     = i_bapireturn.
    TABLES
      MATERIALDESCRIPTION        =
      UNITSOFMEASURE             =
      UNITSOFMEASUREX            =
      INTERNATIONALARTNOS        =
      MATERIALLONGTEXT           =
      TAXCLASSIFICATIONS         =
      RETURNMESSAGES             =
      PRTDATA                    =  i_BAPIHM
      PRTDATAX                   =  i_BAPIHMX.
      EXTENSIONIN                =
      EXTENSIONINX               =
    Please help me understand if I have missed anything as why I am getting this error message. Many thanks.
    Regards,
    Tim

    REPORT Z_NEW_PROGRAM .
    *                STRUCTURE  DECLARATIONS                             *
    TABLES: BAPIMATHEAD,  "Headerdata
            BAPI_MARA,    "Clientdata
            BAPI_MARAX,   "Clientdatax
            BAPI_MARC,    "Plantdata
            BAPI_MARCX,   "Plantdatax
            BAPI_MAKT,    "Material description
            BAPIRET2.     "Return messages
    DATA:V_FILE TYPE STRING.
    DATA:
      BEGIN OF LSMW_MATERIAL_MASTER,
        MATNR(018) TYPE C,  "Material number
        MTART(004) TYPE C,  "Material type
        MBRSH(001) TYPE C,  "Industry sector
        WERKS(004) TYPE C,  "Plant
        MAKTX(040) TYPE C,  "Material description
        DISMM(002) TYPE C,  "Extra Field Added In the Program as itsrequired
        MEINS(003) TYPE C,  "Base unit of measure
        MATKL(009) TYPE C,  "Material group
        SPART(002) TYPE C,  "Division
        LABOR(003) TYPE C,  "Lab/office
        PRDHA(018) TYPE C,  "Product hierarchy
        MSTAE(002) TYPE C,  "X-plant matl status
        MTPOS_MARA(004) TYPE C,  "Gen item cat group
        BRGEW(017) TYPE C,  "Gross weight
        GEWEI(003) TYPE C,  "Weight unit
        NTGEW(017) TYPE C,  "Net weight
        GROES(032) TYPE C,  "Size/Dimensions
        MAGRV(004) TYPE C,  "Matl grp pack matls
        BISMT(018) TYPE C,  "Old material number
        WRKST(048) TYPE C,  "Basic material
        PROFL(003) TYPE C,  "DG indicator profile
        KZUMW(001) TYPE C,  "Environmentally rlvt
        BSTME(003) TYPE C,  "Order unit
        VABME(001) TYPE C,
        EKGRP(003) TYPE C,  "Purchasing group
        XCHPF(001) TYPE C,  "Batch management
        EKWSL(004) TYPE C,  "Purchasing key value
        WEBAZ(003) TYPE C,  "GR processing time
        MFRPN(040) TYPE C,  "Manufacturer part number
        MFRNR(010) TYPE C,  "Manufacturer number
        VPRSV(001) TYPE C,  "Price control indicator
        STPRS(015) TYPE C,  "Standard price
        BWPRH(014) TYPE C,  "Commercial price1
        BKLAS(004) TYPE C,  "Valuation class
      END OF LSMW_MATERIAL_MASTER.
    *                INTERNAL TABLE DECLARATIONS                         *
    *to store the input data
    DATA:
      BEGIN OF it_matmaster OCCURS 0.
            INCLUDE STRUCTURE LSMW_MATERIAL_MASTER.
    DATA:
      END OF it_matmaster.
    *for material description
    DATA:BEGIN OF IT_MATERIALDESC OCCURS 0.
         INCLUDE STRUCTURE BAPI_MAKT .
    DATA:END OF IT_MATERIALDESC.
    *to return messages
    DATA:BEGIN OF IT_RETURN OCCURS 0.
         INCLUDE STRUCTURE BAPIRET2.
    DATA:END OF IT_RETURN.
    *  SELECTION SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.
    PARAMETERS:P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1 .
    * AT SELECTION SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          PROGRAM_NAME  = SYST-CPROG
          DYNPRO_NUMBER = SYST-DYNNR
          FIELD_NAME    = 'P_FILE'
        IMPORTING
          FILE_NAME     = P_FILE.
    *                TO UPLOAD THE DATA                                  *
    START-OF-SELECTION.
    V_FILE = P_FILE.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                      = V_FILE
       FILETYPE                      = 'ASC'
       HAS_FIELD_SEPARATOR           = 'X'
    *   HEADER_LENGTH                 = 0
    *   READ_BY_LINE                  = 'X'
    *   DAT_MODE                      = ' '
    * IMPORTING
    *   FILELENGTH                    =
    *   HEADER                        =
      tables
        data_tab                      =  IT_MATMASTER
    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.
    *                DATA POPULATIONS                                    *
    LOOP AT  IT_MATMASTER.
      BAPIMATHEAD-MATERIAL = IT_MATMASTER-MATNR.
      BAPIMATHEAD-IND_SECTOR = IT_MATMASTER-Mbrsh.
      BAPIMATHEAD-MATL_TYPE = IT_MATMASTER-Mtart.
      BAPIMATHEAD-BASIC_VIEW = 'X'.
      BAPIMATHEAD-PURCHASE_VIEW = 'X'.
      BAPIMATHEAD-ACCOUNT_VIEW = 'X'.
      BAPI_MARA-MATL_GROUP = IT_MATMASTER-MATKL.
      BAPI_MARA-OLD_MAT_NO = IT_MATMASTER-BISMT.
      BAPI_MARA-BASE_UOM = IT_MATMASTER-MEINS.
      BAPI_MARA-BASIC_MATL = IT_MATMASTER-WRKST.
      BAPI_MARA-MFR_NO = IT_MATMASTER-MFRNR.
      BAPI_MARAX-MATL_GROUP = 'X'.
      BAPI_MARAX-OLD_MAT_NO = 'X'.
      BAPI_MARAX-BASE_UOM = 'X'.
      BAPI_MARAX-BASIC_MATL = 'X'.
      BAPI_MARAX-MFR_NO = 'X'.
      BAPI_MARC-PLANT = IT_MATMASTER-WERKS.
      BAPI_MARC-PUR_GROUP = IT_MATMASTER-EKGRP.
      BAPI_MARCX-PLANT = IT_MATMASTER-WERKS.
      BAPI_MARCX-PUR_GROUP = 'X'.
      IT_MATERIALDESC-LANGU = 'EN'.
      IT_MATERIALDESC-MATL_DESC = IT_MATMASTER-MAKTX.
      append IT_materialdesc.
      CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
        EXPORTING
          headdata                   = BAPIMATHEAD
          CLIENTDATA                 = BAPI_MARA
          CLIENTDATAX                = BAPI_MARAx
         PLANTDATA                  = BAPI_MARc
         PLANTDATAX                 = BAPI_MARcx
    *     FORECASTPARAMETERS         =
    *     FORECASTPARAMETERSX        =
    *     PLANNINGDATA               =
    *     PLANNINGDATAX              =
    *     STORAGELOCATIONDATA        =
    *     STORAGELOCATIONDATAX       =
    *     VALUATIONDATA              =
    *     VALUATIONDATAX             =
    *     WAREHOUSENUMBERDATA        =
    *     WAREHOUSENUMBERDATAX       =
    *     SALESDATA                  =
    *     SALESDATAX                 =
    *     STORAGETYPEDATA            =
    *     STORAGETYPEDATAX           =
    *     FLAG_ONLINE                = ' '
    *     FLAG_CAD_CALL              = ' '
       IMPORTING
         RETURN                     = IT_RETURN
       TABLES
         MATERIALDESCRIPTION        = IT_MATERIALDESC
    *     UNITSOFMEASURE             =
    *     UNITSOFMEASUREX            =
    *     INTERNATIONALARTNOS        =
    *     MATERIALLONGTEXT           =
    *     TAXCLASSIFICATIONS         =
    *     RETURNMESSAGES             =
    *     PRTDATA                    =
    *     PRTDATAX                   =
    *     EXTENSIONIN                =
    *     EXTENSIONINX               =
    WRITE:/    IT_RETURN-TYPE,
            2   IT_RETURN-ID,
            22  IT_RETURN-NUMBER,
            25  IT_RETURN-MESSAGE.
    *            IT_RETURN-LOG_NO,
    *            IT_RETURN-LOG_MSG_NO,
    *            IT_RETURN-MESSAGE_V1,
    *            IT_RETURN-MESSAGE_V2,
    *            IT_RETURN-MESSAGE_V3,
    *            IT_RETURN-MESSAGE_V4,
    *            IT_RETURN-PARAMETER,
    *            IT_RETURN-ROW,
    *            IT_RETURN-FIELD,
    *            IT_RETURN-SYSTEM.
    ENDLOOP.
    are you using this bapi BAPI_TRANSACTION_COMMIT,
    after calling the BAPI_MATERIAL_SAVEDATA .
    if not use that and check it.
    thanks
    vijay

  • Reg: How to Stop Polling of JDBC Adapter without Scheduling the adapter

    Dear Gurus,
    Here I am having one requirement. My clients wants to send data from JDBC adapter (ORcale System table) to R3 system via RFC.
    His Requirement::
    1. He is not telling the time of data flow from Oracle server so that based on that we can schedule the adapter in the Communication Channel monitoring (Availablitiy Time Planning) or Else we can Schedule by deciding the setting of the polling interval time.
    2. He is telling that When ever he waants to send the data he will place one dummy file in the File Adapter FTP location so that it will became an Indication for u to poll the jdbc adapter and to transfer the data to R3.
    3. Untill he keeps the file or gives indication he doesn;t want to communicate with Oracle server due to some security and it s a most important data base he doesn't want to disturb that Oracle Server as so many business are running  on that.....
    We Proposed::
    1. Atleast you need to tell the scheduling time or poll interval time so that we can schedule our adapter.
    but he s not accepting for this
    2. Atleast U need to give access for Data base to enter one more extra field like STATUS CODE so that we will add one number and we keep on Update in the Update table and based on that Update table statement it will poll.
    but he s not even accepting for this
    3. Finally we prposed that to create another table in the Oracle SYstem as Dulplicate Table which is similar to Standard Orginal table when ever he wants to pick the data please keep that data in this Duplicate TABle so that JDBC adapter will pick the data from thsi TABLE instead of picking the data from that standard table so that it will not effect any standard table data in the table.
    but he s not even accepting for this
    We have done some R & D:::
    1. WE approached even through BPM and via switch conditions is one scenario
       FILE RECEIVE >SWITCH CONDITION> RECEIVE AND SEND or else EXIT
    2. Using correlation in anotehr scenario means correlating File adapter and JDBC and based on one dynamica value it will goes to SEND STEP ( RECE IVE --> RECEIVE --> SEND STEPS )
    Even though we know this...concept that...we jsut tried::
    In BPM we can control the flow in XI 3.0 but we cannot Stop the Polling of JDBC adapter at backend because one the data comes from FILE adapter it will keep on HOLD untill it receives the JDBC from Oracle then based on the condition or Correlation it will goes futher SEND step means after that file adapter is picking file or not ...what ever it may be JDBC will polls at backend and brings that data to BPM"
    Hence sugest me How to Stop Polling of JDBC Adapter without Scheduling the adapter or else using STATUS CODE Update statements in JDBC Tables 
    Regards:
    Amar Srinivas Eli

    Hi! All,
    Finally I decided to do the scenario in two steps:
    1: FILE REQ --> JDBC REQ -->JDBC RES --> FILE RECV
    2: FILE RECV --> RFC
    But I am getting issue while doing first scenario
    Desgn :
    I have created 2 Synchronous interfaces :
    1) FILE 2 JDBC REQ
    In this a) out put message is FILE  Req
              b) Input msage:; FILE RES
    2} JDBC2FILE RECV
            a) Output mesage;; JDBC REQ
            b) Input Msge :: JDBC Response
    Mappings:
    1) File REQ-->JDBC REQ
    2) JDBC RES-->FILE RES
    Interface mappings:
    1: FILE 2 JDBC REQ--> JDBC 2 FLE RECV
    CONFIGURATION ::
    1: One Seder File CC
    2: Two reciever CC's one is for JDBC RECEIVER and other s FILE RECEIVER
    3; One Sender Agreement
    4: 2 Recver agreements
    5: One Interface Determination and
    6: One RECCV Determination
    My Question;;
    1. First let confirm whether my development steps are right or not ?
    2: Another thing s I am not sure reg Configuration Steps means
    whetehr one interface determination and one Receiver Determinations are required or not as these are synchronous Interfaces
    3: main Issue is::::
    If my scenario s FILE2RFC2FILE then I will get RFC response automatically but here issue is this is JDBC
    My reqquirement is By sending one Field from fILE to JDBC REQ it needs to send entire TAbLE records as a Response to file as XML
    without having Sender JDBC how can I send the JDBC Res to FILE and If that is the case then again JDBC adapter is polling which is contradict to the client requuirement which i explained above.
    pleas suggest me the Detailed steps mainly Colloboration agreements and logical routings and
    also explain in detail if i can  go for BPM
    Also give cleear blogs but before giving make sure that it contains detailed screen shots because aIready gone thorugh
    Scenario File-JDBC-RFC
    File<-->JDBC Sync coomunication.
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/xi/file-rfc-file(Without+BPM)
    /people/luis.melgar/blog/2008/05/13/synchronous-soap-to-jdbc--end-to-end-walkthrough
    Regards::
    Amar Srinivas Eli

  • Problem in using BAPI_MATERIAL_SAVEDATA

    I want to extend a Material from Plant A to Plant B. I am getting the following error.
    E   MM         360 Key fields for user data PLANTDATA and checkbox structure PLANTDATAX are different
    Please correct in the following code
    data: la_headdata type BAPIMATHEAD,
    la_clientdata type BAPI_MARA,
    la_CLIENTDATAX type BAPI_MARAX,
    la_PLANTDATA type BAPI_marc,    "Plant View
    la_PLANTDATAX type bapi_marcx,  "Plant View
    la_mbew  type  bapi_mbew,    "Accounting View
    la_mbewx  type bapi_mbewx.
    *la_return type BAPIRET2.
    *to return messages
    DATA:BEGIN OF la_RETURN OCCURS 0.
            INCLUDE STRUCTURE BAPIRET2.
    DATA:END OF la_RETURN.
    data: i_materialdescription type table of BAPI_MAKT,
          wa_mat_desc like line of i_materialdescription.
    Header
    la_headdata-MATERIAL = '000001000000004000'.
    la_headdata-IND_SECTOR = 'M'.
    la_headdata-MATL_TYPE = 'ZALB'.
        la_headdata-basic_view      = 'X'.
        la_headdata-purchase_view   = 'X'.
        la_headdata-account_view    = 'X'.
        la_headdata-MRP_VIEW        = 'X'.
        la_headdata-STORAGE_VIEW    = 'X'.
        la_headdata-COST_VIEW       = 'X'.
    Client Data - Basic
    la_clientdata-BASE_UOM = 'EA'.
    la_CLIENTDATAX-BASE_UOM = 'X'.
    la_clientdata-MATL_GROUP = '21001000'.
    la_CLIENTDATAX-MATL_GROUP = 'X'.
    la_clientdata-unit_of_wt     = 'KG'.
    la_clientdatax-unit_of_wt    = 'X'.
    la_clientdata-division       = '10'.
    la_clientdatax-division      = 'X'.
    Material Description
    wa_mat_desc-langu           = 'E'.
    wa_mat_desc-MATL_DESC = '+TLA,FILTER KIT,BUNDLE B'.
    append wa_mat_desc to i_materialdescription.
    clear: wa_mat_desc.
    Plant - Purchasing
    la_PLANTDATA-plant     = '5530'.
    la_PLANTDATAX-plant     = 'X'.
    la_PLANTDATA-pur_group     = '006'.
    la_PLANTDATAX-pur_group    = 'X'.
    Accounting
    la_mbew-val_area = '5530'.
    la_mbewx-val_area = 'X'.
    la_mbew-price_ctrl = 'S'.
    la_mbewx-price_ctrl = 'X'.
    la_mbew-std_price = '0.01'.
    la_mbewx-std_price = 'X'.
    *la_mbew-price_unit = '1.000'.
    *la_mbewx-price_unit = 'X'.
    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
    EXPORTING
    headdata = la_headdata
    CLIENTDATA = la_clientdata
    CLIENTDATAX = la_CLIENTDATAX
    PLANTDATA = la_PLANTDATA
    PLANTDATAX = la_PLANTDATAX
    FORECASTPARAMETERS =
    FORECASTPARAMETERSX =
    PLANNINGDATA =
    PLANNINGDATAX =
    STORAGELOCATIONDATA =
    STORAGELOCATIONDATAX =
    VALUATIONDATA = la_mbew
    VALUATIONDATAX = la_mbewx
    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 =
    read table la_return with key TYPE = 'S'.
      if sy-subrc = 0.
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
      endif.
      WRITE:/ la_RETURN-TYPE,
        2 la_RETURN-ID,
        22 la_RETURN-NUMBER,
        25 la_RETURN-MESSAGE.

    Hi,
    hope this code gives you an idea
    *& Report ZKAR_MATMAS_BAPI
    *& This program demonstrates how easy it is to create Material master
    *& data using BAPI_MATERIAL_SAVEDATA
    *& The program also generates a report post-execution displaying errors
    *& as well as successful uploads
    REPORT ZKAR_MATMAS_BAPI.
    * TABLES
    * FLAGS *
    DATA: F_STOP. " Flag used to stop processing
    * DATA DECLARATIONS *
    DATA : V_EMPTY TYPE I, " No. of empty records
    V_TOTAL TYPE I. " Total no. of records.
    * STRUCTURES & INTERNAL TABLES
    *BAPI structures
    DATA: BAPI_HEAD LIKE BAPIMATHEAD, " Header Segment with Control Information
    BAPI_MAKT LIKE BAPI_MAKT, " Material Description
    BAPI_MARA1 LIKE BAPI_MARA, " Client Data
    BAPI_MARAX LIKE BAPI_MARAX, " Checkbox Structure for BAPI_MARA
    BAPI_MARC1 LIKE BAPI_MARC, " Plant View
    BAPI_MARCX LIKE BAPI_MARCX, " Checkbox Structure for BAPI_MARC
    BAPI_MBEW1 LIKE BAPI_MBEW, " Accounting View
    BAPI_MBEWX LIKE BAPI_MBEWX, " Checkbox Structure for BAPI_MBEW
    BAPI_RETURN LIKE BAPIRET2. " Return Parameter
    *--- Internal table to hold excel file data
    DATA: IT_INTERN TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
    *--- Internal table to hold Matetrial descriptions
    DATA: BEGIN OF IT_MAKT OCCURS 100.
            INCLUDE STRUCTURE BAPI_MAKT.
    DATA: END OF IT_MAKT.
    *--- Internal to hold the records in the text file
    DATA : BEGIN OF IT_DATA OCCURS 100,
                WERKS(4), " Plant
                MTART(4), " Material type
                MATNR(18), " Material number
                MATKL(9) , " Material group
                MBRSH(1), " Industry sector
                MEINS(3), " Base unit of measure
                GEWEI(3), " Weight Unit
                SPART(2), " Division
                EKGRP(3), " Purchasing group
                VPRSV(1), " Price control indicator
                STPRS(12), " Standard price
                PEINH(3), " Price unit
                SPRAS(2), " Language key
                MAKTX(40), " Material description
                END OF IT_DATA.
    * SELECTION SCREEN. *
    SELECTION-SCREEN BEGIN OF BLOCK SCR1 WITH FRAME TITLE TEXT-111.
    PARAMETER : P_FILE TYPE RLGRAP-FILENAME OBLIGATORY DEFAULT " Input File
    'C:\Material_master.XLS'.
    PARAMETER : P_MAX(4) OBLIGATORY DEFAULT '100'. " no.of recs in a session
    PARAMETERS: P_HEADER TYPE I DEFAULT 0. " Header Lines
    PARAMETERS: P_BEGCOL TYPE I DEFAULT 1 NO-DISPLAY,
    P_BEGROW TYPE I DEFAULT 1 NO-DISPLAY,
    P_ENDCOL TYPE I DEFAULT 100 NO-DISPLAY,
    P_ENDROW TYPE I DEFAULT 32000 NO-DISPLAY.
    SELECTION-SCREEN END OF BLOCK SCR1.
    * AT SELECTION-SCREEN *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
    *--- Validating file
      PERFORM VALIDATE_FILE USING P_FILE.
    * START-OF-SELECTION
    START-OF-SELECTION.
    *--- Perform to convert the Excel data into an internal table
      PERFORM CONVERT_XLS_ITAB.
      IF NOT IT_DATA[] IS INITIAL.
    *--- Perform to delete Header lines
        PERFORM DELETE_HEADER_EMPTY_RECS.
      ENDIF.
    * END OF SELECTION. *
    END-OF-SELECTION.
    *--- Perform to upload Material Master data
      PERFORM UPLOAD_MATMAS.
    * Form : validate_input_file
    * Description : To provide F4 help for file if read from PC
    FORM VALIDATE_FILE USING F_FILE TYPE RLGRAP-FILENAME.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        CHANGING
          FILE_NAME     = F_FILE
        EXCEPTIONS
          MASK_TOO_LONG = 1
          OTHERS        = 2.
      IF SY-SUBRC <> 0.
        MESSAGE S010(ZLKPL_MSGCLASS). " 'Error in getting filename'.
      ENDIF.
    ENDFORM. " validate_input_file
    *& Form CONVER_XLS_ITAB
    * text
    FORM CONVERT_XLS_ITAB.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          FILENAME    = P_FILE
          I_BEGIN_COL = P_BEGCOL
          I_BEGIN_ROW = P_BEGROW
          I_END_COL   = P_ENDCOL
          I_END_ROW   = P_ENDROW
        TABLES
          INTERN      = IT_INTERN.
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *--- Perform to move the data into an internal data
      PERFORM MOVE_DATA.
    ENDFORM. " CONVERT_XLS_ITAB
    *& Form MOVE_DATA
    * text
    FORM MOVE_DATA.
      DATA : LV_INDEX TYPE I.
      FIELD-SYMBOLS <FS>.
    *--- Sorting the internal table
      SORT IT_INTERN BY ROW COL.
      CLEAR IT_INTERN.
      LOOP AT IT_INTERN.
        MOVE IT_INTERN-COL TO LV_INDEX.
    *--- Assigning the each record to an internal table row
        ASSIGN COMPONENT LV_INDEX OF STRUCTURE IT_DATA TO <FS>.
    *--- Asigning the field value to a field symbol
        MOVE IT_INTERN-VALUE TO <FS>.
        AT END OF ROW.
          APPEND IT_DATA.
          CLEAR IT_DATA.
        ENDAT.
      ENDLOOP.
    ENDFORM. " MOVE_DATA
    *& Form DELETE_HEADER_EMPTY_RECS
    * To delete the Header and empty records
    FORM DELETE_HEADER_EMPTY_RECS.
      DATA: LV_TABIX LIKE SY-TABIX.
      IF NOT P_HEADER IS INITIAL.
        LOOP AT IT_DATA.
          IF P_HEADER > 0 AND NOT IT_DATA IS INITIAL.
            DELETE IT_DATA FROM 1 TO P_HEADER.
    * P_HEADER = 0.
            EXIT.
          ENDIF.
        ENDLOOP.
      ENDIF.
      CLEAR IT_DATA.
    *--- To delete the empty lines from internal table
      LOOP AT IT_DATA.
        LV_TABIX = SY-TABIX.
        IF IT_DATA IS INITIAL.
          V_EMPTY = V_EMPTY + 1.
          DELETE IT_DATA INDEX LV_TABIX..
        ENDIF.
      ENDLOOP.
      CLEAR IT_DATA.
    *--- Total no of recs in file
      DESCRIBE TABLE IT_DATA LINES V_TOTAL.
      IF V_TOTAL = 0.
        MESSAGE I013(ZLKPL_MSGCLASS). " No records in the file
        F_STOP = 'X'.
        STOP.
      ENDIF.
    ENDFORM. " DELETE_HEADER_EMPTY_RECS
    *& Form UPLOAD_MATMAS
    * to upload Material Master data
    FORM UPLOAD_MATMAS .
      LOOP AT IT_DATA.
    * Header
        UNPACK IT_DATA-MATNR TO IT_DATA-MATNR.
        BAPI_HEAD-MATERIAL = IT_DATA-MATNR.
        BAPI_HEAD-IND_SECTOR = IT_DATA-MBRSH.
        BAPI_HEAD-MATL_TYPE = IT_DATA-MTART.
        BAPI_HEAD-BASIC_VIEW = 'X'.
        BAPI_HEAD-PURCHASE_VIEW = 'X'.
        BAPI_HEAD-ACCOUNT_VIEW = 'X'.
    * Material Description
        REFRESH IT_MAKT.
        IT_MAKT-LANGU = IT_DATA-SPRAS.
        IT_MAKT-MATL_DESC = IT_DATA-MAKTX.
        APPEND IT_MAKT.
    * Client Data - Basic
        BAPI_MARA1-MATL_GROUP = IT_DATA-MATKL.
        BAPI_MARA1-BASE_UOM = IT_DATA-MEINS.
        BAPI_MARA1-UNIT_OF_WT = IT_DATA-GEWEI.
        BAPI_MARA1-DIVISION = IT_DATA-SPART.
        BAPI_MARAX-MATL_GROUP = 'X'.
        BAPI_MARAX-BASE_UOM = 'X'.
        BAPI_MARAX-UNIT_OF_WT = 'X'.
        BAPI_MARAX-DIVISION = 'X'.
    * Plant - Purchasing
        BAPI_MARC1-PLANT = IT_DATA-WERKS.
        BAPI_MARC1-PUR_GROUP = IT_DATA-EKGRP.
        BAPI_MARCX-PLANT = IT_DATA-WERKS.
        BAPI_MARCX-PUR_GROUP = 'X'.
    * Accounting
        BAPI_MBEW1-VAL_AREA = IT_DATA-WERKS.
        BAPI_MBEW1-PRICE_CTRL = IT_DATA-VPRSV.
        BAPI_MBEW1-STD_PRICE = IT_DATA-STPRS.
        BAPI_MBEW1-PRICE_UNIT = IT_DATA-PEINH.
        BAPI_MBEWX-VAL_AREA = IT_DATA-WERKS.
        BAPI_MBEWX-PRICE_CTRL = 'X'.
        BAPI_MBEWX-STD_PRICE = 'X'.
        BAPI_MBEWX-PRICE_UNIT = 'X'.
    *--- BAPI to create material
        CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
        EXPORTING
        HEADDATA = BAPI_HEAD
        CLIENTDATA = BAPI_MARA1
        CLIENTDATAX = BAPI_MARAX
        PLANTDATA = BAPI_MARC1
        PLANTDATAX = BAPI_MARCX
    * FORECASTPARAMETERS =
    * FORECASTPARAMETERSX =
    * PLANNINGDATA =
    * PLANNINGDATAX =
    * STORAGELOCATIONDATA =
    * STORAGELOCATIONDATAX =
    * VALUATIONDATA = BAPI_MBEW1
    * VALUATIONDATAX = BAPI_MBEWX
    * WAREHOUSENUMBERDATA =
    * WAREHOUSENUMBERDATAX =
    * SALESDATA = BAPI_MVKE1
    * SALESDATAX = BAPI_MVKEX
    * STORAGETYPEDATA =
    * STORAGETYPEDATAX =
        IMPORTING
        RETURN = BAPI_RETURN
        TABLES
        MATERIALDESCRIPTION = IT_MAKT
    * UNITSOFMEASURE =
    * UNITSOFMEASUREX =
    * INTERNATIONALARTNOS =
    * MATERIALLONGTEXT =
    * TAXCLASSIFICATIONS =
    * RETURNMESSAGES =
    * PRTDATA =
    * PRTDATAX =
    * EXTENSIONIN =
    * EXTENSIONINX =
        IF BAPI_RETURN-TYPE = 'E'.
          WRITE:/ 'Error:' ,BAPI_RETURN-MESSAGE ,'for material:' ,IT_DATA-MATNR.
        ELSEIF BAPI_RETURN-TYPE = 'S'.
          WRITE: 'Successfully created material' ,IT_DATA-MATNR.
        ENDIF.
      ENDLOOP.
    ENDFORM. " UPLOAD_MATMAS
    Regards,
    V.Balaji
    Reward if Usefull...

  • Excise Reg at Depot

    Hi all,
    We have Excise REg no for Plant. But plant does not have Excise reg no.
    Material is shipped to Depot with excise invoice. What is the procedure at depot for GR.
    Do i need to capture the excise invoice?. From Depot, there is no excise invoice generated for customers.
    thanks.

    Hi,
    Refer following link;
    [J95 - Sales at Depot|http://help.sap.com/bp_bblibrary/500/HTML/J95_SaleDepot_EN_IN.htm]

  • How to set reg.cgi for VideoPhoneLabs

    i start with stratus .i try set it to work with my dedicated apache server and sql but have no clue how to do it or where to put this file on my server.
    i realy have probleme with reg.cgi
    for now i did www/cgi-bin/reg.cgi and in the xml i set my websiteurl = "http://88..../cgi-bin/"
    also how to complete reg.cgi for have it to talk with my db ?
    here the reg.cgi file.
    help please ...
    #! /usr/bin/python --
    reg.cgi by Michael Thornburgh.
    This file is in the public domain.
    IMPORTANT: This script is for illustrative purposes only. It does
    not have user authentication or other access control measures that
    a real production service would have.
    This script should be placed in the cgi-bin location according to
    your web server installation. The database is an SQLite3 database.
    Edit the location of the database in variable "dbFile".
    Create it with the following schema:
    .schema
    CREATE TABLE registrations (
        m_username VARCHAR COLLATE NOCASE,
        m_identity VARCHAR,
        m_updatetime DATETIME,
        PRIMARY KEY (m_username)
    CREATE INDEX registrations_updatetime ON registrations (m_updatetime ASC);
    # CHANGE THIS
    dbFile = '.../registrations.db'
    import cgi
    import sqlite3
    import xml.sax.saxutils
    query = cgi.parse()
    db = sqlite3.connect(dbFile)
    user = query.get('username', [None])[0]
    identity = query.get('identity', [None])[0]
    friends = query.get('friends', [])
    print 'Content-type: text/plain\n\n<?xml version="1.0" encoding="utf-8"?>\n<result>'
    if user:
        try:
            c = db.cursor()
            c.execute("insert or replace into registrations values (?, ?, datetime('now'))", (user, identity))
            print '\t<update>true</update>'
        except:
            print '\t<update>false</update>'
    for f in friends:
        print "\t<friend>\n\t\t<user>%s</user>" % (xml.sax.saxutils.escape(f), )
        c = db.cursor()
        c.execute("select m_username, m_identity from registrations where m_username = ? and m_updatetime > datetime('now', '-1 hour')", (f, ))
        for result in c.fetchall():
            eachIdent = result[1]
            if not eachIdent:
                eachIdent = ""
            print "\t\t<identity>%s</identity>" % (xml.sax.saxutils.escape(eachIdent), )
            if f != result[0]:
                print "\t\t<registered>%s</registered>" % (xml.sax.saxutils.escape(result[0]), )
        print "\t</friend>"
    db.commit()
    print "</result>"

    Persistent binding is effectively provided by STMS (MPxIO) - is there anything in particular you're wanting to do that STMS doesn't provide?

  • I bought an itunes gift card in a different country than my account is reg to, can i use it??

    my acc is reg in ireland, i am currently in new zealand and bought a gift card, i cant work out how to use it, help!

    You can't.
    They are country specific.
    You could get a New Zealand address, then get a credit card that is billed to that address, then set up an account in New Zealand, and as long as you are inside the Borders of New Zealand, then you could redeem the card.

Maybe you are looking for