2008 Mar 12 12:54 PM
hi all can anyone give me the logic . on selection screen i have date field date-low and date-high in high it is bydefault sy-datum but in low i need 4 months back date how do i do it..
please its urgent
2008 Mar 12 1:05 PM
In initialization :
USE FM .. to subtract months to the date ..
CALL FUNCTION 'OIL_DATE_SUBTRACT_MONTH'
EXPORTING
date = sy-datum
months = '4'
IMPORTING
DATE_E = v_newdate
EXCEPTIONS
DATE_ERROR = 1
OTHERS = 2
.
date-low = v_newdate
date-high = sy-dayum
date-sign = 'I'
date-option = 'BT'.
append date.
hi all can anyone give me the logic . on selection screen i have date field date-low and date-high in high it is bydefault sy-datum but in low i need 4 months back date how do i do it..
please its urgent
2008 Mar 12 1:00 PM
Hi,
I guess u need to validate if the date-low values is within four months from the current date. If that is so,
use this FM to find diff betn dates and throw error msg.
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = s_audat-high
i_datum_von = s_audat-low
i_kz_excl_von = '0'
i_kz_incl_bis = '0'
i_kz_ult_bis = ' '
i_kz_ult_von = ' '
i_szbmeth = '1'
IMPORTING
e_tage = lf_days
EXCEPTIONS
days_method_not_defined = 1
OTHERS = 2.
IF sy-subrc = 0.
IF lf_days GT <days>.
MESSAGE e004 WITH text-t12. "Error if date span is more
"than 4 months
ENDIF.
ENDIF.
Reward if helpful.
Regards,
Ramya
2008 Mar 12 1:01 PM
Hi Amit,
Calculate the date you are looking for as a backdated one in the INITIALISATION EVENT of your program/report.
Get the desired previous date in a variable and give that variable as you are displaying sy-datum.
Regds,
Gaurav
2008 Mar 12 1:02 PM
Hi,
IN the Initialization event,
Use the function module CALCULATE_DATE, and get the 4 months back date and pass it DAY-LOW
Regards
Sudheer
2008 Mar 12 1:03 PM
Hi,
Try something like this:
SELECTION-SCREEN begin of block b1.
PARAMETERS: p_dhigh type sy-datum DEFAULT sy-datum,
p_dlow type sy-datum .
SELECTION-SCREEN end of BLOCK b1.
load-OF-PROGRAM.
p_dlow = sy-datum - 120.
2008 Mar 12 1:04 PM
sy-datum stores date as yyyymmdd in SAP.
so in initialization write as
v1 = sy-datum+4(2).
if v1 > 4.
v1 = v1 - 4.
elseif V1 = 3.
v1 = 12.
elseif V1 = 2.
V1 = 11.
elseif V1 = 1.
V1 = 10.
endif.
concatenate yyyy V1 dd into p_date-low.
2008 Mar 12 1:05 PM
In initialization :
USE FM .. to subtract months to the date ..
CALL FUNCTION 'OIL_DATE_SUBTRACT_MONTH'
EXPORTING
date = sy-datum
months = '4'
IMPORTING
DATE_E = v_newdate
EXCEPTIONS
DATE_ERROR = 1
OTHERS = 2
.
date-low = v_newdate
date-high = sy-dayum
date-sign = 'I'
date-option = 'BT'.
append date.
2008 Mar 12 1:07 PM
Hi,
You can do this in the INITIALIZATION event of your program.
Call FM RP_CALC_DATE_IN_INTERVAL
pass signum as '-' months as '04' date as s_date-high.
select-options: s_date for sy-datum.
INITIALIZATION.
s_date-sign = 'I'.
s_date-option = 'BT'.
s_date-high = sy-datum.
call function 'RP_CALC_DATE_IN_INTERVAL'
exporting
date = s_date-high
days = '00'
months = '04'
signum = '-'
years = '00'
importing
calc_date = s_date-high.
append s_date.
Hope this helps.
Thanks
Balaji
2008 Mar 12 1:35 PM
Hi amit,
Try this code ,
TABLES vbak.
SELECT-OPTIONS : so_date FOR vbak-erdat.
DATA : gv_date TYPE sydatum,gv_mon TYPE i.
INITIALIZATION.
MOVE:
sy-datum to so_date-high .
gv_mon = so_date-high+4(2).
IF so_date-high+4(2) GT 4.
gv_mon = gv_mon - 4.
gv_date+4(2) = gv_mon .
elseif so_date-high+4(2) eq 4.
gv_mon = 12.
elseif so_date-high+4(2) eq 3.
gv_mon = 11.
elseif so_date-high+4(2) eq 2.
gv_mon = 10.
elseif so_date-high+4(2) eq 1.
gv_mon = 9.
ENDIF.
gv_date0(4) = sy-datum0(4).
gv_date6(2) = sy-datum6(2).
MOVE:
'BT' TO so_date-option,
sy-datum TO so_date-high .
so_date-low = gv_date.
APPEND so_date.
reward points