on 06-05-2014 3:07 PM
Hi Experts,
Simple but not simple question . I know how to calculate the fy and fy period value based on user input. but need to know how to calculate for past 6 period's ( 0fiscper3) values based on user input.
I mean, see the user will enter 0fiscyear and 0fiscper3 initially. But the report should show previous 6 period's ( amount) values in different columns'.
I know we can do it through offset based on user input period -1, user input period -2,.......user input period -6. But what if the user input 001. Then how to we create restriction to change the 0fiscyear value to previous year ? Will it automaticaly take the previous period ? I dont think so right.
For example, user input - 0fiscyear = 2010, 0fiscper3=001.
I need 2009.012, 2009.011, 2009.010, 2009.009, 2009.008,2009.007. Do I need a customer exit for this ?
Thank You
DR
AL,
If i uncheck the ready for input tag for "var1". I am getting error, something like invalid input type for var1 something. I have just removed "var1" ready for input and put "var2" to test. The given code is not allowing for the same.
The requirement is to enter only 0fiscper3 and 0fiscyear values as user input and nothing else.
Hope its clear now .
Thanks
DR
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you restricted the amount kf with var1 which is based on 0fiscper--processed by cmod.It will not be ready for input.
Also IMPORTING is missing in the code check my code properly.
If possible after these changes if you get any error in the code then please share the error screenshot.
Regards,
AL
Hi Anshu,
Thank You soooo much. I really appreciate your help with the code and the detailed explanation. Its hard to get reply on the BI-ABAP area out of which you always respond on time. Excellent knowledge on the BI-ABAP expertise and I guess this page will be helpful to all the folks who search SDN for the previous period calculation.
Again thanks for the help. The main culprit is the exporting word . I somehow missed it while coding. . You have got the point exactly right on the pin. You are an ABAP genius mate. Thanks for the support and prompt replies.
Cheers
DR
Daniel,As per you requirement user will be entering posting period and fiscal year and based on it you need to display the amount of last 6 fiscal year period.
I am assuming that you are having 0fiscper in your provider as well.
Now lets take one eg: User enters Posting period (0fiscper3) as 003 and fiscal year (0fiscyear) as 2014
so you will require amount for fiscalyear periods 0022014,0012014,012,2013 and so on.
My take on this would be to create two dummy selections--restrict one with variable created on posting period and other on fiscal year.This will facilitate user with entry on selection screen.
Now create another 6 selections--Restrict with variable of type cmod based on fiscal year period.
In cmod code we will read the value of posting period once and then of the year and finally pass the value to the variable based on fiscal year period.
DATA:PP TYPE /bi0/oifiscper3,
FY TYPE /bi0/oifiscyear,
FP TYPE /bi0/oifiscper,
FP1 TYPE /bi0/oifiscper.
WHEN 'VAR1'.----CMOD Variable based on fiscal year period
READ TABLE i_t_var_range INTO loc_var_range WITH KEY vnam = 'VAR2'.---User input variable based on posting period
PP = loc_var_range-low.
READ TABLE i_t_var_range INTO loc_var_range WITH KEY vnam = 'VAR3'.--user input variable based on fical year
FY = loc_var_range-low.
CONCATENATE FY PP INTO FP.
CALL FUNCTION 'RST_IOBJ_SHIFT'
I_TIMNM = 0FISCPER
I_TIMVL = FP
I_SHIFT = -1
I_FISCVARNT = 'K4'
E_TIMVL = FP1.
l_s_range-low = FP1.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
I have not tested the same on my system but this should give you a rough idea to move forward with the process.
Keep on decreasing the shift with -1 for other variables.
Regards,
AL
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi AL,
Thanks a lot for the code. Yes we have 0fiscper in the MP.
Let me rephrase what I understood. Need to create 3 user entry variables zvar1 and zvar2, zvar3 for FY period , posting period and and Fiscal year respectively.
And try with your code. But how many variable's do i need to create ?
For example I restrict the amount KF with all the zvar1, zvar2 and zvar3 is it ? But do I need to get the value for 0fiscper from the user and create a user input variable on it ? But the requirement is to get only 0fiscper3 and 0fiscyear value from the user. Can we do this without getting user input for 0fiscper. I am sorry could not get your solution. Please let me know how and what variables to restrict the amount and I need 6 amount field's /.columns for all the 6 period's. 1 based on the user input and the remaining 5 on the previous period's. Based on this can you please provide me an example with the variable selection and cmod variables.
Do I need to create 5 user exit's for FY and 5 for 0fiscper3 ? or just user zvar2 and zvar3 based on offset's as we are passing them through CMOD ?
If we are passing them through CMOD.....how can we pass 2 fiscal year's in a same variable in case of different year selection ?
Please suggest.
Thanks
DR
AL,
I have copied your code, but I dont understand one thing, we are are not fetching 0fiscper from user input and your code is based on when "var1" which is the variable for 0fiscper . right ?
Can you please let me know with what variable's we need to restrict the amount KF's for all the 6 periods ?
do you mean we are passing 0fiscper as an offset calculation for all the 6 period calcuation ?
How come there is no i_step 2 and i_step 3 here and we are calculating this code for user input variable ? Dont we need those here in the CMOD code ?
Please advise, any abaper.
Thanks
DR
Hi,
I could not find the FM " RST_IOBJ_SHIFT" . what is it used for ? Can we change the same code without fetching the 0fiscper value from the user input, in that case we need to remove
" WHEN 'VAR1'.----CMOD Variable based on fiscal year period" correct ?
Please advise anyone is there any other solution ?
Thanks
DR
Daniel,there was a typo error in FM.Actually it is RST_TOBJ_SHIFT.
Use this FM as i suggested in my last reply.You need to write the code in i_step = 2.
Create 6 customer exit variable based on fiscal year period and respectively restrict your amount kf with them.
Create one user input variable based on 0fiscper3 and another user input variable based on fiscal year.Restrict your amount kf with them.This will just act as dummy kf to facilitate user with input variable.
Give it a try and let me know the outcome.
Regards,
AL
READ TABLE i_t_var_range INTO loc_var_range WITH KEY vnam = 'VAR1'.
** User input variable based on posting period
PP = loc_var_range-low.
READ TABLE i_t_var_range INTO loc_var_range WITH KEY vnam = 'VAR3'.
** user input variable based on fical year
FY = loc_var_range-low.
CONCATENATE FY PP INTO FP.
CALL FUNCTION 'RST_TOBJ_SHIFT'
EXPORTING
I_TIMNM = 'VAR3 '
I_TIMVL = FP
I_SHIFT = -1
I_FISCVARNT = 'K4'
E_TIMVL = FP1.
l_s_range-low = FP1.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
Thanks a lot for the update. First I need to create a dummy KF with restriction on fy and fy period for user input selection.
Create the amount's with all the 6 period's selection and restrict with 0fiscper so that we are passing the values from the CMOD to it. Increase offset's for these so that first value which ever we pass from CMOD will act as a base .right ?
Can you please fix this code and suggest me when to add i_step =2 and i_step=3.....for which variable is it for var1 ( 0fiscper3) or var3 ( fy) ?
thanks
DR
DATA:PP TYPE /bi0/oifiscper3,
FY TYPE /bi0/oifiscyear,
FP TYPE /bi0/oifiscper,
FP1 TYPE /bi0/oifiscper.
WHEN 'VAR1'.----CMOD Variable based on fiscal year period(ofiscper)
IF I_STEP = 2.
READ TABLE i_t_var_range INTO loc_var_range WITH KEY vnam = 'VAR2'.---User input variable based on posting period (0fiscper3)
PP = loc_var_range-low.
READ TABLE i_t_var_range INTO loc_var_range WITH KEY vnam = 'VAR3'.--user input variable based on fical year(0fiscyear)
FY = loc_var_range-low.
CONCATENATE FY PP INTO FP.
CALL FUNCTION 'RST_TOBJ_SHIFT'
EXPORTING
I_TIMNM = '0FISCPER'
I_TIMVL = FP
I_SHIFT = -1
I_FISCVARNT = 'K4'
IMPORTING
E_TIMVL = FP1.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
l_s_range-low = FP1.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
CLEAR:FP,FP1,PP,FY.
ENDIF.
Hi AL,
I have few questions given below. Please advise.
I have created a user input selection of variables for amount on 0fiscper3 and 0fiscyear.
1) Do we need to have var1 ( 0fiscper) variable in CMOD in the user input selection. I have created var1, with properties of var1 - 0fiscper as below. Cant we do this without this 0fiscper user input selection ? As per the requirement the user shoudl input only the 0fiscper3 and 0fiscyear.
Type of Variable = Characteristic
Variable Name = var1
Processing by = Customer Exit
Characteristic = 0fiscper
Variable Represents = Single Value
Variable Entry = Mandatory + Check ready for input ( We should not ask this entry from user nor in the selection ).
but your code is asking to fetch this input as we have written i_step = 2 for var1 which is for user input. right ? How can we tweak the code without input selection of 0fiscper.
Please find my latest code below.
var2 is for 0fiscper3 and var3 = 0fiscyear. but are user input mandatory + char + variable + processing by manual input- NOT CUSTOMER EXIT
WHEN 'VAR1'.
IF I_STEP = 2.
READ TABLE i_t_var_range INTO loc_var_range WITH KEY vnam = 'var2' .
** User input variable based on posting period
PP = loc_var_range-low.
READ TABLE i_t_var_range INTO loc_var_range WITH KEY vnam = 'var3'.
** user input variable based on fical year
FY = loc_var_range-low.
CONCATENATE FY PP INTO FP.
CALL FUNCTION 'RST_TOBJ_SHIFT'
EXPORTING
I_TIMNM = '0FISCPER '
I_TIMVL = FP
I_SHIFT = -1
I_FISCVARNT = 'K4'
E_TIMVL = FP1.
l_s_range-low = FP1.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
CLEAR:FP,FP1,PP,FY.
ENDIF.
Thanks
DR
Daniel,
I think you would have to create 5 customer exits on 0fiscper3 and also on 0fiscyear
The Fiscal Period exits will subtract -1, or -2, or -3 etc. etc. etc. from the user input but you would have to add logic that if the input it 0 - then the value is 12 for the first one, 11 for the next and so on.
You need similar logic on fiscal year that if the user input is 0 then less than 6, then you have to start to subtract -1 from the year value input.
The relevant cust exit on 0fiscper3 needs to be paired with the correct 0fiscyear cust exit. Messy but it would work!
With regards
Gill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi DR,
Do you want to give two separate fields for the user to enter FiscYear and FiscPer?
Wont 0CALMONTH (Cal Month./Year, eg: 201009) serve your pupose?
If you use 0CALMONTH, Offset at the BEx query level for the RKF will work.
If you use FiscYr and FIscPer separately, you will need to achieve this using Customer exits.
Regards,
Srilakshmi B
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Right, DR. Requirements cannot be changed generally.
But there is certainly a way and it is to create Cust exits like i've mentioned before and so have Rajesh and Gill.
You will need to create cust exits taking in FiscPer and FiscYear separately and combining them in the exit variable code.
Below is what I think would work..you may wish to try based on your requirement..
1. Create a cust exit on FiScper based on user entry.
2. In the code, populate the last perdiod, i.e, the 6th period
3. Follow steps 1 and 2 for FiscYr as well
4. In the Query now, use these variables in the RKF and keep doing an offset of +1, +2 till +4 in the 4 new RKFs that you will create
5. Thus you will have values for the past 6 periods.
Regards,
Srilakshmi B
Daniel,
There are different ways in which customer exits are coded for..CLass methods are used, BADis are used etc..This depends on your design/standards being followed/input parameters etc.
How you code depends to a great extent on your design and standards followed. In case you have your ABAP team, you could possibly get their help.
Can however give the logic below. You need to get your code written in i_step = 2. (Execution after user entry)
In both exits, you will have to grab the low value of the user entered input.
eg: lv_fiscper = s_var_range-low
Next, lv_fiscper_last = lv_fiscper - 6 (Take care of the data types used in data declaration so that the difference -6 works correctly)
What comes out of this exit class method/code is lv_fiscper_last. This value should go into your new Customer exit variable to be used in RKFs with offset as explained above.
Follow the same logic for the exit varaible for FiscYear.
Remember to include the condition for Fiscper 001 in your code as follows:
If lv_fiscper = '001' then lv_fiscper_last = '007' (or whatever it is as per your requirement).
Regards,
Srilakshmi B
Hi Lakshmi,
Thanks for the explanation. I am planning to code in CMOD in Bex FM and nto the BADI. I will find some code reference and will try to implement the code.
Please find my understanding, I will first create 2 customer exit variables zvar1 for fy and zvar2 for 0fiscper3. Use this as reference to calculate and pass the values for other 0fiscper3 5 values. right ?
so if we can determine and pass the value to zvar2 then can use this zvar2 in the report by using offshet -1, -2, ...-6. correct ? and no need of coding for the other 6 period values through cmod. correct ? As we are passing the value to these 6 period from the initially calculated zvar1 and zvar2 values. Is my understanding right ? or do we need to create customer exit for these 6 period and pass it through cmod itself ?
Thank You
DR
DR,
Will go over my explanation again:
You just create two exit varaibles- one for FY and one for FP.
Based on user input, calcuate the last FY and FP in both these variabels based on the logic i've explained in my previous post ( FY-6 and FP-6)
Use these 2 exit variables in your query and create RKFs in the query using offsets on these newly created exit variables.
Hope this helps you proceed..
Regards,
Lakshmi
we cannot use a single FP to calculate all the 6 values. Because the year will be same till 5 values and the last 2 FP's the year will change. right ? For example take fy = 2013, and fp = 5, in this case, we cannot have the same fy =2013 for the last 2 FP values, we need to pass fy=2012 for which we cannot use the single FY variable. I guess we need to have 6 user exit's. As the RKF cannot be manipulated if we are passing/using same FY and FP for the other year variables.
Any abap'er please put the code. I m confused .
Thanks
DR
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.