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

FUNCTION MODULE that downloads list report

Former Member
0 Likes
670

Is there a Function Module that downloads list report to a '.txt' file to its server? I would like to run it in background so it would download the list report on the server. thanx in advance guys..

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
628

Hi Ferdino,

You can do it this way :

You call the report whose list you want, in another program, exporting list to memory.

Then get that list and write it to file.

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

DATA : list LIKE TABLE OF abaplist WITH HEADER LINE.

DATA : BEGIN OF list_asc OCCURS 0,

msg(300) TYPE c,

END OF list_asc.

DATA : wa_c_filename(30) TYPE c.

wa_c_filename = '/data/ftp/out/rep.txt'.

SUBMIT pgm_xyz EXPORTING LIST TO MEMORY

AND RETURN.

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

listobject = list

EXCEPTIONS

not_found = 1.

CALL FUNCTION 'LIST_TO_ASCI'

  • EXPORTING

  • LIST_INDEX = -1 "LIST_INDEX SY-LSIND.

TABLES

listasci = list_asc

listobject = list.

OPEN DATASET wa_c_filename FOR OUTPUT in text mode.

IF sy-subrc NE 0.

WRITE : / 'The file could not be created'.

ELSE.

LOOP AT list_asc.

TRANSFER list_asc TO wa_c_filename.

ENDLOOP.

CLOSE DATASET wa_c_filename.

ENDIF.

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

The list contents will be in the file in the server, filename and file path as specified in wa_c_filename.

5 REPLIES 5
Read only

Former Member
0 Likes
629

Hi Ferdino,

You can do it this way :

You call the report whose list you want, in another program, exporting list to memory.

Then get that list and write it to file.

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

DATA : list LIKE TABLE OF abaplist WITH HEADER LINE.

DATA : BEGIN OF list_asc OCCURS 0,

msg(300) TYPE c,

END OF list_asc.

DATA : wa_c_filename(30) TYPE c.

wa_c_filename = '/data/ftp/out/rep.txt'.

SUBMIT pgm_xyz EXPORTING LIST TO MEMORY

AND RETURN.

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

listobject = list

EXCEPTIONS

not_found = 1.

CALL FUNCTION 'LIST_TO_ASCI'

  • EXPORTING

  • LIST_INDEX = -1 "LIST_INDEX SY-LSIND.

TABLES

listasci = list_asc

listobject = list.

OPEN DATASET wa_c_filename FOR OUTPUT in text mode.

IF sy-subrc NE 0.

WRITE : / 'The file could not be created'.

ELSE.

LOOP AT list_asc.

TRANSFER list_asc TO wa_c_filename.

ENDLOOP.

CLOSE DATASET wa_c_filename.

ENDIF.

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

The list contents will be in the file in the server, filename and file path as specified in wa_c_filename.

Read only

0 Likes
628

You can run this new program in background. It will work exactly as the main program, in addition to creating the file having list contents in the server.

Hope this will be of help to you.

Thanks,

Susmitha

Read only

0 Likes
628

Nice code Susmitha..i tried that, its great.

I was able to upload a Block alv list to my appl server in exact format.

Read only

0 Likes
628

A <b>very informative</b> code Susmitha Thomas.!

My problem is that I can't 'SUBMIT' my report program because it also has a download functionality. I already have my spool request, my only problem is how to get it and download it to a text file.

Read only

Former Member
0 Likes
628

Hi,

To schedule the program in background job, write the data in application sever file.

OPEN DATASET l_ofile FOR OUTPUT IN TEXT MODE MESSAGE l_msg.

LOOP AT i_data

TRANSFER i_dataTO l_ofile.

ENDLOOP.

CLOSE DATASET l_ofile

Check these links for more infor on file download.

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

Best Regards,

Anjali