‎2005 Nov 21 5:40 AM
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..
‎2005 Nov 21 9:09 AM
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.
‎2005 Nov 21 9:09 AM
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.
‎2005 Nov 21 9:25 AM
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
‎2005 Nov 21 9:35 AM
Nice code Susmitha..i tried that, its great.
I was able to upload a Block alv list to my appl server in exact format.
‎2005 Nov 25 3:20 AM
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.
‎2005 Nov 21 9:26 AM
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