on ‎2013 Nov 12 10:03 AM
Hi Experts,
I am trying to get the Data of previous month based on the user input. For example user enters the date as (01.05.2013 - 31.05.2013) then i need to get the previous month data i.e data of April .
Below is my code
DATA :ZRK1 TYPE SY-DATUM,
ZRK2 TYPE SY-DATUM,
ZT_DT1 TYPE SY-DATUM,
ZT_DT2 TYPE SY-DATUM,
ZFIDAY TYPE SY-DATUM,
ZLSDAY TYPE SY-DATUM.
IF I_STEP = 2.
CASE i_vnam.
WHEN 'ZCDAY'.
LOOP AT i_t_var_range INTO L_S_VAR_RANGE WHERE vnam = 'ZVAR_ADA_PERD2'.
CLEAR: l_s_range.
ZT_DT1 = loc_var_range-low.
ZT_DT2 = loc_var_range-HIGH.
CALL FUNCTION 'DATE_CREATE'
EXPORTING
ANZAHL_JAHRE = 0
ANZAHL_KALTAGE = 0
ANZAHL_MONATE = '-1'
ANZAHL_TAGE = 0
DATUM_EIN = ZT_DT1
* DATUM_EIN_ULT = ' '
* ULTIMO_SETZEN = ' '
IMPORTING
DATUM_AUS = ZFIDAY .
* E_TT =
* E_ULTKZ =
CALL FUNCTION 'DATE_CREATE'
EXPORTING
ANZAHL_JAHRE = 0
ANZAHL_KALTAGE = 0
ANZAHL_MONATE = '-1'
ANZAHL_TAGE = 0
DATUM_EIN = ZT_DT2
* DATUM_EIN_ULT = ' '
* ULTIMO_SETZEN = ' '
IMPORTING
DATUM_AUS = ZLSDAY.
* E_TT =
* E_ULTKZ =
l_s_range-low = ZFIDAY .
l_s_range-high = ZLSDAY .
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ENDLOOP.
ENDCASE.
ENDIF.
Note: ZCDAY is my customer exit variable on 0CALDAY.
Points will be rewarded for help.
Regards,
Manjunath
Request clarification before answering.
Hi Manjunath,
No code is required to get previous month.
1) Drag Calmonth and restrict to your KF
2) Create a variable for Calmonth -->Replacement path-->reference char as calmonth-->Details tab-->Replace with Variable( your date range variable)-->external key value-->Use interval as From-->offset start as 1 and offset length as 6. This way you are taking 201305 from 01.05.2013.
3) Finally put offset -1. this will give you 04.2013
Regards,
Suman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your query design is wrong , it seems. We restrict our KFs with Time char variables to show data as per that time char.
User enters : 01.08.2013 - 31.08.2013. This variable will be in default values pane in query.
Suppose you to want to show Sales KF. You have to restrict your Sales KF with Calmonth variable(which replaces Issue date variable, as I said).
If you want to use calmonth as Drill down, then you have to achieve calmonth in the modeling side in Cube level but not at Bex level. I assumed so far you are trying to view some KF with last month selection automaticallly. Please discuss with your Team lead.
My Query Design is as follows:(Jus for an example)
Scenario:
Displaying no of cars and no of days based on the issue date according to different plants
Selection Screen : Sold Date / Issue date(01.05.2013 - 31.05.2013)
In Filter:
I don have any characterstic restriction
In default values i have - Sold Date/Issue date(CHAR-DATS)
-Plant Code
Rows/Col:
- No of Cars Sold(KF-DEC)
- No of Days (Restricted key figure based on Issue date - counter of unique dates)
- Previousmonth No of Cars
- Previousmonth No of Days
Can u please tell me where did i go wrong?
I would rly appreciate ur help.
Hi Manjunath,
Take any kf and restrict it with variable-- created on Sold Date / Issue date(01.05.2013 - 31.05.2013).Hide this Selection this will act as dummy selection for user input only
Remove it from default pane as well.Because it is acting as global filter and not local filter.
And as you are trying to get the data for previous month but with that date restriction it is not giving any value.
Please give a try and let us know the result.
Regards,
AL
Ok. I have got your requirement.
Step 1 : Drag Issue date into Default values and create a User entry variable with Interval
Step 2 : For Plant also create a variable(mulitple single values) in Default values pane
Step 3 : Drag No. of Cars Sold KF into KF pane. Hope it is a direct KF from your Cube
Step 4 : Drag No. of Days RKF
Step 5 : You have to copy above two KFs by right click on them and change the edit the descriptions for Prev Month
Step 6 : Restrict theme with Calmonth field-->Restrict with variable(replacement of Issue date variable which I told you initially) and put offset -1
I think i have explained you very clearly. You should take help of your colleagues if you don't understand my steps..
Value 012080 of characteristic 0CALMONTH is not plausible
I am getting above error after changing it to key .
Replace with as key
Interval as from value
Offset start as 1
offset length as 6
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.