cancel
Showing results for 
Search instead for 
Did you mean: 

copy an excel sheet

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Varun,

You can use FM ALSM_EXCEL_TO_INTERNAL_TABLE to do the job.

Regards,

John.

Former Member
0 Kudos

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.