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

Uploading and Downloading Excel file from application server.

Hi All,

Could any one tell me the procedure for downloading and uploading Excel file from application server.

Thanks in advance.

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 Jan 30, 2008 at 11:49 AM

    Hi Sir ,

    Please have a look below .Hope it is suitable and simpler solution for your question.

    Please do reward if useful.

    Thankx.

    declarations:

    DATA:IT_EXCEL LIKE TABLE OF ALSMEX_TABLINE WITH HEADER LINE.

    I guess u r familiar with notepad upload.....just use your declaration as it is. Below is a basic demonstration of uploading data from excel...reward if useful.

    Excel file Locating.

    SELECTION-SCREEN SKIP 1.

    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.

    PARAMETERS: P_FILE TYPE LOCALFILE OBLIGATORY .

    SELECTION-SCREEN END OF BLOCK B1.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

    EXPORTING

    STATIC = 'X'

    CHANGING

    FILE_NAME = P_FILE.

    Check whether the uploaded fiel is excel or not

    AT SELECTION-SCREEN ON P_FILE.

    WK_LEN = P_FILE.

    CONDENSE WK_LEN NO-GAPS.

    LENT = STRLEN( WK_LEN ).

    WK_ALP = LENT - 4.

    B = WK_LEN+WK_ALP(LENT).

    IF ( B NE '.xls' AND B NE '.XLS' ).

    MESSAGE E939.

    CLEAR P_FILE.

    STOP.

    ENDIF.

    START-OF-SELECTION.

    do all the othre process here

    PERFORM FETCH_FROM_FLAT_FILE.

    store the values to your normal itab and the process.

    LOOP AT IT_EXCEL.

    CASE IT_EXCEL-COL.

    WHEN '0001'.

    MOVE: IT_EXCEL-VALUE TO RECORD1-MATNR_005.

    WHEN '0002'.

    MOVE: IT_EXCEL-VALUE TO WK_WERKS.

    WHEN '0003'.

    MOVE: IT_EXCEL-VALUE TO RECORD1-BUDAT_002.

    WHEN '0004'.

    MOVE: IT_EXCEL-VALUE TO RECORD1-BKTXT_004.

    WHEN '0005'.

    MOVE: IT_EXCEL-VALUE TO RECORD1-ERFMG_007.

    WHEN '0006'.

    MOVE: IT_EXCEL-VALUE TO RECORD1-ERFMG_008.

    ENDCASE.

    AT END OF ROW.

    APPEND RECORD1.

    CLEAR RECORD1.

    ENDAT.

    ENDLOOP.

    **Here record1 is the internal table holding the data fetched from excel

    end-of-selection.

    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

    EXPORTING

    FILENAME = P_FILE

    I_BEGIN_COL = 1 "From 1st Column

    I_BEGIN_ROW = 2 "From 2nd row

    I_END_COL = 6 "Till 6th Column

    I_END_ROW = 65536 "Till Row

    TABLES

    INTERN = IT_EXCEL

    EXCEPTIONS

    INCONSISTENT_PARAMETERS = 1

    UPLOAD_OLE = 2

    OTHERS = 3.

    CLEAR IT_EXCEL.

    DESCRIBE TABLE IT_EXCEL.

    IF SY-TFILL = 0.

    MESSAGE I937.

    STOP.

    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 11:39 AM

    Hi ,

    to download this the procedure:

    you can use the FM 'EXCEL_OLE_STANDARD_DAT ' for this purpose.

    this FM 'EXCEL_OLE_STANDARD_DAT' can be used to start Excel with a new sheet and transfer data from an internal table to the sheet.

    Here are some of the parameters:

    file_name: Name and path of the Excel worksheet file e.g. ?C:TEMPZTEST?

    data_tab: Name of the internal table that should be uploaded to Exvcel

    fieldnames: Internal tabel with column headers

    How to build the field names table:

    data: begin of i_fieldnames occurs 20,

    field(60), end of i_fieldnames.

    i_fieldnames-field = ?This is column 1?. append i_fieldnames-field.

    i_fieldnames-field = ?This is column 2?. append i_fieldnames-field.

    to upload follow this:

    OPEN DATASET dsn FOR INPUT IN BINARY MODE.

    DO.

    READ DATASET dsn INTO itab-field.

    IF sy-subrc = 0.

    APPEND itab.

    ELSE.

    EXIT.

    ENDIF.

    ENDDO.

    [/code]Rob

    or Try this function module.

    FILE_READ_AND_CONVERT_SAP_DATA

    pass 'XLS' to I_FILEFORMAT..

    pls reward if helps,

    regards.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 11:43 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 12:10 PM

    hi

    good

    declarations:

    DATA:IT_EXCEL LIKE TABLE OF ALSMEX_TABLINE WITH HEADER LINE.

    I guess u r familiar with notepad upload.....just use your declaration as it is. Below is a basic demonstration of uploading data from excel...reward if useful.

    Excel file Locating.

    SELECTION-SCREEN SKIP 1.

    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.

    PARAMETERS: P_FILE TYPE LOCALFILE OBLIGATORY .

    SELECTION-SCREEN END OF BLOCK B1.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

    EXPORTING

    STATIC = 'X'

    CHANGING

    FILE_NAME = P_FILE.

    Check whether the uploaded fiel is excel or not

    AT SELECTION-SCREEN ON P_FILE.

    WK_LEN = P_FILE.

    CONDENSE WK_LEN NO-GAPS.

    LENT = STRLEN( WK_LEN ).

    WK_ALP = LENT - 4.

    B = WK_LEN+WK_ALP(LENT).

    IF ( B NE '.xls' AND B NE '.XLS' ).

    MESSAGE E939.

    CLEAR P_FILE.

    STOP.

    ENDIF.

    START-OF-SELECTION.

    do all the othre process here

    PERFORM FETCH_FROM_FLAT_FILE.

    store the values to your normal itab and the process.

    LOOP AT IT_EXCEL.

    CASE IT_EXCEL-COL.

    WHEN '0001'.

    MOVE: IT_EXCEL-VALUE TO RECORD1-MATNR_005.

    WHEN '0002'.

    MOVE: IT_EXCEL-VALUE TO WK_WERKS.

    WHEN '0003'.

    MOVE: IT_EXCEL-VALUE TO RECORD1-BUDAT_002.

    WHEN '0004'.

    MOVE: IT_EXCEL-VALUE TO RECORD1-BKTXT_004.

    WHEN '0005'.

    MOVE: IT_EXCEL-VALUE TO RECORD1-ERFMG_007.

    WHEN '0006'.

    MOVE: IT_EXCEL-VALUE TO RECORD1-ERFMG_008.

    ENDCASE.

    AT END OF ROW.

    APPEND RECORD1.

    CLEAR RECORD1.

    ENDAT.

    ENDLOOP.

    **Here record1 is the internal table holding the data fetched from excel

    end-of-selection.

    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

    EXPORTING

    FILENAME = P_FILE

    I_BEGIN_COL = 1 "From 1st Column

    I_BEGIN_ROW = 2 "From 2nd row

    I_END_COL = 6 "Till 6th Column

    I_END_ROW = 65536 "Till Row

    TABLES

    INTERN = IT_EXCEL

    EXCEPTIONS

    INCONSISTENT_PARAMETERS = 1

    UPLOAD_OLE = 2

    OTHERS = 3.

    CLEAR IT_EXCEL.

    DESCRIBE TABLE IT_EXCEL.

    IF SY-TFILL = 0.

    MESSAGE I937.

    STOP.

    ENDIF.

    thanks

    mrutyun^

    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.