Reading data from a file on application server
Reading data from a file on application server
Code
REPORT ZAJAY_FILE_APLSER_READ.
TABLES:zajay_zstu.
TYPES: BEGIN OF ty_zstu,
zst_id TYPE string,
zst_name TYPE zajay_zstu-zst_name,
zst_dept TYPE zajay_zstu-zst_dept,
zst_fee TYPE string,
END OF ty_zstu.
DATA: it_zstu TYPE TABLE OF ty_zstu,
wa_zstu TYPE ty_zstu.
DATA: lf_student(25) TYPE c VALUE '/tmp/student.txt'.
data: ls_final TYPE string.
OPEN DATASET lf_student for INPUT in TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
DO.
READ DATASET lf_student INTO ls_final.
IF sy-subrc = 0.
SPLIT ls_final at space
INTO wa_zstu-zst_id wa_zstu-zst_name wa_zstu-zst_dept wa_zstu-zst_fee.
APPEND wa_zstu to it_zstu.
clear: wa_zstu.
else.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET lf_student.
ENDIF.
cl_demo_output=>display( it_zstu ).
* Execute the above code
Output
Comments
Post a Comment