Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Downloading dynamically to application server

Former Member
0 Likes
712

Hi All,

I want to download table data ( Whose name i am giving at run time ) to application server.

Problem is that, for downloading i will need to convert all fields to char type first and then only i can use following code to download.

OPEN DATASET P_DIR FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

  • Write table contents to file

LOOP AT ITAB INTO W_ITAB.

TRANSFER W_ITAB TO P_DIR.

ENDLOOP.

How can i do this ?

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
674

use as

OPEN DATASET P_DIR FOR OUTPUT IN BINARY MODE .

5 REPLIES 5
Read only

former_member191735
Active Contributor
0 Likes
674

You have to change into character type data or try different type of options like Legacy binary mode or legacy text mode

Read only

Former Member
0 Likes
674

transfer the work area to a variable type string and then Transfer the String to dataset.

loop at it into wa.

string = wa .

Transfer wa to dataset.

endloop.

Thanks,

Adi

Read only

Former Member
0 Likes
674

correction "Transfer string to dataset".

Thanks,

Adi

Read only

Former Member
0 Likes
675

use as

OPEN DATASET P_DIR FOR OUTPUT IN BINARY MODE .

Read only

former_member156446
Active Contributor
0 Likes
674

HI Deepika.. the below code can be use used for ur purpose..

DATA: gt_error TYPE STANDARD TABLE OF tt_error,
      wa_error TYPE tt_error.

TYPES: BEGIN OF tt_file,
        data(1000),
END OF tt_file.
DATA: gt_file TYPE STANDARD TABLE OF tt_file,
      wa_file TYPE tt_file.

*Conver to pipe delimited file
  PERFORM fr_format_error_file TABLES gt_error gt_file.

FORM fr_format_error_file  TABLES p_final_table
                                  p_output_file.

  IF NOT gv_error LT 1.

    DATA : lf_buf TYPE string,
           lf_line TYPE string,
    co_line_feed TYPE c VALUE cl_abap_char_utilities=>cr_lf.

    FIELD-SYMBOLS : <fs_record> TYPE ANY,<fs_comp> TYPE ANY.
    LOOP AT p_final_table ASSIGNING <fs_record>.
      DO.
        ASSIGN COMPONENT sy-index OF STRUCTURE <fs_record> TO <fs_comp>.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
        lf_buf = <fs_comp>.
        IF sy-index = 1.
          lf_line = lf_buf.
        ELSE.
          CONCATENATE lf_line lf_buf INTO lf_line SEPARATED BY c_sep.
        ENDIF.
        CLEAR lf_buf.
      ENDDO.
      CONCATENATE lf_line co_line_feed INTO lf_line.
      APPEND lf_line TO p_output_file.
      CLEAR lf_line.
    ENDLOOP.
  ENDIF.
ENDFORM.                    " FR_FORMAT_ERROR_FILE