Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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

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

Former Member
Not what you were looking for? View more on this topic or Ask a question