Write data to a file on Application server
* AL11 - T-code for SAP Directories.
Write data to a file on Application server.
Code
REPORT zajay_file_aplser_write.
TABLES:zajay_zstu.TYPES: BEGIN OF ty_zstu,
zst_id TYPE zajay_zstu-zst_id,
zst_name TYPE zajay_zstu-zst_name,
zst_dept TYPE zajay_zstu-zst_dept,
zst_fee TYPE zajay_zstu-zst_fee,
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: lstr_final TYPE string.
DATA: lv_fee(10) TYPE c,
lv_id(2) TYPE c.
SELECT-OPTIONS : s_id FOR zajay_zstu-zst_id.
IF s_id IS NOT INITIAL.
SELECT zst_id
zst_name
zst_dept
zst_fee
FROM zajay_zstu
INTO TABLE it_zstu
WHERE zst_id IN s_id.
ENDIF.
OPEN DATASET lf_student FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
LOOP AT it_zstu INTO wa_zstu.
write wa_zstu-zst_id to lv_id.
write wa_zstu-zst_fee to lv_fee.
* lv_id = wa_zstu-zst_id.
* lv_fee = wa_zstu-zst_fee.
CONCATENATE lv_id wa_zstu-zst_name wa_zstu- zst_dept lv_fee INTO lstr_final SEPARATED BY space.
TRANSFER lstr_final TO lf_student.
ENDLOOP.
CLOSE DATASET lf_student.
ENDIF.
Input
Output
* Check in AL11 T-code double click on /tmp.
* Right click on last change click on set filter and give date.
* Right click on last change click sort in ascending order.
* Check the file you give in program - student.txt
* Double clicks on file name.
Comments
Post a Comment