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

Save a CSV file in a specified path

5,331

Hi Guys,

I want to save a CSV file in a specified path. The path should be selectable in the selection screen.

I created my file with the function module SAP_CONVERT_TO_CSV_FORMAT. So I just need the option to save them.

Would be nice if someone can help me

thx

1 ACCEPTED SOLUTION
Read only

roberto_forti
Contributor
0 Likes
4,660

Hi Dear, try coding and running the following sample code.

Best Regards!

Roberto FORTI Santos

call function 'SAP_CONVERT_TO_CSV_FORMAT'
exporting
i_field_seperator          = ';'
tables
i_tab_sap_data             = internal_table
changing
i_tab_converted_data       = csv_table[]
exceptions
conversion_failed          = 1
others                     = 2.

if ( sy-subrc eq 0 ).

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename                        = 'C:\data.csv'
tables
data_tab                        = csv_table[].

endif.
7 REPLIES 7
Read only

VXLozano
Active Contributor
0 Likes
4,660

Two ways:

  • CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD in frontend
  • OPEN DATASET in background

But I guess there are a lot of resources in the site where you could get that information, if you just wanted to search for them

Read only

VXLozano
Active Contributor
4,660

and as the OP has deleted himself, I'll ask the moderation team to delete this thread entirely... what a waste of time

edited: the OP has returned from oblivion, it seems... maybe a SAP glitch in the time-space continuum

Read only

0 Likes
4,660

thank you.

Read only

VXLozano
Active Contributor
4,660

my pleasure... now it's your turn to:

- learn from this post (the entire Q&A process)

- decide if the answers provided are enough (I don't care which, I'm not hunting for rep, I'm a lucky guy)
- mark que question as answered (if it is)

and, please, the next time you have a question to ask, do yourself a favor and dig deeper: search for tutorials (I guess you are learning), look at the ABAP examples (they are not as bad as they seem) and tell us in your question what did you tried before asking the question. Do NOT post a plain requirement. Prove me that my time writing all this has been an investment and not a waste of time.

Read only

former_member598787
Participant
0 Likes
4,660

Hello Mario,

Please try the following solution

1. Use method cl_gui_frontend_services=>file_open_dialog to get dialog box to open and choose the filepath to download and save the file

2. Use GUI_DOWNLOAD function module to download and save the file in the path chosen from step 1.

Do update if the solution works for you.

Regards,

Juby

Read only

0 Likes
4,660

thank you

Read only

roberto_forti
Contributor
0 Likes
4,661

Hi Dear, try coding and running the following sample code.

Best Regards!

Roberto FORTI Santos

call function 'SAP_CONVERT_TO_CSV_FORMAT'
exporting
i_field_seperator          = ';'
tables
i_tab_sap_data             = internal_table
changing
i_tab_converted_data       = csv_table[]
exceptions
conversion_failed          = 1
others                     = 2.

if ( sy-subrc eq 0 ).

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename                        = 'C:\data.csv'
tables
data_tab                        = csv_table[].

endif.