Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8704

Re: Download or Save CSV file in the App server problem

$
0
0

1) Make your data table comma delimited. You can use the below function module for that. But if your table contains like more than 100000 records, I would not recommend to us it. 

 

 

 

 

 

"Convert the Output Table in to Text Table separated by comma

 

  CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'

    EXPORTING

      i_field_seperator    = ',' "Comma

      i_line_header        = abap_true

    TABLES

      i_tab_sap_data       = gt_data

    CHANGING

      i_tab_converted_data = gt_output

    EXCEPTIONS

      conversion_failed    = 1

      OTHERS               = 2.

  IF sy-subrc <> 0.

    FREE: r_value.

    RETURN.

  ENDIF.

 

 

 

 

2) Download the converted table as below.

 

 

 

  lv_filename should contain the file path with the correct filename ( with .CSV extension )

 

 

 

  "Begin - Download

 

  OPEN DATASET lv_filename

  FOR OUTPUT IN TEXT MODE ENCODING DEFAULT

  MESSAGE lv_msg.

  IF sy-subrc <> 0.

    MESSAGE e004 "Error

    WITH lv_filename lv_msg RAISING exception_occured.

  ENDIF.

 

 

 

  LOOP AT gt_output INTO ls_output.

    TRANSFER ls_outpu TO lv_filename.

  ENDLOOP.

 

 

 

  CLOSE DATASET lv_filename.


Viewing all articles
Browse latest Browse all 8704

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>