Application Development 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: 

populate internal table to download

Former Member
0 Kudos

Hi All,

i need to download a text file to local drive.

first i create a new internal table with type all character.

then copy the data from 1 internal table of same number of field to this new internal table.

i make it all character as i want to assign and store the field name at the internal table first row.

then download to local.

may i know if i have better approach to do the above?

thanks

2 REPLIES 2

Former Member
0 Kudos

Hi,

From your requirement and as per my understanding you are trying to populate an internal table, transfer the contents of the 1st internal table to another internal table and then download the contents of the table to a local text file in the Presentation Server. If this is correct then, for the download of the file you can use the following class.

CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD. You can use this method to download the contents of the internal table to the local directory structure of the PC. You can have a look at the other methods which will help you with locating the files on the server.

For the previous part, how will you convert the numbers and characters? Are you using your own logic or some predefined methods? If you can share your logic or sample code then it would be really good.

Hope this will help.

Thanks,

Samantak.

JerryWang
Advisor
Advisor
0 Kudos

Hello friend,

you can use following code to download internal table to local files.

DATA:

lv_rc TYPE i,

lt_path TYPE TABLE OF file_table,

ls_path TYPE file_table,

lv_down_path TYPE string,

lv_full_path TYPE string,

lv_file_nm TYPE string,

lt_data_in TYPE TABLE OF string,

lv_data_in TYPE string,

lt_data_out TYPE TABLE OF string,

lv_data_out TYPE string,

lv_exsit TYPE abap_bool,

lv_apr_bo_name TYPE mdrs_apr_bo_name_wb,

lv_apr_node_nm TYPE mdrs_apr_bo_node_name,

lv_apr_qry_name TYPE mdrs_apr_bo_qry_name,

lv_core_bo_name TYPE sesf_business_object,

lv_core_node_nm TYPE sesf_business_object_node,

lv_ext_id TYPE string.

**********************************************************************

  • added by Simon Liang

DATA:

lv_cus_name TYPE string.

**********************************************************************

CALL METHOD cl_gui_frontend_services=>file_open_dialog

EXPORTING

window_title = 'Select file'

CHANGING

file_table = lt_path

rc = lv_rc.

READ TABLE lt_path INTO ls_path INDEX 1.

lv_file_nm = ls_path-filename.

CALL METHOD cl_gui_frontend_services=>gui_upload

EXPORTING

filename = lv_file_nm

filetype = 'ASC'

  • has_field_separator = SPACE

  • header_length = 0

read_by_line = 'X'

CHANGING

data_tab = lt_data_in.

LOOP AT lt_data_in INTO lv_data_in.

SPLIT lv_data_in AT ','

INTO lv_ext_id

lv_cus_name " added by Simon Liang

lv_core_bo_name

lv_core_node_nm

lv_apr_bo_name

lv_apr_node_nm

lv_apr_qry_name.

TRANSLATE lv_ext_id TO UPPER CASE.

TRANSLATE lv_cus_name TO UPPER CASE.

TRANSLATE lv_core_bo_name TO UPPER CASE.

TRANSLATE lv_core_node_nm TO UPPER CASE.

TRANSLATE lv_apr_bo_name TO UPPER CASE.

TRANSLATE lv_apr_node_nm TO UPPER CASE.

TRANSLATE lv_apr_qry_name TO UPPER CASE.

CALL FUNCTION 'ZRFB_CHECK'

EXPORTING

im_apr_bo_name = lv_apr_bo_name

im_apr_node_nm = lv_apr_node_nm

im_apr_qry_name = lv_apr_qry_name

im_core_bo_name = lv_core_bo_name

im_core_node_nm = lv_core_node_nm

IMPORTING

ex_exist = lv_exsit.

" modified by Simon Liang

IF lv_exsit = 'X'. " RFB exists

CONCATENATE lv_data_in 'Yes' INTO lv_data_out SEPARATED BY ','.

ELSE.

CONCATENATE lv_data_in 'No' INTO lv_data_out SEPARATED BY ','.

ENDIF.

APPEND lv_data_out TO lt_data_out.

ENDLOOP.

CALL METHOD cl_gui_frontend_services=>file_save_dialog

EXPORTING

window_title = 'Save the file'

default_extension = 'TXT'

default_file_name = 'RFBCHK'

initial_directory = 'c:\'

CHANGING

filename = lv_file_nm

path = lv_down_path

fullpath = lv_full_path.

CALL METHOD cl_gui_frontend_services=>gui_download

EXPORTING

filename = lv_full_path

filetype = 'ASC'

write_field_separator = 'X'

CHANGING

data_tab = lt_data_out.

Edited by: Jerry Wang on Jul 5, 2010 8:47 AM