Excel to internal table upload 'ALSM_EXCEL_TO_INTERNAL_TABLE' issue

I am using ALSM_EXCEL_TO_INTERNAL_TABLE function module to upload the excel into an internal table. In case there is a column with no data. This function module is still populating the previous row data into the internal table
Ex. if the Excel has data like the below 3 rows and 3 columns
1                   10                5.0
                     20   
2                                       6.0
The internal table is posting data like this
1                  10               5.0
1                  20               5.0
2                  20               6.0
Please tell me if i am missing something to be added in the below snip of code
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      FILENAME                = p_file
      I_BEGIN_COL             = B1
      I_BEGIN_ROW             = C1
      I_END_COL               = B2
      I_END_ROW               = C2
    TABLES
      INTERN                  = IT_upload
    EXCEPTIONS
      INCONSISTENT_PARAMETERS = 1
      UPLOAD_OLE              = 2
      OTHERS                  = 3.
  IF SY-SUBRC = 0.
  ENDIF.
  LOOP AT IT_upload.
    CASE IT_Upload-COL.
      WHEN 1.
        IT_Excel-BILLCO = IT_Upload-VALUE.
      WHEN 2.
        IT_Excel-PONUM = IT_Upload-VALUE.
      WHEN 3.
        CLEAR v_upload.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = IT_upload-value
          IMPORTING
            OUTPUT = v_upload.
        IT_Excel-STORENUM = v_upload.
      WHEN 4.
        IT_Excel-VINVNUM = IT_Upload-VALUE.
      WHEN 5.
        IT_Excel-LINEITNUM = IT_Upload-VALUE.
      WHEN 6.
        IT_Excel-LINEITAMT = IT_upload-VALUE.
      WHEN 7.
        IT_Excel-TAXAMT = IT_upload-VALUE.
      WHEN 8.
        IT_Excel-TOTAL = IT_upload-VALUE.
    ENDCASE.
    AT END OF ROW.
      APPEND IT_Excel.
    ENDAT.
  ENDLOOP.

Hi,
Please check below link. surely it will help u.
http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=60655105
Thanks
Jitendra

Similar Messages

  • Upload data from Excel to Internal table

    Hi,
    I am facing a peculiar problem in uploading the data in excel sheet to internal table.
    The excel file contains material number and product hierarchy number. The product hierarchy number for some material is downloaded as 5.73101E17 for the value 573100910115782000. Though I expand the sheet the display is the same 5.73101E17. When i upload the sheet using the f'n module "ALSM_EXCEL_TO_INTERNAL_TABLE" the value is taken as it is (5.73101E+17) into the internal table which is wrong. I tried to change the data type to type n. Then the value is uploaded as 5731011700000000.
    Please propose a solution to this without having to change the format of the column from general to "number without decimals"
    Regards,
    Sam

    HI
    see this example code which EXCEL TO INTERNAL TABLE AND THEN TO APPLICATION
    *& Report  ZSD_EXCEL_INT_APP
    REPORT  ZSD_EXCEL_INT_APP.
    parameter: file_nm type localfile.
    types : begin of it_tab1,
            f1(20),
            f2(40),
            f3(20),
           end of it_tab1.
    data : it_tab type table of ALSMEX_TABLINE with header line,
           file type rlgrap-filename.
    data : it_tab2 type it_tab1 occurs 1,
           wa_tab2 type it_tab1,
           w_message(100)  TYPE c.
    at selection-screen on value-request for file_nm.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
      PROGRAM_NAME        = SYST-REPID
      DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME          = ' '
       STATIC              = 'X'
      MASK                = ' '
      CHANGING
       file_name           = file_nm
    EXCEPTIONS
       MASK_TOO_LONG       = 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.
    start-of-selection.
    refresh it_tab2[].clear wa_tab2.
    file = file_nm.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = file
        i_begin_col                   = '1'
        i_begin_row                   =  '1'
        i_end_col                     = '10'
        i_end_row                     = '35'
      tables
        intern                        = it_tab
    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.
    loop at it_tab.
      case it_tab-col.
       when '002'.
        wa_tab2-f1 = it_tab-value.
       when '004'.
        wa_tab2-f2 = it_tab-value.
      when '008'.
        wa_tab2-f3 = it_tab-value.
    endcase.
    at end of row.
      append wa_tab2 to it_tab2.
    clear wa_tab2.
      endat.
    endloop.
    data : p_file TYPE  rlgrap-filename value 'TEST3.txt'.
    OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    *--- Display error messages if any.
      IF sy-subrc NE 0.
        MESSAGE e001(zsd_mes).
        EXIT.
      ELSE.
    *---Data is downloaded to the application server file path
        LOOP AT it_tab2 INTO wa_tab2.
          TRANSFER wa_tab2 TO p_file.
        ENDLOOP.
      ENDIF.
    *--Close the Application server file (Mandatory).
      CLOSE DATASET p_file.
    loop at it_tab2 into wa_tab2.
      write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
    endloop.

  • Upload data from Excel to Internal table in ECC

    Hello SDN,
    Here I am facing a problem for uploading the data from excel sheet to internal table in ECC6.0
    Main problem is we don't have any FM ALSM_EXCEL_TO_INTERNAL_TABLE.
    Please provide me the solution how to upload the data from excel to internal table through class. If possible please provide me the sample code so that it will be very helpful for me.
    Waitingfor your valuable response.
    Thanks & Regards,
    Kumar.

    Hi,
    you can use OLE to acces (not only) excel, but this will only work in dialog processing.
    regards,
    Hans

  • In SRM How to upload data from Excel to Internal Table

    Hello Experts,
    As seen the Function Module 'ALSM_EXCEL_TO_INTERNAL_TABLE' does not exists in SRM.
    Is there any alternative to upload the data direct from excel to Internal table using any other FM. As seach did't get any relevant FM.
    Please advice..
    Thanks..

    did u try this
    TEXT_CONVERT_XLS_TO_SAP
    in this manner
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
          i_line_header              = 'X'
          i_tab_raw_data             = lt_raw
          i_filename                 = p_path
        TABLES
          i_tab_converted_data       = gt_output
        EXCEPTIONS
          conversion_failed          = 1
          OTHERS                     = 2.
    this FM works on DOI
    so
    SAP document about DOI:
    http://help.sap.com/saphelp_nw2004s/helpdata/EN/e9/0be775408e11d1893b0000e8323c4f/frameset.htm
    SAP Demo Program about DOI: SAPRDEMOEXCELINTEGRATION.
    the fm you mentioned works on OLE
    so you could refer,
    SAP document about OLE:
    http://help.sap.com/saphelp_46c/helpdata/EN/59/ae3c98488f11d189490000e829fbbd/frameset.htm
    Also you can refer this post
    Download of SRM Contracts in Excel - Unit of Measurement Missing
    Let me know if this works ..
    Regards
    Manthan.
    Edited by: Manthan_R on Feb 23, 2010 12:18 PM

  • To upload data from excel to internal table

    hi
    in excel sheet it contains 4 tabs.to upload data from excel to internal table i have used this fm
    text_convert_xls_to_sap .but error wil comeing.that error in tables parameter.iternal table does not contain data.ple help me.(v 6.0) ple give me one example with coding

    Hello,
    Take a look on this: [ABAP - Upload data from Excel to Sap using OO|https://wiki.sdn.sap.com/wiki/x/xOw].
    Regards.

  • Uploading Excel to Internal Table

    Hi,
      Can anyone please look into the code and suggest me the changes in uploading Excel to Internal Table. Code is as below in OnInputProcessing.
    DATA: event TYPE REF TO CL_HTMLB_EVENT.
    event =
    CL_HTMLB_MANAGER=>get_event( runtime->server->request ).
    DATA: fileUpload TYPE REF TO CL_HTMLB_FILEUPLOAD,
           fcontent type xstring,
           fstring  type string,
                  len TYPE I.
    fileUpload ?= CL_HTMLB_MANAGER=>GET_DATA(
    request = runtime->server->request
    name = 'fileUpload'
    id = 'myFileUpload1').
    len = fileUpload->file_length.
    IF event->id = 'submitButton' AND
        event->event_type = 'click'.
       fileUpload ?=
    CL_HTMLB_MANAGER=>GET_DATA( request = request
                               id = 'myFileUpload1'
                               name = 'fileUpload' ).
       IF ( fileUpload->file_name NE '' ) AND
       ( fileUpload->file_length GT 0 ).
         IF fileUpload->file_content_type
         = 'application/vnd.ms-excel'.
           DATA: content TYPE ZTABLE,
           conv TYPE REF TO CL_ABAP_CONV_IN_CE,
           viewoff TYPE REF TO CL_ABAP_VIEW_OFFLEN,
           it_off TYPE ABAPOFFLENTAB,
           wa_off TYPE ABAPOFFLEN,
           dd_fields TYPE DDFIELDS,
           wa_fields TYPE DFIES.
    data: codepage type CPCODEPAGE.
    CALL FUNCTION 'SCP_CODEPAGE_BY_EXTERNAL_NAME'
    EXPORTING
    external_name       = 'utf-16le'
      KIND                = 'H'
      IMPORTING
      SAP_CODEPAGE        = codepage.
    conv = CL_ABAP_CONV_IN_CE=>CREATE( encoding = '4103'
    endian = 'L'
    input =   fileUpload->file_content
    ignore_cerr = 'X').
           CALL FUNCTION 'TR_NAMETAB_GET'
             EXPORTING
               IV_TABNAME                 = 'ZTABLE'
               IV_GET_LENGTHS_IN_CHARMODE = 'X'
               IV_GET_TEXTS               = ' '
             IMPORTING
               ET_DFIES                   = dd_fields.
            LOOP AT dd_fields INTO wa_fields.
             MOVE wa_fields-offset TO wa_off-ioff.
             MOVE wa_fields-intlen TO wa_off-ilen.
             APPEND wa_off TO it_off.
            ENDLOOP.
           viewoff = CL_ABAP_VIEW_OFFLEN=>CREATE( tab = it_off ).
            call method conv->read( importing data = fstring ).
           fcontent = conv->get_buffer( ).
           call function 'HR_KR_XSTRING_TO_STRING'
               exporting
                   from_codepage = '4103'
                   in_xstring    = fcontent
              importing
                   out_string    = fstring.
          data: input_string type string.
          data: fields  type string_table.
          data: s_table type string_table.
    split fstring at cl_abap_char_utilities=>cr_lf into table s_table.
    field-symbols: <wa_table> like line of s_table.
    loop at s_table assigning <wa_table>.
      split <wa_table> at cl_abap_char_utilities=>HORIZONTAL_TAB into table
    fields.
    endloop.
      endif.
      endif.
      endif.
    thanks in advance,
    anjani.

    Hi anjani,
    it doesn't help much if you just post some code and request changes, if you don't state the kind of problem you are having ... in order to receice helpful replies, you have to give detailed information, what you want to do, what is not working as expected ... so please post more details.
    Meanwhile I recommend doing a search for your excel problem in the forum and also read the excel weblogs from <a href="https://www.sdn.sap.com/sdn/weblogs.sdn?blog=/pub/u/1918">Thomas Jung</a>.
    Regards,
    Max

  • For uploading Excel to Internal Table??????

    Hello All,
    Can anybody give me the details for uploading Excel to Internal Table.
    Plz give me the FMs with parameters (Eg).
    I need to use this inside a BDC Program.
    Urgent
    Thanks in Advance,
    Regards,
    LIJO.

    Hi,
    refer the below code.
    DATA:xl_sheet LIKE kcde_cells OCCURS 0 WITH HEADER LINE.
    DATA : scol   TYPE i VALUE '1',
           srow   TYPE i VALUE '1',
           ecol   TYPE i VALUE '256',
           erow   TYPE i VALUE '65536'.
    DATA :  index TYPE i.
            FIELD-SYMBOLS : <fs>.
      CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
        EXPORTING
          filename                =  'file path'
          i_begin_col             = scol
          i_begin_row             = srow
          i_end_col               = ecol
          i_end_row               = erow
        TABLES
          intern                  = xl_sheet
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc <> 0.
    Write:/ 'Not a valid Excel file'.
      ENDIF.
      IF xl_sheet[] IS INITIAL.
        WRITE:/ 'Error:Data not Uploadeded'.
        EXIT.
      ELSE.
        SORT xl_sheet BY row col.
        LOOP AT xl_sheet.
          MOVE xl_sheet-col TO index.
          ASSIGN COMPONENT index OF STRUCTURE ittab TO <fs>.
          MOVE xl_sheet-value TO <fs>.
          AT END OF row.
            APPEND ittab.
            CLEAR ittab.
          ENDAT.
        ENDLOOP.
      ENDIF.
    Note:- after reading excel sheet to our internal table, each excel cell will be stored as a reocrd into yout internal table,let us i suppose if you have 3 fields in first reocrd, it will stores 3 fields data as 3 records into your internal table, each field contains row number and column number, then you have to take care to from this information as a record.
    Reward if useful.
    Thanks,
    Sreeram.

  • 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

  • Excel to Internal Table Issue

    Hi Experts,
      Row
      Column
      Value
      1
      0001
      Prem(First Name )
      1
      0002
      Raj(Middle name )
      1
      0003
      Kaushik(Last name
      2
      0001
      Naresh
    I have the above data in excel file  and my internal table like as follows
    Data : begin of  it_itab occurs 0,
    Row type c,
    Column type string,
    Value type string,
    End of it_itab.
    Now I want to upload the excel file to my internal table
    filed wise  i.e in my intenal table row
    shold have row values from excel same as
    for column and value also
    Can anyone suggest me fix this issue?
    Best Regards,
    Ramjee M

    You may use this function to put data in internal table.
    CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
         EXPORTING
           filename                = p_file *xcel file name
           i_begin_col             = p_scol  *start column
           i_begin_row             = p_srow *start row
           i_end_col               = p_ecol *end col
           i_end_row               = p_erow *end row
         TABLES
           intern                  = it_tab
         EXCEPTIONS
           inconsistent_parameters = 1
           upload_ole              = 2
           OTHERS                  = 3.
      Use this function to put data in internal table.

  • Upload data from Excel to internal table without using Screen

    Hi,
    My reqirment is to read the excel input data and then upload it to internal table for further proceeing but without using selection input screen. I mean can I mention the fixed file name and the path in the function module iself for the input file.

    1.First create one internal table as u have created ur EXCEL file.
    e.g: if ur EXCEL file contains 3 fields col1 col2 and col3.
           data: begin of wa,
                     col1(10),
                     col2(10),
                     col3(10),
                   end of wa,
                   itab like standard table of wa.
    data: filename type string 'C:\FOLDER\DATA.XLS'
    If u dont want to use the screen, then pass the file name directly to the GUI_UPLOAD FM.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                      = filename
       FILETYPE                      = '.XLS'
      tables
        data_tab                      = itab
    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.
    This will serve ur puspose.
    loop at itab into wa.
    write: / wa-col1,wa-col2,wa-col3.
    endloop.
    Thanks & Regards
    Santhosh

  • Function module to upload excel to internal table in SAP 7.0 version system

    <<Question has been asked and answered many times - please search before asking for function modules for common tasks>>
    currently i am using SAP Netweaver7.0 version, i need a Funtion Module to upload an Excel sheet data to an internal table.
    please let me know this ASAP.
    thanks,
    Edited by: Matt on Aug 24, 2009 7:25 AM

    hi,
    the FM you have suggested does not exist in the *version 7.0*
    added the FM "ALSM_....",also does not exist
    pls suggest a FM for SAP7.0 version

  • Reg transfer of data from excel to internal table

    hi
    i need to upload datas from Excel sheet to Internal Table.For this i use d FM
    ALSM_EXCEL_TO_INTERNAL_TABLE.but the problem is if a particular field has no value in excel sheet,then its not  uploaded into internal table.then next field value has come to that blank place in d internal table. what i need is if the excel sheet has a blank value for a field then a blank value is added in d inetrnal table also.

    Use below program logic
    Program    : ZLWMI151_UPLOAD(Data load to ZBATCH_CROSS_REF Table)
    Type       : Upload program
    Author     : Seshu Maramreddy
    Date       : 05/16/2005
    Transport  : DV3K919574
    Transaction: None
    Description: This program will get the data from XLS File
                 and it upload to ZBATCH_CROSS_REF 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
    Reward points if it is helpful
    Thanks
    Seshu

  • Download data from excel to internal table in CRM system?

    Hi Experts,
    Can we read multiple work sheets from an Excel work book to internal tables in CRM system?
    Ex.. Work book has 2 work sheets.  One header sheet and one item sheet.  Can we read this into two internal tables and process the data.
    If yes, pls do let me know the FM name.
    Thanks in advance,
    Cheers'
    Surekha.

    ALSM_EXCEL_TO_INTERNAL_TABLE 
    check this function module

  • Excel to internal table formatting errors.

    Hi,
    I have a requirement where I need to take data from an excel doc and put it into an internal table.
    The excel doc has got  only one active sheet and one column . I am using the methods FILE_OPEN_DIALOG and GUI_UPLOAD for the same. However the data that is getting stored in the internal table is some garbage data.
    I am passing the following parameters in GUI_UPLOAD:-
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
       EXPORTING
         FILENAME                = p_file
         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      =
    IMPORTING
       FILELENGTH              =
       HEADER                  =
      CHANGING
        DATA_TAB                = lt_itab
    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
    The excel file that I am using is a tab delimited one.I am working in CRM 6.0 so as such cannot use the function module 'ALSM_EXCEL_TO_INTERNAL_TABLE'.
    Can anyone provide some idea how to go sbout this?
    Thanks,
    Samrat.

    Hi Clemens,
    Thanks for your response. Below is the code that I am using:-
    types: begin of t_itab,
    bpid(10) type c,
    end of t_itab.
    data: lt_file_table type FILETABLE,
          ls_file_table type file_table,
          ls_window_title type string value 'Data Conversion',
          lv_rc type i,
          lt_itab type table of t_itab,
          ls_itab type t_itab.
    PARAMETERS: p_file type string.
    at SELECTION-SCREEN on VALUE-REQUEST FOR p_file.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
      EXPORTING
         WINDOW_TITLE            = ls_window_title
    *    DEFAULT_EXTENSION       =
    *    DEFAULT_FILENAME        =
    *    FILE_FILTER             =
    *    WITH_ENCODING           =
    *    INITIAL_DIRECTORY       =
    *    MULTISELECTION          =
      CHANGING
        FILE_TABLE              = LT_FILE_TABLE
        RC                      = lv_RC
    *    USER_ACTION             =
    *    FILE_ENCODING           =
    *  EXCEPTIONS
    *    FILE_OPEN_DIALOG_FAILED = 1
    *    CNTL_ERROR              = 2
    *    ERROR_NO_GUI            = 3
    *    NOT_SUPPORTED_BY_GUI    = 4
    *    others                  = 5
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    read table lt_file_table into ls_file_table index 1.
    if sy-subrc = 0.
    p_file = ls_file_table-FILENAME.
    endif.
    START-OF-SELECTION.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
      EXPORTING
         FILENAME                = p_file
         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      =
    *  IMPORTING
    *    FILELENGTH              =
    *    HEADER                  =
      CHANGING
        DATA_TAB                = lt_itab
    *  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
    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,
    Samrat.
    Edited by: SAMRAT DUTTA on Oct 4, 2009 10:09 AM

  • ABAP debugging : excel to internal table

    Hi ,
    I would like to know if there is any way to copy excel sheet data into internal table during Debugging? Any pointers to this are highly appreciated.
    Thank you in Advance.
    Sravan.

    Here is one technique if you have Basis 640 or higher - you can use the advanced debugger (New ABAP Debugger). I have done this many times.
    1) Select the tables tab when you are at a place in the code where you wnat to change the internal table
    2) Use a single table versus the split screen within the tables tab to maximize fields on the screen
    3) Select the tools for the service (wrench) on the right side of the screen - pop up window will appear and select 'Change row content'. Note there is a change column but I have not tried that to see if the entire table column changed or if only the visible rows column changed.
    4) Align excel fields in the same order as the internal table fields and copy the data
    5) Place cursor in the first position of the starting field and paste
    This can only be done for the rows that are visible on the screen so you will need to page down to continue to paste. Perhaps since you work for SAP you can suggest a better way to paste in an internal table. Also there is a limitation with the number of records that can be displayed/changed in the advanced debugger.
    Andy

Maybe you are looking for

  • How do I set the FireFox browser to be compatible with my Brother MFC-8840D printer so it will translate color into grayscale when printing from a webpage?

    Hi, I have a question about setting the FireFox browser so it is compatible with my Brother MFC-8840D printer to print in grayscale. Currently, if I print anything in color, like a Google Map, the colored parts of the map show up blank, whereas the c

  • How can I avoid losing my customised desktop icon arrangement?

    I have a lot of folder icons on my desktop arranged in a specific way. Recently when I shut down and then re-boot I find all the desktop icons  have been re-arranged. This is a real pain! How can I prevent this from happeining? I've been using Mac co

  • Cannot open URL from Adobe Reader (10.1.8)

    My PDF contains a URL which is not standard http format, but is file://. Adobe Reader identifies it to be a URL (hand cursor shows up), but nothing happens when clicking on it. In fact, we have 3 systems (colleagues) with varied behavior. One one it

  • Time machine stuck on 564bytes

    Hi there. I recently decided to backup my Mac as usual. I keep my external HD in a safe place and to my knowledge nothing has been spilled on it etc. Everything is still accesible on it. But I realised, while backing up my computer, that it was takin

  • 16 bit now 8 bit

    Using PS Elements 7, I had RAW 4.3. All of my Canon XSi files opened as 16 bit color in the RAW editor. If in fact I went into Elements itself, I could do little to nothing unless it converted to 8 bit. I updated to RAW 5.5 and now those files open a