Skip to Content
-1
Jan 10, 2023 at 02:38 AM

How to send data from excel file in al11 to my custom table(ztable) using read dataset.

207 Views

Hello Experts,

I Have created a program to get the data from application server using open, read & close dataset into internal tables but im not able to update my custom table with those records taken from excel file in application server.

TABLES : zts_len_data.

DATA : p_file_n TYPE localfile.

TYPES : BEGIN OF zts_len_data,
emp_id TYPE zts_len_data-empl_id,
name TYPE zts_len_data-name,
short_id TYPE zts_len_data-usr_id,
Date_of_Swipe TYPE zts_len_data-date_of_swipe,
First_in_time type zts_len_data-first_in_time,
last_out_time TYPE zts_len_data-last_out_time,
END OF zts_len_data.

DATA: it_tab TYPE TABLE OF zts_len_data,
wa_tab TYPE zts_len_data.

p_file_n = '/tmp/sk.csv'.

OPEN DATASET p_file_n FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
DO.
READ DATASET p_file_n INTO wa_tab.
IF sy-subrc EQ 0.
APPEND wa_tab TO it_tab.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET p_file_n.

insert zts_len_data FROM wa_tab.


IF it_tab IS NOT INITIAL.
LOOP AT it_tab INTO wa_tab.
WRITE: / wa_tab-empl_id, wa_tab-name, wa_tab-usr_id, wa_tab-date_of_swipe, wa_tab-first_in_time, wa_tab-last_out_time.
ENDLOOP.
ENDIF.

File records are coming in output but not able to insert in ztable. please help any one.