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

copy an excel sheet

how can we copy an excel file in an internal table. which is the function which can do this or is there any sample program available for it.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Dec 09, 2004 at 02:50 PM

    If you save the excel document as "tab deliminated text" you can use the sample code below.

    itab and the structure of the file must be same. And there must be no header line.

    FORM fill_itab .

    DATA:

    filetable TYPE filetable,

    filename TYPE string,

    rc TYPE i.

    CALL METHOD cl_gui_frontend_services=>file_open_dialog

    CHANGING

    file_table = filetable

    rc = rc

    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 filetable INTO filename INDEX 1.

    CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

    filename = filename

    filetype = 'ASC'

    has_field_separator = 'X'

    • HEADER_LENGTH = 0

    read_by_line = 'X'

    DAT_MODE = 'X'

    • CODEPAGE = ' '

    • IGNORE_CERR = ABAP_TRUE

    • REPLACEMENT = '#'

    • CHECK_BOM = ' '

    • IMPORTING

    • FILELENGTH =

    • HEADER =

    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.

    ENDFORM. " fill_itab

    -


    If it helps please give points.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 09, 2004 at 03:00 PM

    Hi Varun,

    You can use FM ALSM_EXCEL_TO_INTERNAL_TABLE to do the job.

    Regards,

    John.

    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.