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: 

How to download data from SAP report to text file?

Former Member
0 Kudos

Hi,

I am new to ABAP programming and still learning it on the job.

My SAP system has an existing report, which can be accessed via a transaction key. Before I get the report, I need to fill in some variant and execute it so I can get the correct data. Now I need to download the data presented in this report to a text file in my local pc.

Is it possible to do this? I really have no idea how to go about it. I only know how to write ABAP program to download data from SAP tables to text file.

Can someone point me to a link which has explanation or examples on how to do this?

Thanks a lot!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Click on 'SYSTEM' on menu bar, select 'List', 'Save' and 'Local File' options. Give file path and type of file (in your case .TXT) in the pop up and click on 'Generate' button. This will download your report to a text file on your local PC.

Cheers,

Satyanarayana.

6 REPLIES 6

Former Member
0 Kudos

Hi,

Click on 'SYSTEM' on menu bar, select 'List', 'Save' and 'Local File' options. Give file path and type of file (in your case .TXT) in the pop up and click on 'Generate' button. This will download your report to a text file on your local PC.

Cheers,

Satyanarayana.

0 Kudos

Hi Satyanarayana,

Thanks for the input.

Sorry I forgot to state that I need to automate this process since I need to download the data everyday for further processing.

Is there anyway we can automate this?

Thanks

Regards,

Cecilia

0 Kudos

Hi Cecilia,

This is an indirect solution. Check whether it meets your requirement.

You need to write a program which will be scheduled to run in background. This program should execute the report with required variant, pass the output to spool. Then the output may be captured from the spool file and sent to the user as an email attachment which may be downloaded to the local PC.

Thanks,

Satyanarayana.

0 Kudos

write another report which will submit your report and export the data to the memory like below stmt

submit z21336r_cimpro_po_log exporting list to memory and return with s_date in r_date

with s_batch in r_batch

with p_callpo eq c_x.

then get that data into internal table and download that data into a internal table as below

call function 'LIST_FROM_MEMORY'

tables

listobject = i_abaplist

exceptions

not_found = 1

others = 2.

if sy-subrc <> 0.

g_message = 'Error in importing list from memory'(010).

g_msgtyp = c_e.

perform f_populate_message using g_msgtyp

g_message.

endif.

Then download to PC using GUI_download or ws_download FM

If you want execute it daily automatically then you should run this program in backgroud but you cann't download it to Pc you should download it to application using OPEN DATASET.

Let me know if you have issues more.

Cheers,

Satya

Former Member
0 Kudos

Cecilia,

You can also achieve this by minor code modification & adding one more parameter in your selection screen.

Use function module GUI_DOWNLOAD to download the internal table (Displaying in the output list) into your workstation.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = input_filename

filetype = 'ASC'

TABLES

data_tab = i_your_output_data

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

OTHERS = 5.

Option # 2 )

If you want to schedule this program in background job, you need to write the data in application sever file(at the end of your current program logic).

OPEN DATASET l_out_file FOR OUTPUT IN TEXT MODE MESSAGE l_msg.

LOOP AT i_your_output_data

TRANSFER i_your_output_dataTO l_out_file.

ENDLOOP.

CLOSE DATASET l_out_file

Cheers

Raghava.

Message was edited by: Raghava M

Former Member
0 Kudos

Hi,

You can download the output internal table to the txt file. Please see the below link for examples:

http://www.sapdevelopment.co.uk/file/file_updown.htm

Best Regards,

Anjali