Hello Ajinkya,
Create a internal table in ABAP report with same fields as in Excel file.
Below is the code worked for me.
*******************************************************************************************************
type-pools: truxs, trwbo.
data: begin of gt_record occurs 0,
reswk(004), "Supplying plant
werks(004), "Plant
bsart(004), "Type
end of gt_record.
data: gt_raw type truxs_t_text_data,
gv_file1 type rlgrap-filename.
data: gv_file type string.
parameters: p_file(128) type c.
*----------------------------------------------------------------------*
* at selection screen on value-request for *
*----------------------------------------------------------------------*
at selection-screen on value-request for p_file.
call function 'F4_FILENAME'
exporting
program_name = syst-cprog
dynpro_number = syst-dynnr
importing
file_name = p_file.
*-----------------------------------------------------------------------
* START OF SELECTION
*-----------------------------------------------------------------------
start-of-selection.
gv_file = p_file.
clear gt_record.
gv_file1 = gv_file.
***FM to get data from Excel***
call function 'TEXT_CONVERT_XLS_TO_SAP'
exporting
i_tab_raw_data = gt_raw
i_filename = gv_file1
tables
i_tab_converted_data = gt_record[]
exceptions
conversion_failed = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
delete gt_record index 1.
endif.
******************************************************************************************************
Now gt_record[] will have data from excel.
And excel file should look like this--
reswk(004) | werks(004) | bsart(004) |
N114 | N202 | N1UB |
N114 | N203 | N1UB |
N114 | N204 | N1UB |
N114 | N205 | N1UB |
N114 | N206 | N1UB |
N114 | N207 | N1UB |
N114 | N208 | N1UB |
N114 | N209 | N1UB |