Skip to Content
author's profile photo Former Member
Former Member

GUI_UPLOAD for Excel File

Hi,

I am having tab delimit file. I have declared the internal table for uploading data from the file exactly as the type of data to be uploaded. When, I am Calling the GUI_UPLOAD Function Module, I am passing the file name and making the HAS_FIELD_SEPARATOR TO 'X'.

It is working very fine with the tab delimit text(.txt) file.

But, when I am giving the Excel File(.xls), it is throwing and Error Message and coming out of the program. The Error Message displayed is 'Cannot Interpret data in file'.

I am not able to understand, where the error is. Please help.

Regards,

Ishaq.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 22, 2007 at 08:37 AM

    remove this HAS_FIELD_SEPARATOR TO 'X'. when your are using .xls

    you can use the function module ALSM_EXCEL_TO_INTERNAL_TABLE instead of that if it is excel file

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 22, 2007 at 08:39 AM

    Hi , You cannot pass HAS_FIELD_SEPARATOR TO 'X'.

    and XL file both as feild separator is Used only for the ASCII format.

    • Please mark Useful answers

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 22, 2007 at 08:39 AM

    Hi,

    To upload XLS files use the FM in the below example :-

    Check this Sample code.
    
    TABLES : LFA1,RF02K.
     
    DATA : BEGIN OF ITAB OCCURS 0,
    LIFNR LIKE RF02K-LIFNR,
    KTOKK LIKE RF02K-KTOKK,
    NAME1 LIKE LFA1-NAME1,
    SORTL LIKE LFA1-SORTL,
    LAND1 LIKE LFA1-LAND1,
    SPRAS LIKE LFA1-SPRAS,
    END OF ITAB.
     
    DATA : ITAB1 LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
     
    DATA : B1 TYPE I VALUE 1,
     
    C1 TYPE I VALUE 1,
     
    B2 TYPE I VALUE 10,
     
    C2 TYPE I VALUE 99.
     
     
    INCLUDE BDCRECX1.
     
    START-OF-SELECTION.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
    FILENAME = 'C:xl1.XLS'
    I_BEGIN_COL = B1
    I_BEGIN_ROW = C1
    I_END_COL = B2
    I_END_ROW = C2
    TABLES
    INTERN = ITAB1
    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.
    PERFORM ORGANIZE_UPLOADED_DATA.
    *----------------------------------------------------------------------*
    PERFORM OPEN_GROUP.
    LOOP AT ITAB.
    PERFORM BDC_DYNPRO USING 'SAPMF02K' '0100'.
    PERFORM BDC_FIELD USING 'BDC_CURSOR'
    'RF02K-KTOKK'.
    PERFORM BDC_FIELD USING 'BDC_OKCODE'
    '/00'.
    PERFORM BDC_FIELD USING 'RF02K-LIFNR'
    ITAB-LIFNR.
    PERFORM BDC_FIELD USING 'RF02K-KTOKK'
    ITAB-KTOKK.
    PERFORM BDC_DYNPRO USING 'SAPMF02K' '0110'.
    PERFORM BDC_FIELD USING 'BDC_CURSOR'
    'LFA1-SPRAS'.
    PERFORM BDC_FIELD USING 'BDC_OKCODE'
    '/00'.
    PERFORM BDC_FIELD USING 'LFA1-NAME1'
    ITAB-NAME1.
    PERFORM BDC_FIELD USING 'LFA1-SORTL'
    ITAB-SORTL.
    PERFORM BDC_FIELD USING 'LFA1-LAND1'
    ITAB-LAND1.
    PERFORM BDC_FIELD USING 'LFA1-SPRAS'
    ITAB-SPRAS.
    PERFORM BDC_DYNPRO USING 'SAPMF02K' '0120'.
    PERFORM BDC_FIELD USING 'BDC_CURSOR'
    'LFA1-KUNNR'.
    PERFORM BDC_FIELD USING 'BDC_OKCODE'
    '/00'.
    PERFORM BDC_DYNPRO USING 'SAPMF02K' '0130'.
    PERFORM BDC_FIELD USING 'BDC_CURSOR'
    'LFBK-BANKS(01)'.
    PERFORM BDC_FIELD USING 'BDC_OKCODE'
    '=ENTR'.
    PERFORM BDC_DYNPRO USING 'SAPLSPO1' '0300'.
    PERFORM BDC_FIELD USING 'BDC_OKCODE'
    '=YES'.
    PERFORM BDC_TRANSACTION USING 'XK01'.
     
    PERFORM CLOSE_GROUP.
    ENDLOOP.
    FORM ORGANIZE_UPLOADED_DATA .
     
    SORT ITAB1 BY ROW
    COL.
     
    LOOP AT ITAB1.
     
    CASE ITAB1-COL.
    * ....................................................
    WHEN 1.
    ITAB-LIFNR = ITAB1-VALUE.
    WHEN 2.
    ITAB-KTOKK = ITAB1-VALUE.
    WHEN 3.
    ITAB-NAME1 = ITAB1-VALUE.
    WHEN 4.
    ITAB-SORTL = ITAB1-VALUE.
    WHEN 5.
    ITAB-LAND1 = ITAB1-VALUE.
    WHEN 6.
    ITAB-SPRAS = ITAB1-VALUE.
    * ....................................................
    ENDCASE.
     
     
    AT END OF ROW.
    * wa_tabdata-mandt = sy-mandt.
    * APPEND wa_tabdata TO it_tabdata.
    * CLEAR: wa_tabdata.
    APPEND ITAB.
    CLEAR ITAB.
    ENDAT.
     
    ENDLOOP.
     
    ENDFORM. " ORGANIZE_UPLOADED_DATA 
    
    

    Regards,

    Deepu.K

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 22, 2007 at 08:53 AM

    Hi Ishaq,

    Gui_Upload does not read Exel files directly. Use TEXT_CONVERT_XLS_TO_SAP, to read Exel files direcly to SAP. Its much better option then converting your exel file to tab limited and then using gui_upload.

    Hope this helps.

    Reward if helpful

    Regards,

    Karan

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.