100% found this document useful (1 vote)
614 views

Implement Enhancement SQUE0001-2

This document provides instructions for implementing a user exit (EXIT_RSAQEXCE_001) in SAP to download query results from transaction SQ01 as a tab-delimited file to a specified shared directory. The key steps are: 1. Create a project using transaction CMOD and include enhancement SQUE0001. 2. Implement the user exit EXIT_RSAQEXCE_001 in the component section. 3. Run transaction SQ01 in background or foreground mode, select "Private file" as the output type, and the results will be downloaded as a tab-separated text file to the specified shared directory.

Uploaded by

Daniel Lai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
614 views

Implement Enhancement SQUE0001-2

This document provides instructions for implementing a user exit (EXIT_RSAQEXCE_001) in SAP to download query results from transaction SQ01 as a tab-delimited file to a specified shared directory. The key steps are: 1. Create a project using transaction CMOD and include enhancement SQUE0001. 2. Implement the user exit EXIT_RSAQEXCE_001 in the component section. 3. Run transaction SQ01 in background or foreground mode, select "Private file" as the output type, and the results will be downloaded as a tab-separated text file to the specified shared directory.

Uploaded by

Daniel Lai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 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