‎2008 Oct 24 7:24 AM
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file
has_field_separator = '#'
TABLES
data_tab = lt_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
I am using the above FM to read data from a text file. now i want to read data from an excel sheet.
is it possible using this same FM? i tried but it is not working .
If it is possible what changes i need to make in passing the parameters.
otherwise is there any FM which reads data from excel sheet?
‎2008 Oct 24 7:27 AM
‎2008 Oct 24 7:28 AM
Hello,
Try in this way it will work.
DATA y_lv_fnam1 TYPE string.
y_k_asc TYPE char10 VALUE 'ASC',
y_k_x TYPE char1 VALUE 'X',
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = y_lv_fnam1
filetype = y_k_asc
has_field_separator = y_k_x
TABLES
data_tab = y_li_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.
MOVE y_k_x TO y_v_error.
MESSAGE ID sy-msgid TYPE y_k_s NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
‎2008 Oct 24 7:28 AM
Hi
try this code.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = '1'
i_begin_row = begn_row
i_end_col = '5'
i_end_row = end_row
TABLES
intern = excel_tab
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.
Arunima
‎2008 Oct 24 7:29 AM
‎2008 Oct 24 7:31 AM
yes you can in gui_upload:
please have a look into this :
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename =
FILETYPE = 'ASC'** HAS_FIELD_SEPARATOR = ' '
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 =
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.
you have file type here , just give the type whether XLS or CSV format or whatever.
‎2008 Oct 24 7:31 AM
Hello,
Take a look on this: ABAP - [Upload data from Excel |https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap-UploaddatafromExceltoSapusing+OO] to Sap using OO. It's a program to upload data and as you can see in this, it shows how to navigate between spreadsheets and cells.
Regards.