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

Similar Messages

  • 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.

  • 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

  • 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.

  • 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

  • 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

  • FM for uploading data into internal table from Excel sheet

    Hi,
    I have a slight problem in one of the function modules that I have created. Actually it has been copied from a standard SAP function module “KCD_EXCEL_OLE_TO_INT_CONVERT”. Now my created function module is throwing me a dump suggesting “Data objects in a Unicode program are not convertible”. Can anybody help me out in removing the error .
    Actually the need of copying the standard FM to a ZFM is to increase the length of the column which can be uploaded thru this FM. The standard FM has a restriction of being able to upload 32 characters whereas my requirement is to upload data having at least 150 characters. So in order to care the need I made a ZStructure ZAKHIL_CELLS taking the Value parameters as 150 characters instead of 32 characters.
    Well this is all done because I wanted to upload a excel sheet into an internal table and not use a tab delimited file. Can anybody help in this regard or suggest some other function module which can upload more than 150 characters from a excel sheet .
    ‘m also attaching structure of my ZStructure for ur reference .
    STRUCTURE ZAKHIL_CELLS1 .
    ROW KCD_EX_ROW_N NUMC 4 Flexible Excel upload: row number
    COL KCD_EX_COL_N NUMC 4 Column
    VALUE KCD_VALUE CHAR 150 External Data Transfer: Values of Parameters or Variables
    Thanks & Rgds,
    Akhil

    hi,
    sample excel sheet.
    coloumn 1 is name and column 2 is age
    name age
    A     8
    C     13
    D     55
    DATA : int_excel LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
    data : record like db_name_age occurs 0 with header line.
    DATA : v_start_col TYPE i VALUE '1', "starting col
           v_start_row TYPE i VALUE '1', " starting row
           v_end_col   TYPE i VALUE '2', " total columns
           v_end_row   TYPE i VALUE '10'. "total no of record
    FORM f_upload .
      CLEAR : int_excel, int_excel[].
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = wf_filename
          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                  = int_excel
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc <> 0.
    *Message is 'Unable to upload data from  '  wf_filename.
        MESSAGE e169(zm050) WITH wf_filename.
      ELSE.
        SORT int_excel BY row col.
        REFRESH : record.
        CLEAR   : record.
        LOOP AT int_excel.
          CASE int_excel-col. "go thru each column.
            WHEN 1.
              record-name  = int_excel-value.
            WHEN 2.
              record-age = int_excel-value.     
          ENDCASE.
          AT END OF row.
            APPEND record.
            CLEAR record.
          ENDAT.
        ENDLOOP.
    *inserting into table
      ENDIF.
    if this helped pld rewrd points,
    rgrds
    anver

  • 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

  • How to filter out alt+enter in excel when upload to abap internal table

    hi guys,
    we're facing a problem when upload excel file with alt+key in between a line.
    system would create some special character (# if see from internal table, a square if see from text file) in between the line.
    replace all occurrences of '#' in char with space is not working here. And it is possible for user to key in '#' in the lines.
    do we have any other option to fix this?
    thanks.

    Hi,
    How are you uploading data from Excel to your program.
    Try using FM 'ALSM_EXCEL_TO_INTERNAL_TABLE' as shown below :
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_file
          i_begin_col             = '1'
          i_begin_row             = w_row
          i_end_col               = '200'
          i_end_row               = '60000'
        TABLES
          intern                  = ex_itab
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
    This will allow you to upload the file without any special character. w_row is the row from which actual data in your excel begins.
    Hope I understood your problem correctly and have given the right soln.
    Regards,
    Lalit Kabra

  • 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

  • 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.

  • Uploading data into internal table

    hi all ,
    i;m uploading the file using Function module  ALSM_EXCEL_TO_INTERNAL_TABLE  . problem now is  when i given lower cae in excel it is not taking . when i use upper case then it is taking from excel and putting into internal table  . now i need to take records from excel even it is lower case . can u pls suggest how to proceed and help . Thanks

    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = pa_f
          i_begin_col             = co_x  " column num shd start take as 1
          i_begin_row             = co_y "row number shd start take based on the heading in excel sheet
          i_end_col               = co_n13 "end column is 13 here
          i_end_row               = co_50000 "endrow is 50000 here
        TABLES
          intern                  = ta_file
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc EQ 0.
        LOOP AT ta_file INTO wa_file.
          AT NEW row.
          Clear the  work area
            CLEAR wa_file.
          ENDAT.
        Check the Columen numbers and move the file data in to work area of Task.
        For Column  One
          IF wa_file-col =  '1'.
            MOVE wa_file-value TO wa_ztemp_employee-employeid.
          ENDIF.
        For Column Two
          IF wa_file-col = '2'.
            MOVE wa_file-value TO wa_ztemp_employee-employe_name.
          ENDIF.
          AT END OF row.
          The Data Transfer from work area to Internal table
            APPEND wa_ztemp_employee TO ta_ztemp_employee.
          Clear the  work area
            CLEAR wa_ztemp_employee.
          ENDAT.
        ENDLOOP.
       ELSE.
      MESSAGE e004 DISPLAY LIKE 'I'.
    try this code
    u will get
    Regards
    Edited by: Rasheed salman on Nov 28, 2008 6:33 AM

Maybe you are looking for