My requirement is to create Customer exit variable to calculate the Month to date (MTD) value (Quantity) in a query. I created a Customer exit variable for MTD (0CALDAY) in Query & wrote code in CMOD for the same as follows.
DATA: ZYEAR(4) TYPE N,
ZMON(2) TYPE N,
ZDAY(2) TYPE N.
IF I_STEP = 2.
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE.
ZYEAR = LOC_VAR_RANGE-LOW+0(4).
ZMON = LOC_VAR_RANGE-LOW+4(2).
ZDAY = LOC_VAR_RANGE-LOW+6(2).
CONCATENATE ZYEAR ZMON '01' INTO L_S_RANGE-LOW.
CONCATENATE ZYEAR ZMON ZDAY INTO L_S_RANGE-HIGH.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'BT'.
APPEND L_S_RANGE TO E_T_RANGE.
I debugged this code by putting a break point & running the query in RSRT, the code is getting executed & i am getting the From & To dates in E_T_RANGE output.
But when I execute the Query, I am getting the output Quantity for FTD only, not MTD.
For example, if i give 05-12-2009 as variable input for 0CALDAY when i execute the query, i should get the summed up quantity for 01 Dec to 05 Dec in a single cell. But now, i am getting the summed up quantity for 05 Dec only.
Help me in resolving this.
Thanks for your reply. When i debugged the code, it is working fine. I mean, I am getting the From & To values in the E_T_RANGE finally. But the problem is the Variable created for this MTD in the Query is not calculating the Quantity value based on this dates, it is giving the output based on FTD only.
If you could share any standard Exit to calculate MTD, it would be of much help.
It seems like you are reading some input value of existing variable from selection screen then based on the input you are calculating your MTD range.
Now the variable i.e. time characteristic you are using on selection screen should not be restricted at global filter level, other wise your other variable in the query will not work.
So keep the selection screen variable in some RKF and then use the new RKF for further restriction.