Skip to Content
author's profile photo Former Member
Former Member

Fiscal year/period subtraction issue

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 11:37 AM
    Please let me know where I am missing. Points would be rewarded.

    Did you read the Rules before posting???

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 11:46 AM

    Please use like this. It should work.

    lv_period = '2008003'.

    lv_poper = ( lv_period+4(3) + 6 ) MOD 12.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 23, 2008 at 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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.