Hi,
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.
CASE I_VNAM.
WHEN 'ZVCE_MTD'.
IF I_STEP = 2.
REFRESH E_T_RANGE.
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).
CLEAR L_S_RANGE.
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.
EXIT.
ENDLOOP.
ENDIF.
ENDCASE.
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.
Regards,
Murali
why this:
REFRESH E_T_RANGE. LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE. .... ENDLOOP.
?
definitely remove the refresh statement as that will clear your variable table compeltely
next remove the loop exit endloop statements
code should work fine then
Hi Raf,
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.
Regards,
Murali
then the problem is in the query... not the user exit ![]()
APPEND L_S_RANGE TO E_T_RANGE.
ENDLOOP.
Remove exit from here and check.
Hi Damawat,
When i remove EXIT from the Customer exit code and run the query, i am getting an error "Error for Variable in Customer exit".
Regards,
Murali
Hi Murali,
In this case why can't you try with hard filter instead of giving variable !!! Instead of giving any variable try to give some value directly in restriction and execute the query then if you are getting data properly go for variable...
-
Thanks
BVR
Hi,
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.
Regards,
Durgesh.
Thanks much Durgesh, your idea solved the issue. I removed the ZFDATE restriction from Filters (Characteristic restrictions) and it worked well, i am getting data for MTD now.
Regards,
Murali