12-05-2005 11:00 AM
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
12-05-2005 11:03 AM
Josephine,
Could you please elaborate the requirement?????
Thanks
Kam
12-05-2005 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
12-05-2005 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.
12-05-2005 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