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

Need to give condition to select the fields for last 2 year &previous year

give a sample program. how to give a condition to select the field values for last 2 year and

a condition to reterieve fields based on perious year

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Dec 05, 2005 at 11:03 AM

    Josephine,

    Could you please elaborate the requirement?????

    Thanks

    Kam

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 05, 2005 at 11:09 AM

    Sorry your question is unspecific.

    So how to answer a question if we can not understand what is your goal or task?

    parameters:

    p_year type gjahr,

    p_lastyr type gjahr

    initialization.

    p_year = sy-datum(4).

    p_lastyr = p_year - 1.

    start-of-selection.

    select ... gjahr ... into ???

    case ???-gjahr.

    when p_year.

    • do something for this year

    when lastyr.

    • do something for last year

    endcase.

    endselect.

    Hope it helps,

    C

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 05, 2005 at 11:10 AM

    you can directly give the date in where condition if you have date field in side database by providing 2years date or 1 year previous to current date.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 05, 2005 at 12:00 PM

    Hi,

    calculate previous year:

    p_year = sy-datum(4) - 1.

    1) p_year_begin type sy-datum:

    concatenate p_year '0101' into p_year_begin.

    2) p_year_date type sy-datum:

    concatenate p_year sy-datum+4 into p_year_date.

    -> example for sel. bkpf

    select * from bkpf into itab
     where bukrs  in s_bukrs 
       and gjahr between p_year and sy-datum(4)
       and cpudt between p_year_date and sy-datum.

    Andreas

    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.