Changes in BDC program to upload data from text/excel file

Hi friends i have obtained the BDc program after recording :
start-of-selection.
perform open_group.
perform bdc_dynpro      using 'SAPLCOIH' '0100'.
perform bdc_field       using 'BDC_CURSOR'
                              'CAUFVD-GSBER'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'AUFPAR-PM_AUFART'
                              'PM01'.
perform bdc_field       using 'CAUFVD-IWERK'
                              '460a'.
perform bdc_field       using 'CAUFVD-GSBER'
                              '2460'.
perform bdc_field       using 'CAUFVD-EQUNR'
                              '10000009'.
perform bdc_dynpro      using 'SAPLCOIH' '3000'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'CAUFVD-KTEXT'
                              'abc'.
perform bdc_field       using 'CAUFVD-INGPR'
                              'GM'.
perform bdc_field       using 'CAUFVD-VAPLZ'
                              'RTN_VELR'.
perform bdc_field       using 'CAUFVD-VAWRK'
                              '460A'.
perform bdc_field       using 'BDC_CURSOR'
                              'CAUFVD-GLTRP'.
perform bdc_field       using 'CAUFVD-GSTRP'
                              '1.8.2010'.
perform bdc_field       using 'CAUFVD-GLTRP'
                              '1.8.2010'.
perform bdc_field       using 'CAUFVD-TPLNR'
                              'RTNP-HIG'.
perform bdc_field       using 'CAUFVD-EQUNR'
                              '10000009'.
perform bdc_field       using 'AFVGD-INDET'
                              '1'.
perform bdc_field       using 'AFVGD-WERKS'
                              '460A'.
perform bdc_field       using 'AFVGD-STEUS'
                              'PMIN'.
perform bdc_field       using 'AFVGD-ARBEH'
                              'H'.
perform bdc_field       using 'AFVGD-DAUNE'
                              'H'.
perform bdc_dynpro      using 'SAPLCOIH' '3000'.
perform bdc_field       using 'BDC_OKCODE'
                              '=BU'.
perform bdc_field       using 'BDC_CURSOR'
                              'CAUFVD-KTEXT'.
perform bdc_field       using 'CAUFVD-KTEXT'
                              'abc'.
perform bdc_field       using 'CAUFVD-INGPR'
                              'GM'.
perform bdc_field       using 'CAUFVD-VAPLZ'
                              'RTN_VELR'.
perform bdc_field       using 'CAUFVD-VAWRK'
                              '460A'.
perform bdc_field       using 'CAUFVD-GSTRP'
                              '01.08.2010'.
perform bdc_field       using 'CAUFVD-GLTRP'
                              '01.08.2010'.
perform bdc_field       using 'CAUFVD-TPLNR'
                              'RTNP-HIG'.
perform bdc_field       using 'CAUFVD-EQUNR'
                              '10000009'.
perform bdc_field       using 'AFVGD-LTXA1'
                              'abc'.
perform bdc_field       using 'AFVGD-INDET'
                              '1'.
perform bdc_field       using 'AFVGD-ARBPL'
                              'RTN_VELR'.
perform bdc_field       using 'AFVGD-WERKS'
                              '460A'.
perform bdc_field       using 'AFVGD-STEUS'
                              'PMIN'.
perform bdc_field       using 'AFVGD-ARBEH'
                              'H'.
perform bdc_field       using 'AFVGD-DAUNE'
                              'H'.
perform bdc_transaction using 'IW31'.
perform close_group.
after executing it has two options.one is for call transactioin and other is for with session.Now i want to do the uploading from text file.Please guide me how to achieve that and what should be the order of fields in the text file.I am just a beginner.I know how to do that with LSMW bt trying BDc first time for creating PM orders

You can use class "cl_gui_frontend_services". First you must select file with "file_open_dialog" method and the you can upload file with "gui_upload" method into internal table. Here is a sample: (I didn't try the code but I'm sure you can get it working, there are lots of sample codes about that. You can also search FM "GUI_UPLOAD").
REPORT  zreport.
DATA:
gv_subrc TYPE sysubrc,
gv_result TYPE abap_bool,
gt_data_tab type table of zstruc.
PARAMETERS: p_fname LIKE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
    PERFORM file_open_dialog USING space space space space
                        CHANGING p_fname gv_action gv_subrc.
START-OF-SELECTION.
PERFORM gui_upload TABLES gt_data_tab
                 USING p_fname  CHANGING gv_subrc.
*** FORMS ***
FORM file_open_dialog USING pv_window_title
                            pv_default_extension
                            pv_default_filename
                            pv_initial_directory
                   CHANGING pv_filename
                            pv_user_action
                            pv_subrc.
  DATA:
  lt_file_table TYPE filetable,
  lv_rc         TYPE i,
  lv_initial_directory TYPE string.
  IF pv_initial_directory IS INITIAL.
    PERFORM get_desktop_directory CHANGING lv_initial_directory.
  ELSE.
    lv_initial_directory = pv_initial_directory.
  ENDIF.
  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      window_title            = pv_window_title
      default_extension       = pv_default_extension
      default_filename        = pv_default_filename
*     file_filter             =
*     with_encoding           =
      initial_directory       = lv_initial_directory
*     multiselection          =
    CHANGING
      file_table              = lt_file_table
      rc                      = lv_rc
      user_action             = pv_user_action
*     file_encoding           =
    EXCEPTIONS
      file_open_dialog_failed = 1
      cntl_error              = 2
      error_no_gui            = 3
      not_supported_by_gui    = 4
      OTHERS                  = 5
  pv_subrc = sy-subrc.
  IF pv_subrc EQ 0.
    READ TABLE lt_file_table INTO pv_filename INDEX 1.
  ENDIF.
ENDFORM.
FORM gui_upload TABLES pt_data_tab
                 USING pv_filename
              CHANGING pv_subrc    TYPE sysubrc.
  DATA:
  lt_data_tab TYPE TABLE OF string,
  lv_filename TYPE string.
  lv_filename = pv_filename.
  CALL METHOD cl_gui_frontend_services=>gui_upload
    EXPORTING
      filename                = lv_filename
      filetype                = 'ASC'
     has_field_separator     = 'X'
*     header_length           = 0
*     read_by_line            = 'X'
*     dat_mode                = SPACE
*     codepage                = SPACE
*     ignore_cerr             = ABAP_TRUE
*     replacement             = '#'
*     virus_scan_profile      =
*     show_transfer_status    = 'X'
*   IMPORTING
*     filelength              =
*     header                  =
    CHANGING
      data_tab                = lt_data_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
      not_supported_by_gui    = 17
      error_no_gui            = 18
      OTHERS                  = 19
  pv_subrc = sy-subrc.
  IF pv_subrc EQ 0.
    pt_data_tab[] = lt_data_tab[].
  ENDIF.
ENDFORM.

Similar Messages

  • Uploading data from an excel file to ztable

    Hi,
    I tried to upload an excel file to ztable using fm 'ALSM_EXCEL_TO_INTERNAL_TABLE'.In the o/p I can see only 3 rows and all the date and time fields are not properly displayed in the o/p.What would be the reason?Can anyone give me a suggestion?
    Regards,
    Hema

    Hi,
    pls check my code.
                       Data Definitions                                  *
      Internal Tables
    DATA : t_zrb_hdr TYPE STANDARD TABLE OF ZRB_HDR WITH HEADER LINE,
           t_field_catalog  TYPE slis_t_fieldcat_alv.
    Declaration of the Internal Table with Header Line comprising of the uploaded data.
    DATA: BEGIN OF t_file_upload OCCURS 0.
    INCLUDE STRUCTURE ALSMEX_TABLINE. " Rows for Table with Excel Data
    DATA: END OF t_file_upload.
    form UPLOAD_EXCEL_FILE .
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = p_file
        i_begin_col                   = '1'
        i_begin_row                   = '2'
        i_end_col                     = '10'
        i_end_row                     = '250'
      tables
        intern                        = t_file_upload
    EXCEPTIONS
      INCONSISTENT_PARAMETERS       = 1
      UPLOAD_OLE                    = 2
      OTHERS                        = 3
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  • FM to upload data / Attribute in EXCEL File in SRM7.0

    Hi Experts,
    We  had used FM BBP_UPDATE_ATTRIBUTE to upload Storage Location( LAG) attribute in SRM ORG Structure and other data in other case ...... Currently we arranged to upload the .TXT file.
    But we want to upload from MS EXCEL File.
    Can anyone please suggest, which FM we can need to use  to upload data from MS EXCEL File.
    Thnaks
    NAP

    Hi Narenrda,
    Normally in ECC we can use the FM "ALSM_EXCEL_TO_INTERNAL_TABLE" to convert excel to internal table but this FM is not there in SRM 7.0 .
    I copied the above mentioned FM along with global data and includes of the function group from ECC and it works fine in SRM.
    You can use the FM "BBPU_FILENAME_HELP" to show an F4 help for the input field for selecting a file from desktop.
    Thanks,
    Anubhav

  • BAPI to upload data from a flat file to VA01

    Hi guys,
    I have a requirement wherein i need to upload data  from a flat file to VA01.Please tell me how do i go about this.
    Thanks and regards,
    Frank.

    Hi
    previously i posted code also
        Include           YCL_CREATE_SALES_DOCU                         *
         Form  salesdocu
         This Subroutine is used to create Sales Order
         -->P_HEADER           Document Header Data
         -->P_HEADERX          Checkbox for Header Data
         -->P_ITEM             Item Data
         -->P_ITEMX            Item Data Checkboxes
         -->P_LT_SCHEDULES_IN  Schedule Line Data
         -->P_LT_SCHEDULES_INX Checkbox Schedule Line Data
         -->P_PARTNER  text    Document Partner
         <--P_w_vbeln  text    Sales Document Number
    DATA:
      lfs_return like line of t_return.
    FORM create_sales_document changing P_HEADER  like fs_header
                                       P_HEADERX like fs_headerx
                                       Pt_ITEM   like t_item[]
                                       Pt_ITEMX  like t_itemx[]
                                       P_LT_SCHEDULES_IN  like t_schedules_in[]
                                       P_LT_SCHEDULES_INX like t_schedules_inx[]
                                       Pt_PARTNER  like t_partner[]
                                       P_w_vbeln  like w_vbeln.
    This Perform is used to fill required data for Sales order creation
      perform sales_fill_data changing p_header
                                       p_headerx
                                       pt_item
                                       pt_itemx
                                       p_lt_schedules_in
                                       p_lt_schedules_inx
                                       pt_partner.
    Function Module to Create Sales and Distribution Document
      perform sales_order_creation using p_header
                                         p_headerx
                                         pt_item
                                         pt_itemx
                                         p_lt_schedules_in
                                         p_lt_schedules_inx
                                         pt_partner.
      perform return_check using p_w_vbeln .
    ENDFORM.                                 " salesdocu
        Form  commit_work
        To execute external commit                                    *
    FORM commit_work .
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
       WAIT          = c_x
    ENDFORM.                                 " Commit_work
    Include ycl_sales_order_header          " To Fill Header data and Item data
    Include ycl_sales_order_header.
         Form  return_check
        To validate the sales order creation
    FORM return_check using pr_vbeln type vbeln.
    if pr_vbeln is initial.
        LOOP AT t_return into lfs_return .
          WRITE / lfs_return-message.
          clear lfs_return.
        ENDLOOP.                             " Loop at return
      else.
        perform commit_work.                 " External Commit
        Refresh t_return.
        fs_disp-text = text-003.
        fs_disp-number = pr_vbeln.
        append fs_disp to it_disp.
      if p_del eq c_x or p_torder eq c_x or
        p_pgi eq c_x or p_bill eq c_x.
        perform delivery_creation.           " Delivery order creation
        endif.                               " If p_del eq 'X'......
      endif.                                 " If p_w_vbeln is initial
    ENDFORM.                                 " Return_check
    *&      Form  sales_order_creation
          text
         -->P_P_HEADER  text
         -->P_P_HEADERX  text
         -->P_PT_ITEM  text
         -->P_PT_ITEMX  text
         -->P_P_LT_SCHEDULES_IN  text
         -->P_P_LT_SCHEDULES_INX  text
         -->P_PT_PARTNER  text
    FORM sales_order_creation  USING    P_P_HEADER like fs_header
                                        P_P_HEADERX like fs_headerx
                                        P_PT_ITEM like t_item[]
                                        P_PT_ITEMX like t_itemx[]
                                        P_P_LT_SCHEDULES_IN like t_schedules_in[]
                                        P_P_LT_SCHEDULES_INX like t_schedules_inx[]
                                        P_PT_PARTNER like t_partner[].
        CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
        EXPORTING
          sales_header_in     = p_p_header
          sales_header_inx    = p_p_headerx
        IMPORTING
          salesdocument_ex    = w_vbeln
        TABLES
          return              = t_return
          sales_items_in      = p_pt_item
          sales_items_inx     = p_pt_itemx
          sales_schedules_in  = p_p_lt_schedules_in
          sales_schedules_inx = p_p_lt_schedules_inx
          sales_partners      = p_pt_partner.
    ENDFORM.                    " sales_order_creation
    plzz reward if i am usefull plzz

  • Uploading data from an excel to internal table.

    Hi All,
                I have a small problem when uploading data from an excel sheet to internal table using the function "GUI_UPLOAD".
    Some garbage value is getting stored in the internal table after the upload. If i change the format of the file to ".txt" then its working fine. Pls help me out to upload the data frm Excel to Internal Table.
    Thanks.
    Sirisha.

    hi
    good
    pls check this code , this might help you to solve your problem
    Multiple excel sheets generation in a workbook
    CREATE OBJECT EXCEL 'EXCEL.SHEET'.
    GET PROPERTY OF EXCEL 'Application' = APPLICATION.
    SET PROPERTY OF APPLICATION 'Visible' = 1.
    CALL METHOD OF APPLICATION 'Workbooks' = BOOKS.
    CALL METHOD OF BOOKS 'Add' = BOOK.
    CALL METHOD OF BOOK 'WORKSHEETS' = SHEET.
    CALL METHOD OF SHEET 'ADD'.
    Fill all the sheets with relavant data
    PERFORM SHEET1 TABLES ITAB1.
    PERFORM SHEET2 TABLES ITAB2.
    PERFORM SHEET3 TABLES ITAB3.
    PERFORM SHEET4 TABLES ITAB4.
    Quit the excel after use
    CALL METHOD OF EXCEL 'QUIT'.
    FREE OBJECT: COLUMN,SHEET,BOOK,BOOKS,APPLICATION,EXCEL. "NO FLUSH.
    CLEAR V_SHEET.
    FORM FILL_CELL USING ROW COL VAL.
    CALL METHOD OF SHEET 'cells' = CELL NO FLUSH
    EXPORTING #1 = ROW #2 = COL.
    SET PROPERTY OF CELL 'value' = VAL.
    FREE OBJECT CELL NO FLUSH.
    ENDFORM. " FILL_CELL
    FORM SHEET1 TABLES ITAB1 STRUCTURE ITAB1.
    V_SHEET = Sheet Name.
    V_NO = V_NO + 1.
    CALL METHOD OF BOOK 'worksheets' = SHEET NO FLUSH EXPORTING #1 = V_NO.
    SET PROPERTY OF SHEET 'Name' = V_SHEET NO FLUSH.
    PERFORM FILL_SHEET1 TABLES ITAB1 USING V_NO V_SHEET.
    CALL METHOD OF SHEET 'Columns' = COLUMN.
    FREE OBJECT SHEET.
    CALL METHOD OF COLUMN 'Autofit'.
    FREE OBJECT COLUMN.
    ENDFORM.
    Repeat above procedure for all sheets you want to add
    FORM FILL_SHEET1
    TABLES ITAB1 STRUCTURE ITAB1
    USING V_NO V_SHEET.
    ROW = 1.
    PERFORM FILL_CELL USING ROW 1 'Column1 Name'.
    PERFORM FILL_CELL USING ROW 2 'Column2 Name'.
    PERFORM FILL_CELL USING ROW 3 'Column3 Name'.
    ROW = ROW + 1.
    LOOP AT ITAB1.
    PERFORM FILL_CELL USING ROW 1 ITAB1-Column1.
    PERFORM FILL_CELL USING ROW 2 ITAB1-Column2.
    PERFORM FILL_CELL USING ROW 3 ITAB1-Column3.
    ROW = ROW + 1.
    ENDLOOP.
    ENDFORM.
    Repeat above procedure for all sheets you want to add
    Try this also
    TYPE-POOLS: truxs.
    DATA: it_raw TYPE truxs_t_text_data.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    field_name = 'P_FILE'
    IMPORTING
    file_name = p_file.
    Upload Excel file
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
    I_FIELD_SEPERATOR =
    i_line_header = 'X'
    i_tab_raw_data = it_raw
    i_filename = p_file
    TABLES
    i_tab_converted_data = i_XCEL[]
    EXCEPTIONS
    conversion_failed = 1
    OTHERS = 2.
    IF sy-subrc 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Thanks&regds,
    Sree.
    Edited by: Sree on Mar 17, 2008 8:07 AM

  • Error while uploading data from a flat file to the hierarchy

    Hi guys,
    after i upload data from a flat file to the hierarchy, i get a error message "Please select a valid info object" am loading data using PSA, having activated all external chars still get the problem..some help on this please..
    regards
    Sri

    there is o relation of infoobject name in flat file and infoobjet name at BW side.
    please check with the object in the BW and their lengths and type of the object and check your flat file weather u have the same type there,
    now check the sequence of the objects in the transfer rules  and activate them.
    there u go.

  • Uploading Data from a Flat File

    Hi
    I am trying to Upload data from a Flat File to the MDS. I have a few questions on the Process.
    a) XI would be the Interface, and one end would be a file adapter with the Flat File format. On the other end, which Interface should I use - ABA Business Partner In or MDM Business Partner In. I do not understand the differences between them and where should which one be used?
    B) At the moment,I want to map the data to standard Object type, Business Partner  BUS1006. This also has a staging area already defined in the System. Can I view the data which is imported into the Staging area ? How so ?
    C) The struture (or data) that I wish to upload has few fields, and does not map to the BP structure easily. In such a scenario does it make sense to
    Create a new Object type
    (ii) Create a new Business Partner type with the appropriate fields only ..
    What I need to know is if either of these options is feasible and what are the pros & cons of doing this, in terms of effort, skillset & interaction with SAP Development ?
    Kindly do reply if you have any answers to these questions.
    Regards,
    Gaurav

    Hi Markus,
    Thanks for your inputs.
    I have tried uploading some dats from a Flat file to the Business Partner Onject type, BUS1006. I initially got some ABAP Parsing errors on the MDM side, but after correcting that, I find my message triggers a short dump - with the Method SET_OBJECTKEYS, not finding any keys in the BP structure that has been created.
    Q1 - How do I get around this problem ? Is it necessary for me to specify Keys in the PartyID node of the Interface ABABusinessPartnerIn. or is it something else ?
    Q2 - How is this general process supposed to work? I would assume that for staging, I would get incomplete Master data or data from flat files, which need not neccesarily contain keys. The aim is to use the matching strategies in the CI to identify duplicates and consolidate them.
    Thanks in advance for your reply.
    Regards,
    Gaurav

  • GUI_UPLOAD to read data from an Excel File

    Hi Folks,
    I'm using FM GUI_UPLOAD to read data from an Excel File. But all I see in the table returned is 1 row with garbage values (special chacaters). Excel Workbook has proper data in the sheet, but its not getting uploaded properly. Sy-subrc is 0.
    What could be the reason?
    Thanks

    use FM : ALSM_EXCEL_TO_INTERNAL_TABLE
    See the example program to get from XLS file to Internal table
    REPORT ZLWMI151_UPLOAD no standard page heading
                           line-size 100 line-count 60.
    *tables : zbatch_cross_ref.
    data : begin of t_text occurs 0,
           werks(4) type c,
           cmatnr(15) type c,
           srlno(12) type n,
           matnr(7) type n,
           charg(10) type n,
           end of t_text.
    data: begin of t_zbatch occurs 0,
          werks like zbatch_cross_ref-werks,
          cmatnr like zbatch_cross_ref-cmatnr,
          srlno like zbatch_cross_ref-srlno,
          matnr like zbatch_cross_ref-matnr,
          charg like zbatch_cross_ref-charg,
          end of t_zbatch.
    data : g_repid like sy-repid,
           g_line like sy-index,
           g_line1 like sy-index,
           $v_start_col         type i value '1',
           $v_start_row         type i value '2',
           $v_end_col           type i value '256',
           $v_end_row           type i value '65536',
           gd_currentrow type i.
    data: itab like alsmex_tabline occurs 0 with header line.
    data : t_final like zbatch_cross_ref occurs 0 with header line.
    selection-screen : begin of block blk with frame title text.
    parameters : p_file like rlgrap-filename obligatory.
    selection-screen : end of block blk.
    initialization.
      g_repid = sy-repid.
    at selection-screen on value-request for p_file.
      CALL FUNCTION 'F4_FILENAME'
           EXPORTING
                PROGRAM_NAME = g_repid
           IMPORTING
                FILE_NAME    = p_file.
    start-of-selection.
    Uploading the data into Internal Table
      perform upload_data.
      perform modify_table.
    top-of-page.
      CALL FUNCTION 'Z_HEADER'
      EXPORTING
        FLEX_TEXT1       =
        FLEX_TEXT2       =
        FLEX_TEXT3       =
    *&      Form  upload_data
          text
    FORM upload_data.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           EXPORTING
                FILENAME                = p_file
                I_BEGIN_COL             = $v_start_col
                I_BEGIN_ROW             = $v_start_row
                I_END_COL               = $v_end_col
                I_END_ROW               = $v_end_row
           TABLES
                INTERN                  = itab
           EXCEPTIONS
                INCONSISTENT_PARAMETERS = 1
                UPLOAD_OLE              = 2
                OTHERS                  = 3.
      IF SY-SUBRC <> 0.
        write:/10 'File '.
      ENDIF.
      if sy-subrc eq 0.
        read table itab index 1.
        gd_currentrow = itab-row.
        loop at itab.
          if itab-row ne gd_currentrow.
            append t_text.
            clear t_text.
            gd_currentrow = itab-row.
          endif.
          case itab-col.
            when '0001'.
              t_text-werks = itab-value.
            when '0002'.
              t_text-cmatnr = itab-value.
            when '0003'.
              t_text-srlno = itab-value.
            when '0004'.
              t_text-matnr = itab-value.
            when '0005'.
              t_text-charg = itab-value.
          endcase.
        endloop.
      endif.
      append t_text.
    ENDFORM.                    " upload_data
    *&      Form  modify_table
          Modify the table ZBATCH_CROSS_REF
    FORM modify_table.
      loop at t_text.
        t_final-werks = t_text-werks.
        t_final-cmatnr = t_text-cmatnr.
        t_final-srlno = t_text-srlno.
        t_final-matnr = t_text-matnr.
        t_final-charg = t_text-charg.
        t_final-erdat = sy-datum.
        t_final-erzet = sy-uzeit.
        t_final-ernam = sy-uname.
        t_final-rstat = 'U'.
        append t_final.
        clear t_final.
      endloop.
      delete t_final where werks = ''.
      describe table t_final lines g_line.
      sort t_final by werks cmatnr srlno.
    Deleting the Duplicate Records
      perform select_data.
      describe table t_final lines g_line1.
      modify zbatch_cross_ref from table t_final.
      if sy-subrc ne 0.
        write:/ 'Updation failed'.
      else.
        Skip 1.
        Write:/12 'Updation has been Completed Sucessfully'.
        skip 1.
        Write:/12 'Records in file ',42 g_line .
        write:/12 'Updated records in Table',42 g_line1.
      endif.
      delete from zbatch_cross_ref where werks = ''.
    ENDFORM.                    " modify_table
    *&      Form  select_data
          Deleting the duplicate records
    FORM select_data.
      select werks
             cmatnr
             srlno from zbatch_cross_ref
             into table t_zbatch for all entries in t_final
             where werks = t_final-werks
             and  cmatnr = t_final-cmatnr
             and srlno = t_final-srlno.
      sort t_zbatch by werks cmatnr srlno.
      loop at t_zbatch.
        read table t_final with key werks = t_zbatch-werks
                                    cmatnr = t_zbatch-cmatnr
                                    srlno = t_zbatch-srlno.
        if sy-subrc eq 0.
          delete table t_final .
        endif.
        clear: t_zbatch,
               t_final.
      endloop.
    ENDFORM.                    " select_data

  • How to retrieve data from an Excel file which is located on server

    hi everybody,
                    I am using SAP NWDS 2004s .     
                I have done an application on how to export the table data into an Excel .
    Now i want to get the data from an Excel file which is located in server and display that data which is in excel in a View for example a Sample view in Webdynpro  .
    In Sample view i took a uielement textview to display the data ....   
    can any one help how to procced further
    Thanks in advance
    Madhavi

    Options to read Excel data to WebDynpro context
    Reading Excel Sheet from Java without using any Framework
    Reading Multiple Sheets of Excel Sheet from Java
    Few Threads
    How to Display the content of Excel file into Webdynpro Table
    Is it possible to upload data from excel file(.xls)
    Re: How to export the data as integer into excel sheet?
    regards
       Vinod

  • How to read data from the excel file using java code.

    Hi to all,
    I am using below code to getting the data from the excel file but I can't get the corresponding data from the specific file. can anyone give me the correct code to do that... I will waiting for your usefull reply......
    advance thanks....
    import java.io.*;
    import java.sql.*;
        public class sample{
                 public static void main(String[] args){
                      Connection connection = null;
                          try{
                               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                               Connection con = DriverManager.getConnection( "jdbc:odbc:Mydsn","","" );
                               Statement st = con.createStatement();
                               ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );
                               System.out.println("sample:"+rs);
                                  ResultSetMetaData rsmd = rs.getMetaData();
                                  System.out.println("samplersd:"+rsmd);
                               int numberOfColumns = rsmd.getColumnCount();
                                  System.out.println("numberOfColumns:"+numberOfColumns);
                                   while (rs.next()) {
                                            System.out.println("sample1:"+rs);
                                            for (int i = 1; i <= numberOfColumns; i++) {
                                                 if (i > 1) System.out.print(", ");
                                                 String columnValue = rs.getString(i);
                                                 System.out.print(columnValue);
                                            System.out.println("");
                                       st.close();
                                       con.close();
                                      } catch(Exception ex) {
                                           System.err.print("Exception: ");
                                           System.err.println(ex.getMessage());
                        }

    1: What is the name of the excel sheet?
    2: What is printed in this program? null ? anything?
    error?Excel file name is "sample.xls" I set excel file connectivity in my JDBC driver(DSN). Here in my program I am not giving that excel file name. I am giving only that excel sheet name. that is followed
    ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );The output of this program is given bellow.
    sample:sun.jdbc.odbc.JdbcOdbcResultSet@1b67f74
    samplersd:sun.jdbc.odbc.JdbcOdbcResultSetMetaData@530daa
    numberOfColumns:2

  • Reading data from an excel file

    Hi,
    I want to read data from the excel file and display it in
    jsp page. Iam getting the following error:
    [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con =
    DriverManager.getConnection("jdbc:odbc:mydsn","","");
    Statement st = con.createStatement();
    ResultSet rs = st.executeQuery("select * from [holidays$]");
    Here i have created the dsn with the name "mydsn". I have the
    following data in the mydsn.dsn file:
    [ODBC]
    DRIVER=Microsoft Excel Driver (*.xls)
    UID=admin
    UserCommitSync=Yes
    Threads=3
    SafeTransactions=0
    ReadOnly=1
    PageTimeout=5
    MaxScanRows=8
    MaxBufferSize=2048
    FIL=excel 8.0
    DriverId=790
    DefaultDir=D:\WorkSpace\Projects\VINET\devl\webroot\jsp
    DBQ=D:\WorkSpace\Projects\VINET\devl\webroot\jsp\list_of_holidays_2003.xls
    thanks in advance
    phani.

    You might want to look at the POI project (an open source Jakarta sub-project) that allows you to create/modify/read excel files via Java code. That might be more flexible and easier than what you're currently trying to do.
    Cheers

  • How to export the data from an excel file to Oracle database by using macro

    Hi,
    I want to export data from an excel file into Oracle database.There is one method that by creating the macros through excel we are able to do this.
    can anybody please send me the code to create macros?
    Thanks in advance.
    Regards,
    Surendra.V

    There are several resources on the web, but you could start analyzing if this code fits your needs --> VBA Macro for Excel 2003 Export of Text File with Comma and Quote Delimiters.
    ~ Madrid

  • Help! How to read data from an Excel file?

    Hi,
    I need to read data from an Excel file that may contain more then one table in a sheet. How can I read them?
    I would be eternally grateful to anyone who can give me any information.

    Did you try POI from Apache?
    http://jakarta.apache.org/poi/index.html

  • Loading data from an excel file to Oracle Tables

    Hi Everyone,
    Once again I will have to bring some data from some excel file, which I have already done and "know" how to do and I would like to confirm with you all something first.
    What I shall do is the following:
    From one excel workbook file which has a lot of info just in one spread sheet feed some tables with the data coming from it.
    So what I have though is create mane name ranges (Define names on excel) as I need and work with them, but I will be facing with headers on the rows and columns. There is where I doubt if it will be possible. So far, I will not be able to modify the Excel’s file structure.
    Something more or less like this:
    Country1 Country 2
    Sales1 9999999 9999999
    Sales2 9999999 9999999
    Sales3 9999999 9999999
    Total123 9999999 9999999
    Sales4 9999999 9999999
    Sales5 9999999 9999999
    Sales6 9999999 9999999
    Total456 9999999 9999999
    Best regards.
    Jaison

    Hi SH,
    First of all, I do really appreciate your time, patience and guidance.
    Ok, let me get this straight.
    You will need to create a data server for each Excel Work book
    That means that as I will just work with one excel sheet, I will just have one data server and within it, there will be the spread sheets (excel tabs) and therefore the different named ranges.
    Each of your named ranges will be a data store beneath the data server which can be used as a source model in your ODI interfaces. Therefore if you have a single workbook with 12 sheets for the months, each covered by a single named range, you would have a single data server withe 12 data stores.
    This means that I will have something like this:
    + “My_Workbook.xls” server name (Just one)
    -     Spread sheet 1 (1 or several named ranges)
    -     Spread sheet 2 (1 or several named ranges)
    -     Spread sheet 3 (1 or several named ranges)
    -     Spread sheet n (1 or several named ranges)
    I do think that if my statement above is correct, I think I got the idea. Is it like that?
    I have gotten another question; let’s say for example that in any spread sheet I will have three different named ranges. The difference between spread sheet and spread sheet will be the month within and of course the information. Would it be accurate to bring it like that? That means that so far for twelve month I will bring 36 named ranges.
    Well I think I had explained myself. Please do not hesitate to contact me if any further detail is required.
    Best regards.
    J

  • Program to upload data from a tab-delimited file ...

    I have to upload data from a tab-delimited file with following fields into database table(ZCBU) with same fields:
    CBU (parent)
    KUNNR (child)
    ERDAT (effective from)
    MANDT (client)
    SFID (salesforce ID)
    AEDAT (effective to)
    AENAM (assigned by).
    This file can be of type PC(txt) or UNIX.
    plz tell me how to do this in both type of files

    Hi,
    DATA: bdcdata LIKE bdcdata    OCCURS 0 WITH HEADER LINE.
    DATA: xfile TYPE string.
    DATA: BEGIN OF itab OCCURS 0,
            empno TYPE zmemp-empno,
            name  TYPE zmemp-first_name,
            last  TYPE zmemp-last_name,
            comp  TYPE zmemp-comp,
            place TYPE zmemp-place,
            END OF itab.
    PARAMETER : p_file TYPE rlgrap-filename OBLIGATORY.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    Form to get the file path of legacy data stored on presentation server
      PERFORM get_file_path.
    START-OF-SELECTION.
      MOVE p_file TO xfile.
    to get the data from excel sheet data into an internal table
      PERFORM get_data.
      LOOP AT itab .
        REFRESH bdcdata.
        PERFORM bdc_dynpro      USING 'ZM_EMPLOYEE' '9001'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'S9001_EMPNO'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=CREA'.
        PERFORM bdc_field       USING 'S9001_EMPNO'
                                      itab-empno.
        PERFORM bdc_dynpro      USING 'ZM_EMPLOYEE' '9002'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'S9002_PLACE'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=SAVE'.
        PERFORM bdc_field       USING 'S9002_EMPNO'
                                      itab-empno.
        PERFORM bdc_field       USING 'S9002_FIRST_NAME'
                                      itab-name.
        PERFORM bdc_field       USING 'S9002_LAST_NAME'
                                      itab-last.
        PERFORM bdc_field       USING 'S9002_COMP'
                                      itab-comp.
        PERFORM bdc_field       USING 'S9002_PLACE'
                                      itab-place.
        PERFORM bdc_dynpro      USING 'ZM_EMPLOYEE' '9001'.
        PERFORM bdc_field       USING 'BDC_CURSOR'
                                      'S9001_EMPNO'.
        PERFORM bdc_field       USING 'BDC_OKCODE'
                                      '=BACK'.
        CALL TRANSACTION 'ZMEMP'
        USING bdcdata
        UPDATE 'A'
        MODE   'N'.
      ENDLOOP.
           Start new screen                                              *
    FORM bdc_dynpro USING program dynpro.
      CLEAR bdcdata.
      bdcdata-program  = program.
      bdcdata-dynpro   = dynpro.
      bdcdata-dynbegin = 'X'.
      APPEND bdcdata.
    ENDFORM.                    "BDC_DYNPRO
           Insert field                                                  *
    FORM bdc_field USING fnam fval.
      CLEAR bdcdata.
      bdcdata-fnam = fnam.
      bdcdata-fval = fval.
      APPEND bdcdata.
    ENDFORM.                    "BDC_FIELD
    *&      Form  get_file_path
    FORM get_file_path .
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        CHANGING
          file_name = p_file.
    ENDFORM.                    " get_file_path
    *&      Form  get_data
    FORM get_data .
      DATA : lines1 TYPE i.
      MOVE p_file TO xfile.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename            = xfile
          filetype            = 'ASC'
          has_field_separator = 'X'
        TABLES
          data_tab            = itab.
      DESCRIBE TABLE itab LINES lines1.
      WRITE : / lines1 , 'REcords uploaded' .
    ENDFORM.                    " get_data
    Regards,
    Nihar Swain,

Maybe you are looking for

  • Images open in wrong version of Photoshop

    I have both Photoshop CC and Photoshop CC 2014 installed because some actions I have purchased only work in Photoshop CC due to them using the Oil Painting filter. But if I double click an image to open it, it opens in Photoshop CC. So I right click

  • HT1338 internet browser is so slow when I first open it??

    my internet browser either safari or firefox are so slow to start up??? if i open new tabs its straight away....and straight away for new windows.... what is this about?

  • Font style issue's in mail

    Hi, Our requirement is to send mails, the content of which will be stored in SO10. However in SO10 the tex can be stored in various formats (bold, underlines etc.) How do we capture this information and send via mails? Will  the function module \ SO_

  • Toolbar Bookmarks = Broken in FF 4.0

    In FF4.0, my Toolbar bookmarks do not do anything when I click on them. And I can not open a new tab by clicking on the "+" for new tabs.

  • Spry 2, IE7/IE8 bad, IE9 ok.

    I have a horizontal spry menu version 2 (Spry pre-release 1.7) that appears to have a small problem with IE 7, and IE 8, but not IE9 or other browsers like Firefox, Safari, and Chrome. The problem is when I open the submenu, and scroll the mouse up a