How to log/track filters used within a Bex query.
The requirement is to log/track/record all information related to the use of a specific Bex query ; the reason is that the query points to very sensitive data.
The access to the data is of course protected by specific rights but the customer wants to be able to determine who access the data, when and also what filters were used. This last information (filters) is not available from standard BW statistics content. Another approach could be to activate logs for that query but it appeared too much complex.
SAP BW 7.3, Bex Query Designer
Install a query tracker through the use of a BEX Customer exit. The customer exit records the data to a ‘Z’ table each time the query is launched.
STEP BY STEP
a) Create 2 variables on each filter to be tracked
The first variable is the user selection (common multiple selection in our case) ; the second one is the tracker.
The settings of the second variable are:
b) Create a Z-table
That could also be a DSO, but I went for a simple table.
c) Write the customer exit
The following code takes place in the RSR00001 enhancement, Function module EXIT_SAPLRRS0_001.
The i_step 2 is reached AFTER the filter selection by the user, so it is possible to use the selection recorded by the first variable (ZV_**********_MULT_SEL).
The second variable (‘V_**********_TRACKER) is just used for reaching the i_step 2
DATA: l_s_var_range TYPE rrrangeexit.
DATA: user TYPE xubname.
DATA: timestamp TYPE rsconttimestmp.
DATA: wa TYPE zbw_msisdn_logs.
” Do nothing
user = sy–uname.
CALL FUNCTION ‘SRM_VE_CONVERT_DATETIME_TO_TS’
IV_DATE = sy–datum
IV_TIME = sy–uzeit
IV_TIME_ZONE = ‘CET’
EV_TIMESTAMP = timestamp
* EV_TIMESTAMPL = timestamp
* CONVERT_ERROR = 1
* OTHERS = 2
LOOP AT i_t_var_range INTO l_s_var_range WHERE vnam = ‘ZV_**********_MULT_SEL’.
wa–timestamp = timestamp.
wa–bname = user.
wa–msisdn = l_s_var_range–low.
wa–counter = 1.
INSERT zbw_**********_logs FROM wa.
The Z-table contains all selections made against this query.