12-23-2008 11:32 AM
hi,
We are trying to code ABAP in BI so as to get 6 fiscal periods data from any given period for plant material.
For example,
if fiscal period 2008003 is input I need an output for six period data from 2008003 to 2007009.
The following is the code I tried.
data:
lv_period type rsfiscper,
lv_period1 type rsfiscper,
lv_poper type rsfiscper,
lv_poper1 type rsfiscper.
lv_period = '2008003'.
lv_poper = lv_period - 006.
write : lv_poper .
And I am getting the output as follows
Result: 997/2007
but the required result should be
009/2007
Please let me know where I am missing. <REMOVED BY MODERATOR - REQUEST OR OFFER POINTS ARE FORBIDDEN>
Thanks
AP
Code Formatted by: Alvaro Tejada Galindo on Dec 23, 2008 10:21 AM
12-23-2008 11:37 AM
Please let me know where I am missing. Points would be rewarded.
Did you read the Rules before posting???
12-23-2008 11:46 AM
Please use like this. It should work.
lv_period = '2008003'.
lv_poper = ( lv_period+4(3) + 6 ) MOD 12.
12-23-2008 11:47 AM
You must take in consideration that the field is a number for SAP, so 2008003 - 6 is 2007997. You have to split the field in to YYYY + PPP and then do the math separated, thinking that PPP is a number from 001 to 012. The code might be a bit tricky but it's solvable.
data : begin of w_per,
year(4) type n,
period(3) type n,
end of w_per.
data : begin of w_output ,
year(4) type n,
period(3) type n,
end of w_per.
data : w_dif(3) type n.
w_per = lv_period.
if w_per-period < 6.
w_dif = 6 - w_per-period.
w_output-period = 12 - w_dif.
w_output-year = w_per-year - 1.
else.
w_output = lv_period - 6.
endif.
Something like this might do the trick.