Error while uploading an edited excel file into an internal table

Hi Experts,
I am getting error while uploading an excel file that has been edited.
I am using GUI_UPLOAD for uploading the file into internal table.
In my program I first have to download a file, if I use the same file without editing I am able to read the file.
When I try to edit it and then use it to upload it fails, but this is part of the my requirement.
PLease suggest.
Regards
Kishore

TYPE-POOLS: truxs.
parameter :    lv_full_path     TYPE rlgrap-filename,
data : lt_conv_data   TYPE truxs_t_text_data,
          lt_roles_excel   type table of ( your structure).
start-of-selection.
        CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
          EXPORTING
            i_line_header        = 'X'
            i_filename           = lv_full_path
          TABLES
            i_tab_sap_data       = lt_roles_excel
          CHANGING
            i_tab_converted_data = lt_conv_data
          EXCEPTIONS
            conversion_failed    = 1
            OTHERS               = 2.
In the FM Line_header = 'X' means it will negelect the first line. So u can give the heading in the excel file.
Hope this might help u .
With Regards,
Sumodh.P

Similar Messages

  • Upload an Excel file into an Internal Table

    Hi,
    I want to upload an Excel file into an internal table but it doesn't work. I'd appreciate if someone could tell me what is wrong.
    My excel file has the following format:
          Col1  Col2
    Row1    1    2
    Row2    2    3
    Row3    3    4
    And the report code is the following one:
    REPORT ZFI_PROKON_PROCESOS.
    DATA: BEGIN OF itab OCCURS 0,
            num1(1),
            num2(1).
    DATA: END OF itab.
    PARAMETERS: p_file LIKE rlgrap-filename obligatory.
    AT SELECTION-SCREEN.
    AT SELECTION-SCREEN on value-request for p_file.
      call function 'KD_GET_FILENAME_ON_F4'
           EXPORTING
                static    = 'X'
           CHANGING
                file_name = p_file.
    START-OF-SELECTION.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
         EXPORTING
              FILENAME                = p_file
              I_BEGIN_COL             = 1
              I_BEGIN_ROW             = 1
              I_END_COL               = 2
              I_END_ROW               = 5
         TABLES
              INTERN                  = itab
        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 itab.
      WRITE: / itab-num1, 10 itab-num2.
    ENDLOOP.
    Thanks in advance,
    Gerard

    Try function module
    ALSM_EXCEL_TO_INTERNAL_TABLE
      call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           exporting
                filename                = p_path
                i_begin_col             = 1
                i_begin_row             = 2
                i_end_col               = 70
                i_end_row               = 10000
           tables
                intern                  = i_excel
           exceptions
                inconsistent_parameters = 1
                upload_ole              = 2
                others                  = 3.
    P_PATH is file name with path.
    I_EXCEL is internal table to store data.
    declaration is "i_excel like structure alsmex_tabline"
    then loop at i_Excel and populate your table
    for eg
      loop at i_excel.
        case  i_excel-col.
          when '0001'.
            i_data-compcode              = i_excel-value.
          when '0002'.
            i_data-rcpttyp               = i_excel-value.
          when '0003'.
            i_data-pocimpro              = i_excel-value.
          when '0004'.
            i_data-tranno                = i_excel-value.
          when '0005'.
            i_data-msrpo                 = i_excel-value.
          when '0006'.
            i_data-mporel                = i_excel-value.
        endcase.
        at end of row.
          append i_data.
          clear  i_data.
        endat.
      endloop.

  • CRM ABAP How to upload an Excel file into an internal table?

    How to upload an Excel file using GUI_UPLOAD?? what should be the values of the parameters? The function modules ALSM_EXCEL_TO_INTERNAL_TABLE and KCD_EXCEL_OLE_TO_INT are not present in CRM. Please suggest me a way out!

    Hi saurabh,
    you can try the folowing sample..
    and make modifications according to your requirement..
    TYPE-POOLS: truxs.
    DATA: i_text_data TYPE truxs_t_text_data,
    v_filename_string TYPE string.
    DATA: BEGIN OF itab OCCURS 0,
    Name(30),
    Phone(15),
    Fax(500).
    DATA: END OF itab.
    PARAMETERS: p_file LIKE rlgrap-filename.
    START-OF-SELECTION.
    v_filename_string = p_file.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = v_filename_string
    filetype = 'ASC'
    has_field_separator = 'X'
    * HEADER_LENGTH = 0
    * READ_BY_LINE = 'X'
    dat_mode = ''
    * IMPORTING
    * FILELENGTH =
    * HEADER =
    TABLES
    data_tab = i_text_data
    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.
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
    i_field_seperator = 'X'
    * I_LINE_HEADER =
    i_tab_raw_data = i_text_data
    i_filename = p_file
    TABLES
    i_tab_converted_data = itab
    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.
    this is a sample code that uploads a excel file using GUI_UPLOAD, but uses another function module to convert that uploaded data into an internal table..
    regards
    satesh

  • How to read data in correct format from EXCEL file into an internal table??

    Hi Experts,
    My requirement is to upload data from an excel file on presentation server into an internal table on <b>SRM</b> server.
    I used 'GUI_UPLOAD' function module to achieve the same but all the the data is getting uploaded in # only.I had set in the 'HAS_FIELD_SEPARATOR' to 'X' to overcome this problem.
    But all the efforts are in vain. The function module 'ALSM_EXCEL_TO_INTERNAL_TABLE' doesn't exist on SRM Server and I am not getting any other function module having similar functionality available on SRM server.
    I have written the following code:-
    TYPES: BEGIN OF ty_addr_loc,
             userid    TYPE xubname,      "User Id
             addr_code TYPE char4,        "3 Digit Site Location Code/4 Digit
                                                       "Alternate Address
             loc_id    TYPE bbp_location, "Indicator: Address is standard address
            END OF ty_addr_loc.
    *Retrieving file name
    parameters: p_file type rlgrap-filename.
      DATA:
        Local variable holding file name
          l_file TYPE string,
        Local Variable holding the file type,
          l_type TYPE filetype VALUE 'ASC',
        Local Variable holding the field separator
          l_sep  TYPE char01,
          i_tab type standard table of ty_addr_loc.
    Clearing local variables
      CLEAR:
            l_file,
            l_sep.
    Initializing the local variables
      MOVE p_file TO l_file.
      l_sep = 'X'.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                      = l_file
          filetype                      = l_type
          has_field_separator           = l_sep
       HEADER_LENGTH                 = 0
       READ_BY_LINE                  = 'X'
       DAT_MODE                      = ' '
       CODEPAGE                      = ' '
       IGNORE_CERR                   = ABAP_TRUE
       REPLACEMENT                   = '#'
       CHECK_BOM                     = ' '
       VIRUS_SCAN_PROFILE            =
       NO_AUTH_CHECK                 = ' '
    IMPORTING
       FILELENGTH                    =
       HEADER                        =
        TABLES
          data_tab                     = i_tab
       EXCEPTIONS
         file_open_error               = 1
         file_read_error               = 2
         no_batch                      = 3
         gui_refuse_filetransfer       = 4
         invalid_type                  = 5
         no_authority                  = 6
         unknown_error                 = 7
         bad_data_format               = 8
         header_not_allowed            = 9
         separator_not_allowed         = 10
         header_too_long               = 11
         unknown_dp_error              = 12
         access_denied                 = 13
         dp_out_of_memory              = 14
         disk_full                     = 15
         dp_timeout                    = 16
         OTHERS                        = 17
      IF sy-subrc <> 0.
      Throwing an information message
        MESSAGE i003. "Data Upload Failed
        LEAVE LIST-PROCESSING.
      ENDIF.
    Please tell me a way out. I have to make a delivery urgently.
    Thanks in advance,
    Swati Gupta

    Hi
    Try the FM <b>KCD_EXCEL_OLE_TO_INT_CONVERT</b>
    Sample:
      call function 'KCD_EXCEL_OLE_TO_INT_CONVERT'
           exporting
                filename                = i_filename
                i_begin_col             = l_begin_col
                i_begin_row             = l_begin_row
                i_end_col               = l_end_col
                i_end_row               = l_end_row
           tables
                intern                  = xt_intern
           exceptions
                INCONSISTENT_PARAMETERS = 201
                UPLOAD_OLE              = 201.
      if sy-subrc <> 0.
        e_subrc = sy-subrc.
        exit.
      endif.
    <b>reward if Helpful.</b>

  • How to upload data in excel file to an internal table

    hi,
    how can we upload data in excel file on presentation server to an internal table..?
    Any pointers on this would be helpful.
    Regards,
    Anil.

    hi
    use the fm ALSM_EXCEL_TO_INTERNAL_TABLE
    check this example
    TYPES: BEGIN OF ty_mara,
             matnr LIKE mara-matnr,
             mbrsh LIKE mara-mbrsh,
             mtart LIKE mara-mtart,
             maktx LIKE makt-maktx,
             meins LIKE mara-meins,
          END OF ty_mara.
    DATA: it_mara TYPE table of ty_mara WITH HEADER LINE.
    parameters : p_file like RLGRAP-FILENAME.
    data : itab type table of ALSMEX_TABLINE WITH HEADER LINE.
    start-of-selection.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = p_file
        i_begin_col                   = 1
        i_begin_row                   = 1
        i_end_col                     = 5
        i_end_row                     = 4
      tables
        intern                        = itab.
    loop at itab.
      CASE ITAB-COL.
        WHEN '1'.
          it_mara-matnr = ITAB-VALUE.
        WHEN '2'.
         it_mara-mbrsh = ITAB-VALUE.
        WHEN '3'.
          it_mara-mbrsh = ITAB-VALUE.
        WHEN '4'.
         it_mara-maktx  = ITAB-VALUE.
        WHEN '5'.
          it_mara-meins = ITAB-VALUE.
      ENDCASE.
    AT END OF ROW.
      APPEND it_mara.
      CLEAR it_mara.
    ENDAT.
      endloop.
    regards
    prasanth

  • I have problem of uploading excel file to my internal table

    Hi,
    I trying to upload data from excel file to my internal table and when i tried to debug the program and check the data in internal table and iam gettin # in all the fields and the data in not populated in internal table , as we are using 4.0b version and we are using UPLOAD FUNCTION.
            BUKRS(4) TYPE C,     
             PONO(8) TYPE C,     
             GRNNO(8) TYPE C,   
             DELNOTE(16) TYPE C,
             RECPTDT(10) TYPE C,  
             SUPPCODE(20) TYPE C, 
              RECPT(12) TYPE C,  
              GLACCT(10) TYPE C, 
             CCTR(6) TYPE C,      
      CALL FUNCTION 'UPLOAD'
        TABLES DATA_TAB = STRU.
      IF SY-SUBRC NE 0.
        WRITE: /'Data file error'.
      ENDIF.
    i am using the same sequeuence in the above structure in excel.

    Hi KODAMANCHILI,
    Refer following link :
    http://help.sap.com/saphelp_40b/helpdata/en/fc/eb3d9d358411d1829f0000e829fbfe/frameset.htm
    This will surely solve your problem.
    Regards,
    Vivek

  • Upload a .CSV File into an Internal table

    Hi,
    What are the parameters to be filled into the Function Modules "GUI_UPLOAD" and "ALSM_EXCEL_TO_INTERNAL_TABLE" to Upload a .CSV File into an internal table.
    Please send a sample code to support this....
    Regards,
    Aadhi.

    Hi,
            Check the below code.
    TYPE-POOLS: truxs.
    TYPES:
      BEGIN OF ty_line,
        vbeln LIKE vbap-vbeln,
        posnr LIKE vbap-posnr,
      END OF ty_line.
    *data:  ty_Lines TYPE STANDARD TABLE of ty_Line WITH DEFAULT KEY.
    DATA: itab   TYPE STANDARD TABLE OF ty_line WITH DEFAULT KEY.
    DATA: itab1  TYPE truxs_t_text_data.
    SELECT
      vbeln
      posnr
      UP TO 10 ROWS
      FROM vbap
      INTO TABLE itab.
    CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
      EXPORTING
        i_field_seperator    = ';'
      TABLES
        i_tab_sap_data       = itab
      CHANGING
        i_tab_converted_data = itab1
      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.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename = 'd:\TEMP\test1.txt'
      TABLES
        data_tab = itab1
      EXCEPTIONS
        OTHERS   = 1.
    IF sy-subrc eq 0.
      WRITE: 'Data downloaded successfully'.
    ENDIF.
    DATA: BEGIN OF IEXCEL OCCURS 0.
          INCLUDE STRUCTURE ALSMEX_TABLINE.
    DATA: END OF IEXCEL.
    PARAMETERS: FILENM   LIKE rlgrap-filename MEMORY ID M01,
                NOHEADER AS CHECKBOX.
    call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      exporting
        filename                      = FILENM
        i_begin_col                   = 1
        i_begin_row                  = 1
        i_end_col                     = 100
        i_end_row                     = 30000
      tables
        intern                        = IEXCEL
      EXCEPTIONS
        INCONSISTENT_PARAMETERS       = 1
        UPLOAD_OLE                    = 2
        OTHERS                        = 3.
    if sy-subrc <> 0.
       WRITE: / 'EXCEL UPLOAD FAILED ', FILENM, SY-SUBRC.
    endif.

  • Upload an XML file into the Internal table

    Hi Guys,
    I want to know, how to upload an xml file into the Internal table through ABAP programming

    you just wanted to load the xml file into internal table (as a table of binary strings)or load the xml data mapped to itab row columns
    for the first one you can simply use gui_upload
    and for the second one you need to load the xml file using gui_upload and use XLST program to transform into an itab
    Regards
    Raja

  • Loading an Excel file into a Z-Table

    Hi Gurus,
    Can somebody guide me how to load an excel file into  a Z-Table.

    Hi,
    You need to write a ABAP code for this....
    The following is the code for loading data into an internal table:
    types: begin of ttab,
           rec(1000) type c,
           end of ttab.
    types: begin of tdat,
           fld1(10) type c,
           fld2(10) type c,
           fld3(10) type c,
           end of tdat.
    data: itab type table of ttab with header line.
    data: idat type table of tdat with header line.
    data: file_str type string.
    parameters: p_file type localfile.
    at selection-screen on value-request for p_file.
      call function 'KD_GET_FILENAME_ON_F4'
           exporting
                static    = 'X'
           changing
                file_name = p_file.
    start-of-selection.
      file_str = p_file.
      call function 'GUI_UPLOAD'
           exporting
                filename                = file_str
           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.
    delete itab index 1.
      loop at itab.
        clear idat.
        split itab-rec at cl_abap_char_utilities=>horizontal_tab
                              into idat-fld1
                                   idat-fld2
                                   idat-fld3.
        append idat.
      endloop.
      loop at idat.
        write:/ idat-fld1, idat-fld2, idat-fld3.
      endloop.
    From this internal store it onto the database.....
    Sharma one more thing you must have posted this question in ABAP fourum for better results....
    Hope it helps,
    Thanks,
    Happy Life,
    Aravind

  • Collect data from a dynamic XML file into multiple internal tables

    I need to convert the XML file into multiple internal tables. I tried many links and posts in SDN but still was facing difficulty in achieving this. Can some one tell me where I am going wrong.
    My XML file is of the following type.It is very complex and the dynamice.
    The following tags occur more than once in the XML file. The "I" and "L" tags and its child tags can occur ones or more than once for each XML file and it is not constant. i.e in one file they can occur 1 time and in another they can occur 100 times.
    "I" and "L" are child tags of <C>
    <I>
           <J>10</J>
             <K>EN</K>
      </I>
    <L>
             <J>20</J>
              <N>BB</N>
      </L>
    Tags <C> and <F> occur only ones for each XML file. <C> is the child tag of "A" and "F" is the child tag of <C>.
    I need to collect <D>, <E> in one internal table ITAB.
    I need to collect <G>, <H> in one internal table JTAB.
    I need to collect <J>, <K> in one internal table KTAB.
    I need to collect <J>, <N> in one internal table PTAB.
    Below is the complete XML file.
    ?xml version="1.0" encoding="iso-8859-1" ?>
    <A>
        <B/>
        <C>
           <D>RED</D>
           <E>999</E>
        <F>
           <G>TRACK</G>
           <H>PACK</H>
        </F>
        <I>
           <J>10</J>
           <K>EN</K>
        </I>
        <I>
           <J>20</J>
           <K>TN</K>
        </I>
        <I>
           <J>30</J>
           <K>KN</K>
        </I>
        <L>
           <J>10</J>
           <N>AA</N>
        </L>
        <L>
           <J>20</J>
           <N>BB</N>
        </L>
        <L>
           <J>30</J>
           <N>CC</N>
        </L>
        </C>
      </A>
    With the help of SDN I am able to gather the values of <D> <E> in one internal table.
    Now if I need to gather
    <G>, <H> in one internal table JTAB.
    <J>, <K> in one internal table KTAB.
    <J>, <N> in one internal table PTAB.
    I am unable to do. I am following  XSLT transformation method. If some one has some suggestions. Please help.
    Here is my ABAP program
    TYPE-POOLS abap.
    CONSTANTS gs_file TYPE string VALUE 'C:\TEMP\ABCD.xml'.
    * This is the structure for the data from the XML file
    TYPES: BEGIN OF ITAB,
             D(10) TYPE C,
             E(10) TYPE C,
           END OF ITAB.
    * Table for the XML content
    DATA: gt_itab       TYPE STANDARD TABLE OF char2048.
    * Table and work ares for the data from the XML file
    DATA: gt_ITAB     TYPE STANDARD TABLE OF ts_ITAB,
          gs_ITAB     TYPE ts_ITAB.
    * Result table that contains references
    * of the internal tables to be filled
    DATA: gt_result_xml TYPE abap_trans_resbind_tab,
          gs_result_xml TYPE abap_trans_resbind.
    * For error handling
    DATA: gs_rif_ex     TYPE REF TO cx_root,
          gs_var_text   TYPE string.
    * Get the XML file from your client
    CALL METHOD cl_gui_frontend_services=>gui_upload
      EXPORTING
        filename                = gs_file
      CHANGING
        data_tab                = gt_itab1
      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.
    * Fill the result table with a reference to the data table.
    * Within the XSLT stylesheet, the data table can be accessed with
    * "IITAB".
    GET REFERENCE OF gt_shipment INTO gs_result_xml-value.
    gs_result_xml-name = 'IITAB'.
    APPEND gs_result_xml TO gt_result_xml.
    * Perform the XSLT stylesheet
    TRY.
        CALL TRANSFORMATION zxslt
        SOURCE XML gt_itab1
        RESULT (gt_result_xml).
      CATCH cx_root INTO gs_rif_ex.
        gs_var_text = gs_rif_ex->get_text( ).
        MESSAGE gs_var_text TYPE 'E'.
    ENDTRY.
    * Now let's see what we got from the file
    LOOP AT gt_ITAB INTO gs_ITAB.
      WRITE: / 'D:', gs_ITAB-D.
      WRITE: / 'E :', gs_ITAB-E.
    ENDLOOP.
    Transformation
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
      <xsl:strip-space elements="*"/>
      <xsl:template match="/">
        <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
          <asx:values>
            <IITAB>
              <xsl:apply-templates select="//C"/>
            </IITAB>
          </asx:values>
        </asx:abap>
      </xsl:template>
      <item>
          <D>
            <xsl:value-of select="D"/>
          </D>
          <E>
            <xsl:value-of select="E"/>
          </E>
        </item>
      </xsl:template>
    </xsl:transform>
    Now the above pgm and transformation work well and I am able to extract data into the ITAB. Now what changes should I make in transformation and in pgm to collect
    <G>, <H> in one internal table JTAB.
    <J>, <K> in one internal table KTAB.
    <J>, <N> in one internal table PTAB.
    Please help..i am really tring hard to figure this out. I am found lot of threads addressing this issue but not my problem.
    Kindly help.
    Regards,
    VS

    Hi Rammohan,
    Thanks for the effort!
    But I don't need to use GUI upload because my functionality does not require to fetch data from presentation server.
    Moreover, the split command advised by you contains separate fields...f1, f2, f3... and I cannot use it because I have 164 fields.  I will have to split into 164 fields and assign the values back to 164 fields in the work area/header line.
    Moreover I have about 10 such work areas.  so the effort would be ten times the above effort! I want to avoid this! Please help!
    I would be very grateful if you could provide an alternative solution.
    Thanks once again,
    Best Regards,
    Vinod.V

  • Reading long text from excel file to an internal table

    Hi
    Can any body tell me how to read long text from excel file to an internal table.
    When i am using this FM KCD_EXCEL_OLE_TO_INT_CONVERT then it is reading only 32 characters from each cell.
    But in my excel sheet in one of the cell has very long text which i need to upload into a internal table.
    may i know which FM or what logic i need to use for this problem.
    Regards

    Hi,
    Here is an example program.  It will upload an Excel file with two columns.  You could also assign the Excel structure dynamically, but I wanted to keep the example simple.  The main point is that the internal table (it_excel in this example) must match the Excel structure that you want to convert.
    Remember, this is just an example to help you figure out how to properly use the technique.  It will certainly need to be modified to fit your requirements, and as always there may be a better way to get the Excel converted... this is just one possibility that has worked for me in the past.
    *& Report  zexcel_upload_test                            *
    REPORT  zexcel_upload_test.
    TYPE-POOLS: truxs.
    TYPES: BEGIN OF ty_excel,
             col_a(10) TYPE n,
             col_b(35) TYPE c,
           END OF ty_excel.
    DATA: l_data_tab         TYPE TABLE OF string,
          l_text_data        TYPE truxs_t_text_data,
          l_gui_filename     TYPE string,
          it_excel           TYPE TABLE OF ty_excel.
    FIELD-SYMBOLS: <wa_excel>  TYPE ty_excel.
    PARAMETERS: p_file TYPE rlgrap-filename.
    * Pass the file name in the correct format
    l_gui_filename = p_file.
    * Upload data from PC
    CALL METHOD cl_gui_frontend_services=>gui_upload
      EXPORTING
        filename                = l_gui_filename
        filetype                = 'ASC'
        has_field_separator     = 'X'
      CHANGING
        data_tab                = l_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
        OTHERS                  = 17.
    IF sy-subrc <> 0.
    *   MESSAGE ...
      EXIT.
    ENDIF.
    * Convert from Excel into the appropriate itab
    l_text_data[] = l_data_tab[].
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
      EXPORTING
        i_field_seperator    = 'X'
        i_tab_raw_data       = l_text_data
        i_filename           = p_file
      TABLES
        i_tab_converted_data = it_excel
      EXCEPTIONS
        conversion_failed    = 1
        OTHERS               = 2.
    IF sy-subrc <> 0.
    *   MESSAGE ...
      EXIT.
    ENDIF.
    LOOP AT it_excel ASSIGNING <wa_excel>.
    *  Do something here...
    ENDLOOP.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      PERFORM filename_get CHANGING p_file.
    *       FORM filename_get                                             *
    FORM filename_get CHANGING p_in_file TYPE rlgrap-filename.
      DATA: l_in_file  TYPE string,
            l_filetab  TYPE filetable,
            wa_filetab TYPE LINE OF filetable,
            l_rc       TYPE i,
            l_action   TYPE i,
            l_init_dir TYPE string.
    * Set the initial directory to whatever you want it to be
      l_init_dir = 'C:\'.
    * Call the file open dialog without multiselect
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        EXPORTING
          window_title            = 'Load file'
          default_extension       = '.XLS'
          default_filename        = l_in_file
          initial_directory       = l_init_dir
          multiselection          = 'X'
        CHANGING
          file_table              = l_filetab
          rc                      = l_rc
          user_action             = l_action
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          OTHERS                  = 4.
      IF sy-subrc <> 0.
        REFRESH l_filetab.
      ENDIF.
    * Read the selected filename
      READ TABLE l_filetab INTO wa_filetab INDEX 1.
      IF sy-subrc = 0.
        p_in_file = wa_filetab-filename.
      ENDIF.
    ENDFORM.                    " filename_get
    Regards,
    Jamie

  • Change Value While Uploading data From Excel File

    Dear Expert,
    Please guide me is it Possible?, if yes then How?
    We have one BDC Uploader there After uploading data from Excel File, i want to check one field like this....
    if it_f65data-newbs contains any Alphabet.
    then user Should be able to change value on the same time while executing Program in table.
    Please tell me how i can change value in running program
    Regards'
    Shelly Malik

    Hi,
    What you can probably do is, perform a consistency check on your data in the internal table and segregate all those rows that have inconsistent data (in your case, the field NEWBS containing albhabets) into another temporary internal table. Display the temporary internal table in an editable ALV grid saying that these data have not been inserted to the database, coz they have inconsistent data in the field NEWBS. Allow the user to edit and then save the data which will consequently refresh the internal table contents.

  • Error while uploading cost element planning data into KP06 transaction

    Hi,
    I am facing the below error while uploading the Cost Element Planning excel file in KP06 transaction code. Please help me in fix this issue.
    We are trying to enter a budget upload using Transaction code: KP06. We get the following message errors  when we do this. It seems revenue accounts cannot be entered using cost centers. Question, how should these accounts be added? Kindly help me how to add Revenue cost elements to this planning?
    Error accured when generating data for the planning processor
    Messange no.K9400
    Revenue element 451000 can not be planned on cost center 9720
    Thanks
    Kishore

    The cost element which have  category 01 only can be planned in the Kp06.
    Regards
    Ranjan

  • Best way to read a CSV file into an internal table

    Hi,
    I have a comma seprated file, which I need to read into an internal table, and be able to look at particular values - basically looping round and populating BDC fields. Whats the easiest way of doing this?

    The easiest way would be to define a flat interal table.
    Data: begin of itab occurs 0,
          rec(1000) type c,
          end of itab.
    Then call the function module GUI_UPLOAD to get the data into your internal table from the file on the frontend. I assume that you know how to use this function module.  You could also use the method GUI_UPLOAD of the class CL_GUI_FRONTEND_SERVICES.
    For example,  say you have a comman delimited file with materail number, plant, quantity in it.
    4000001,0004,1.00
    4000002,0006,2.00
    Define another internal table to hold the data.
    Data: begin of itab2 occurs 0,
          matnr type mara-matnr
          werks type marc-werks
          quant(10) type c.
          end of itab2.
    Then loop at the internal table(ITAB) and use the split statement to split it up into the appropriate fields of the other interal table(ITAB2). 
    Loop at itab.
    clear itab2.
    split itab-rec at ',' into itab2-matnr
                               itab2-werks
                               itab2-quant.
    append itab2.
    endloop.
    That's it.
    Regards,
    Rich Heilman
    Message was edited by: Rich Heilman

  • OEDQ 11 - error.connection.externaldatasource - While trying to export excel file into local drive

    Team I am trying to export a dataset as a excel spreadsheet on to my local drive. when I ever I try to run the Export I am getting error.connection.externaldatasource error message.
    Even I tried creating a excel file in my local and point that file in EDQ - Data Stores connection , still getting the same error message.
    Please help.
    Thanks!
    BG

    Also useful to understand:
    - Is it a server-side or client-side data store?
    - Is it an XLS or an XLSX file you are trying to write?
    - What's the data volume?

Maybe you are looking for

  • I can't sync my iphone to itunes. It says not enough access privileges? Help please?

    I have a hp computer and I created another account on the computer so it's me and my mom's account. I been using my mom's but I want to sync it on my part of the computer and it says I don't have enough access privileges? I need help ASAP please?

  • Songs from iPod to new computer?

    I have an HP running Vista that recently got a corrupt hard drive. We took it to a store and had them wipe the hard drive. I just got it back today and re-installed iTunes. All my playlists are gone, but the music is still there. When I plugged my iP

  • Error while trying to load java classes

    I am doing a 9iAS installation - at the end of the installation I get an error stating that the SSOHash class has not been loaded into the database. When I run the loadjava utility to load the class into the database I get the following error: ora-29

  • Recommend a good text editor for JAVA/C/C++

    Hi, Could anyone recommend some good (preferably freeware) text editors that can parse Java and C/C++? Thanks!

  • Unable to download iOS 7

    I have an iPhone 4S and been trying to update to the new iOS7 both in iTunes (the new one they released) and on my iPhone. For both, it would show 22hours remaining and would slowly change to 2hours or 1 hour. But then it would provide an error "Erro