Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

GUI_UPLOAD for Excel file read

Former Member
0 Likes
776

Hi Experts,

I am transferring excel sheet content to internal table, for which I am using GUI_UPLOAD function module. It is successfully reading, but I am getting ##### values instead of text values. I am getting more than expected lines also. My code is below.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = w_file_url

FILETYPE = 'DAT'

HAS_FIELD_SEPARATOR = 'X'

tables

data_tab = t_uploadeddata

I used my file type as 'ASC' and 'BIN' also. Can anybody help me?

Thanks and regards,

Venkat

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
695

hi,

try out the following function module...

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
  EXPORTING
*   I_FIELD_SEPERATOR =
*   I_LINE_HEADER  = 'X'
    i_tab_raw_data = it_type
    i_filename     = p_file
  TABLES
    i_tab_converted_data = t_upload[]
  EXCEPTIONS
    conversion_failed = 1
    OTHERS            = 2.

Thanks

Sharath

Hi Experts,

I am transferring excel sheet content to internal table, for which I am using GUI_UPLOAD function module. It is successfully reading, but I am getting ##### values instead of text values. I am getting more than expected lines also. My code is below.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = w_file_url

FILETYPE = 'DAT'

HAS_FIELD_SEPARATOR = 'X'

tables

data_tab = t_uploadeddata

I used my file type as 'ASC' and 'BIN' also. Can anybody help me?

Thanks and regards,

Venkat

3 REPLIES 3
Read only

Former Member
0 Likes
695

the function module gui_upload, accepts the filename as a string variable....

hence do the following

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

PARAMETERS : P_FILE TYPE RLGRAP-FILENAME DEFAULT 'D:\Example.txt'.

SELECTION-SCREEN END OF BLOCK B1.

data : w_file type string.

w_file = p_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = W_FILE

FILETYPE = 'ASC'

has_field_separator = ' '

tables

data_tab = FILE_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.

Read only

Former Member
0 Likes
696

hi,

try out the following function module...

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
  EXPORTING
*   I_FIELD_SEPERATOR =
*   I_LINE_HEADER  = 'X'
    i_tab_raw_data = it_type
    i_filename     = p_file
  TABLES
    i_tab_converted_data = t_upload[]
  EXCEPTIONS
    conversion_failed = 1
    OTHERS            = 2.

Thanks

Sharath

Read only

Former Member
0 Likes
695

Hi,

Better use 'TEXT_CONVERT_XLS_TO_SAP' or KCD_EXCEL_OLE_TO_INT_CONVERT or ALSM_EXCEL_TO_INTERNAL_TABLE instead of GUI_UPLOAD.

Definetly your problem will be solved.

PS: serach the FM name on the forum or on the net for the code snippet ,you get plenty of them

Pooja

Edited by: Pooja Gupta on Mar 17, 2009 12:21 PM