You are on page 1of 4

Implement enhancment SQUE0001, user-exit EXIT_RSAQEXCE_001.

Written by Ram Manohar Tiwari

font size

Print

Email

Rate this item

(0 votes)
The processing to implement the user-exit is as below:

First create a Project through transaction CMOD say ZSQFILE .

Then use enhancement assignment to include SQUE0001 SAP


Query: Private data file

Further implement the user-exit EXIT_RSAQEXCE_001 in the


component section .

Click on Include ZXQUEU01 to create it and then implement the


given code. Please change the 'SharedFileDirectoryName' to
replace with your shared directory ( Directory that you should be
able to see / configure through transaction AL11 )

Activate the user- exit.

Now Run SQ01 ( Background or foreground ) and select 'Private


file' ( and not File Store ) on the selction screen. Further it will
download the results in a file on folder as specifird in the code as .
Please understand that a parameter can't be provided for file
name, it will be downloaded as the description name of the query
<.txt >. As it is, it will create a tab separated file.

*&---------------------------------------------------------------------*
*& Include
ZXQUEU01
*

*&---------------------------------------------------------------------*
* Implemented by: Ram Manohar Tiwari
* Presented by : www.rmtiwari.com
* Function
: Enhancement SQUE0001 : SAP Query - Private Data File
*
User-Exit FM : EXIT_RSAQEXCE_001
*
to download the SQ01 Query Results on application
*
server as tab separated data file.
*----------------------------------------------------------------------*
class cl_abap_char_utilities definition load.
DATA : lv_file_name LIKE rlgrap-filename.
DATA : empty(1),
fcnt TYPE i,
fpos TYPE i,
cfpos TYPE i,
feld(1000).
DATA: BEGIN OF ldata OCCURS 100.
INCLUDE STRUCTURE rsaqldata.
DATA: END OF ldata,
maxpos TYPE i.

FIELD-SYMBOLS: <feld>,
<cfeld>.
DATA: l_pos TYPE i.
data: l_length type i,
l_number(3) type n,
l_pos_f
type i.
constants: bufferlength type i value 1024.
constants: lc_tab type X value '09'.
REFRESH ldata.
LOOP AT datatab.
CLEAR ldata.
maxpos = 0.
fcnt = 0.
LOOP AT listdesc WHERE lid = list_id.
fcnt = fcnt + 1.
IF fcnt <> 1.
l_pos = maxpos + 1.
IF l_pos > bufferlength.

APPEND ldata.
CLEAR ldata.
maxpos = 0.
ENDIF.
ENDIF.
fpos = listdesc-flpos.
ASSIGN COMPONENT fpos OF STRUCTURE datatab TO <feld>.
WRITE <feld> TO feld.
SHIFT feld LEFT DELETING LEADING space.
l_length = strlen( feld ).
l_number = l_length.
l_pos_f = maxpos + l_length + 1.
if l_pos > bufferlength.
append ldata.
clear ldata.
maxpos = 0.
endif.
IF fcnt <> 1.
concatenate ldata CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
feld into ldata.
else.
concatenate ldata
feld into ldata.
ENDIF.
maxpos = maxpos + strlen( l_number ) + 1 + l_length.

ENDLOOP.
APPEND ldata.
CLEAR ldata.
ENDLOOP.
DATA : lv_list_name(15) type C,
lv_length
type i.
lv_length = strlen( listtext ).
if lv_length < 15.
lv_list_name = listtext.
else.
lv_list_name = listtext(15).
endif.
CONCATENATE '\\SharedFileDirectoryName\' lv_list_name '_'

sy-SLSET '.txt' INTO lv_file_name.

OPEN DATASET lv_file_name FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.


LOOP AT ldata.
TRANSFER ldata TO lv_file_name.
ENDLOOP.
CLOSE DATASET lv_file_name.

You might also like