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.
    TYPESBEGIN 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.
    DATAit_zstu TYPE TABLE OF ty_zstu,
          wa_zstu TYPE ty_zstu.
    DATAlf_student(25TYPE VALUE '/tmp/student.txt'.
    data:     lstr_final     TYPE string.
    DATAlv_fee(10TYPE 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

Popular posts from this blog

Pf status and user command in factory method - OOPS ALV in ABAP

fetch the data from table and send an email in ABAP

Enhancements in abap