Application Development 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: 

How to read data in correct format from EXCEL file into an internal table??

Former Member
0 Kudos

Hi Experts,

My requirement is to upload data from an excel file on presentation server into an internal table on <b>SRM</b> server.

I used 'GUI_UPLOAD' function module to achieve the same but all the the data is getting uploaded in # only.I had set in the 'HAS_FIELD_SEPARATOR' to 'X' to overcome this problem.

But all the efforts are in vain. The function module 'ALSM_EXCEL_TO_INTERNAL_TABLE' doesn't exist on SRM Server and I am not getting any other function module having similar functionality available on SRM server.

I have written the following code:-

TYPES: BEGIN OF ty_addr_loc,

userid TYPE xubname, "User Id

addr_code TYPE char4, "3 Digit Site Location Code/4 Digit

"Alternate Address

loc_id TYPE bbp_location, "Indicator: Address is standard address

END OF ty_addr_loc.

*Retrieving file name

parameters: p_file type rlgrap-filename.

DATA:

  • Local variable holding file name

l_file TYPE string,

  • Local Variable holding the file type,

l_type TYPE filetype VALUE 'ASC',

  • Local Variable holding the field separator

l_sep TYPE char01,

i_tab type standard table of ty_addr_loc.

  • Clearing local variables

CLEAR:

l_file,

l_sep.

  • Initializing the local variables

MOVE p_file TO l_file.

l_sep = 'X'.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = l_file

filetype = l_type

has_field_separator = l_sep

  • 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 = i_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.

  • Throwing an information message

MESSAGE i003. "Data Upload Failed

LEAVE LIST-PROCESSING.

ENDIF.

Please tell me a way out. I have to make a delivery urgently.

Thanks in advance,

Swati Gupta

3 REPLIES 3

h_senden2
Active Contributor
0 Kudos

try function module ALSM_EXCEL_TO_INTERNAL_TABLE

regards,

Hans

varma_narayana
Active Contributor
0 Kudos

Hi

Try the FM <b>KCD_EXCEL_OLE_TO_INT_CONVERT</b>

Sample:

call function 'KCD_EXCEL_OLE_TO_INT_CONVERT'

exporting

filename = i_filename

i_begin_col = l_begin_col

i_begin_row = l_begin_row

i_end_col = l_end_col

i_end_row = l_end_row

tables

intern = xt_intern

exceptions

INCONSISTENT_PARAMETERS = 201

UPLOAD_OLE = 201.

if sy-subrc <> 0.

e_subrc = sy-subrc.

exit.

endif.

<b>reward if Helpful.</b>

Former Member
0 Kudos

se ur heading says dat u want to read data from EXCEL to internal table

For dat the FM used is GUI_DOWNLOAD

but ur code is using GUI_UPLOAD..

I don knw wats ur reqmt but i think u shud recheck ur reqmt..