2023 Jan 10 2:38 AM
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.
2023 Jan 10 2:53 AM
Hello Siva, how are you ?
You are changing workareas instead internal table to insert into your Z Table.
To resolve your problem, change the sentense:
insert zts_len_data FROM wa_tab.
To the sentense:
MODIFY zts_len_data FROM TABLE it_tab
I think, it gonna help you.
Thanks,
Higor Granero
2023 Jan 10 8:08 AM
Hi Lopes,
Good, how about yourself?
Thanks for the solution. It is working😊. But i need to split the records otherwise data is going incorrectly like in one filed, 2 or 3 details are storing.
2023 Jan 10 6:45 AM
Hi,
the problem is that your statement
insert zts_len_data FROM wa_tab.
just inserts the single entry which is stored in the mentioned work area. But as you are working with several entries to be inserted, you could replace it with
INSERT zts_len_data FROM TABLE it_tab.
Here you can get more information:
Furthermore, do not forget to commit your changes using COMMIT WORK.
I hope this helps you.
Kind regard
Jens
2023 Jan 10 8:12 AM
Hi Zahringer,
How are you?
Thanks for the solution. It is working.
2023 Jan 11 7:33 AM
Hi Siva,
perfect 🙂 Could you please mark this question as answered?
Kind regards
Jens
2023 Jan 10 7:51 AM
Please edit your question, select your code and press the button [CODE], which makes the code appear colored/indented, it will be easier for people to look at it. Thank you!