Hello Everyone,
I am new to ABAP. I am trying to upload excel file into an internal table. However the internal table is always empty. I have looked around and could not find a solution. It may even be the excel file. Please can anyone have a look at my code and see if there is any errors.
Thanks you guys.
report zupex_tow.
types: begin of ty_zemas,
employee_no like zemas_tow-employee_no,
forename like zemas_tow-forename,
middle_name like zemas_tow-middle_name,
surname like zemas_tow-surname,
dob like zemas_tow-dob,
sex like zemas_tow-sex,
ni_no like zemas_tow-ni_no,
doj like zemas_tow-doj,
department like zemas_tow-department,
sub_department like zemas_tow-sub_department,
sick_leave like zemas_tow-sick_leave,
paid_leave like zemas_tow-paid_leave,
paternity_leave like zemas_tow-paternity_leave,
maternity_leave like zemas_tow-maternity_leave,
end of ty_zemas.
type-pools: truxs.
data: it_zemas type standard table of ty_zemas with header line,
wa_zemas type ty_zemas,
it_tab_raw_data type truxs_t_text_data.
parameter : p_file type rlgrap-filename default 'C:\Users\Islam\Desktop\Excel_file'.
AT SELECTION-SCREEN on VALUE-REQUEST FOR p_file.
call function 'F4_FILENAME'
EXPORTING
* PROGRAM_NAME = SYST-CPROG
* DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'p_file'
IMPORTING
FILE_NAME = p_file.
.
start-of-selection.
call function 'TEXT_CONVERT_XLS_TO_SAP'
exporting
* I_FIELD_SEPERATOR = '#'
* I_LINE_HEADER = 'X'
i_tab_raw_data = it_tab_raw_data
i_filename = p_file
tables
i_tab_converted_data = it_zemas[]
exceptions
conversion_failed = 1
others = 2.
if sy-subrc <> 0.
message: 'No data found' type 'E'.
else.
message: 'Upload Successful' type 'I'.
endif.
Thanks again.