SAP Query - automatic file output
I need to do the following: There is an existing SAP Query on a system and I want to add the possibility to output a file of the results.
This way when the query is run in background (is that possible?) it also automatically writes a file on the server.
Any ideas?
There is a radio button option on queries to allow for saving a file (its called Private File).
Try looking at the options in the Output format section of the query.
You won't get the normal output, only the file.
You can use the enhencement SQUE0001
in the include ZXQUEU01 you can add the following code.
In the query you enter the path and filename in the description field (listtext)
Then you run the query with the option 'private file'
I am not an ABAP specialist, my code is probably not perfect.
Is there someone who can make it better (universal)?
Stéphane
DATA: filename(50) type C.
DATA: QOT(1) VALUE ';'.
DATA: LINE(255) type C,
FLD0(255) type C,
FLD1(20) type C.
FIELD-SYMBOLS <F>.
FILENAME = listtext.
OPEN DATASET FILENAME FOR OUTPUT IN TEXT MODE.
IF SY-SUBRC = 0.
LOOP AT DATATAB.
clear fld0.
DO.
clear fld1.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE DATATAB TO <F>.
IF SY-SUBRC <> 0. EXIT. ENDIF.
move <F> to fld1.
IF SY-INDEX = 1.
MOVE fld1 to fld0.
ELSE.
CONCATENATE fld0 qot fld1 into fld0.
ENDIF.
IF SY-SUBRC <> 0. EXIT. ENDIF.
ENDDO.
TRANSFER fld0 TO FILENAME.
ENDLOOP.
CLOSE DATASET FILENAME.
ENDIF.
hi, you do not need to use user exit.
1. make internal table in your infoset code-section which have same fields than your orginal list
2. append your internal table in record-prosessing-section
3. make download code into your infoset end-of-selection-section
open dataset and so on...
Very easy..
QB