Anda di halaman 1dari 3

How to Create a “Customer Exit” Date Variable.

Custom date variables greatly enhance BEx Reporting.

Let’s assume you have an InfoProvider with a characteristic 0CALDAY (Calendar


Day) and you want to restrict results of your query to “current month to date”.

Scenario:

1. Start by creating a variable for the 0CALDAY InfoObject.

2. Assign “Processing by” type “Customer Exit”, “Variable Represents” to


“Interval” and “Variable Entry” to “Mandatory”.
Select “Ready for Input” checkbox if you want a request window for your
variable to be presented at runtime (interval values will be filled from your
Customer-Exit but a user can still change them).

3. Go to transaction CMOD to create a project for your enhancement (see

ref.2).
Give a name to the project (1), create (2) and
save the project. Then assign an
enhancement RSR00001 to your project and
save. (In this step an error message “SAP enhancement RSR00001
already belongs to project NAME” may appear. That means an active
project with the enhancement RSR00001 already exists. If this is the case,
you do not need to create your own project and may terminate this step
and go to the step 4). Activate the project.

4. Go to a transaction SE80, display a Function Group XRSR (1,2), open


Function Modules (3) and double click on an EXIT_SAPLRRS0_001 (4).
A source code for the EXIT_SAPLRRS0_001 function module opens.
Double click on a word ZXRSRU01. You arrive to a source code for the
Include ZXRSRU01.
5. In the source code for Include ZXRSRU01 insert your code (see sample
code below).
If some code like
DATA: L_S_RANGE TYPE RSR_S_RANGESID.
………
………
ENDCASE.
Already exists in the Include just insert the part of the sample code from
the first comment to the last at the end of the existing code but above the
ENDCASE statement. Check and Activate.

Code Example:

DATA: L_S_RANGE TYPE RSR_S_RANGESID.

* Current month to date variable ZCMTD example.

WHEN 'ZCMTD'.
* you variable name
data: ZCMTD_LOW like sy-datum.
*defining variable for using as a starting date of the interval
ZCMTD_LOW = sy-datum.
*initializing it with the current date
ZCMTD_LOW+6(2) = '01'.
*replacing last two symbols (day) in the current date with '01'(see ref.1)

CLEAR L_S_RANGE.
L_S_RANGE-LOW = ZCMTD_LOW.
*initializing low interval limit
L_S_RANGE-HIGH = SY-DATUM.
*initializing high interval limit
L_S_RANGE-SIGN = 'I'.
*defining interval as inclusive
L_S_RANGE-OPT = 'BT'.
APPEND L_S_RANGE TO E_T_RANGE.

* Current month to date variable ZCMTD example end.

ENDCASE.

The result of this will be an interval from the first day of the current month till
the current system date.

Acknowledgements and more info:


Thanks go to Dirk Herzog and Roberto Negro for their valuable posts on
forum regarding Customer-Exit variables.
References:
ref.1 Processing Sections of Strings
ref.2 Customer Exits
ref.3 Date for Several Months topic on BW Forum

Anda mungkin juga menyukai