‎2008 Mar 31 10:47 AM
Hello abapers..
I want two function modules...
1) to subtract 1 hour from time and date.
for eg if the date entered is 23.3.08 and time is 00:00:00
then the function module should give the result as
22.3.08 and 23:00:00.
or if the date is 21.03.08 and time is 12:00:00.
The result should be 21.03.08 and time 11:00:00.
2) the second one is for validation..i am not sure if there is
a function module for that.
I want to validate whether the date entered by the user
in the select option for type sy-datum is in the correct format.
I mean the user should not enter anything except a date.
For eg:
If the user enters 97898jjjj then it should also invalidate this
as well as if the user enters 34.07.08 then also the FM should invalidate this..
Points will be rewarded for helpful answer.
‎2008 Mar 31 10:52 AM
1)
DATA: dat TYPE d,
tim TYPE t.
IF tim LT '01000'.
SUBTRACT 1 FROM dat.
ENDIF.
SUBTRACT 3600 FROM tim.2)
If you define your select options as type sy-datum, the user cannot enter an implausible/invalid date.
matt
‎2008 Mar 31 10:54 AM
use fm
RP_CALC_DATE_IN_INTERVAL
Add/subtract years/months/days from a date
‎2008 Mar 31 10:59 AM
hi,
Use the below FM ..
IF pa_older = 'X'.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
date = pa_end
days = '00'
months = '06'
signum = '-'
years = '00'
IMPORTING
calc_date = pa_end.
ENDIF.
‎2008 Mar 31 11:01 AM
I am sorry but my select option is not of type sy-datum.
But of the type ITSEGDIAE-TIME_TST01 .
and it is a combination of date and time.
This structure is linked to the table TSEGE and the field for the
date and time is TSEGE-even_tstfr.
It is displayed in numeric format like 20.071.026.100.000.
But internally date and time is stored as 26.10.2007 10:00:00.
So i want to validate whether the date and time is in the correct format.
Also i want to subtract 1 hour from the actual date and time entered by the user.
‎2008 Mar 31 11:01 AM
Hi,
Try the FM.
SCOV_TIME_DIFF.
example.
Import parameters Value
IM_DATE1 31.03.2008
IM_DATE2 31.03.2008
IM_TIME1 10:00:00
IM_TIME2 11:00:00
Export parameters Value
EX_DAYS 0
EX_TIME 01:00:00
Regards,
Morris Bond.
Reward Points if Helpful.
‎2008 Mar 31 11:05 AM
hi,
I have input as date and time and constant subtraction of 1 hour
.
The output should be new date and time with 1 hour subtraction.
‎2008 Mar 31 11:09 AM
Try the FM LEINT_TIMECALC_DIFF / TIMECALC_DIFF.
This will find the difference b/w 2 time stamps in seconds.
Hope this helps.
Thanks
Balaji
‎2008 Mar 31 11:15 AM
Hi,
i also had one requirment of adding 1hour tp date and time.
i used the FM dimp_add_time. But i m not finding a suitable FM for subtracting 1 hour.I have still not got a apt FM like that.
‎2014 Nov 27 12:12 PM
Try this
DATA : diff TYPE i.
PARAMETERS :
iv_stime TYPE t,
iv_sdate TYPE d,
iv_atime TYPE t.
ev_endtime = iv_stime - iv_atime.
diff = ev_endtime - iv_stime.
IF diff > 0.
ev_enddate = iv_sdate - 1.
ELSE.
ev_enddate = iv_sdate.
ENDIF.
WRITE : ev_endtime.
WRITE : ev_enddate.
‎2008 Mar 31 11:19 AM
Try the below FM CONV_UTIL_ADD_DATE_AND_TIME .
This will help you to add days and time to a timestamp. It will give you result in datestamp too.
Hope this helps.
Thanks
Balaji
‎2008 Mar 31 11:23 AM
Hi,
I do have a FM to add time i want a FM to subtract time!!!!
Is it that in SAP there is FM to add time but no FM to subtract
time!!!!!
‎2008 Mar 31 11:41 AM
‎2008 Apr 12 11:42 AM
Hi,
Try FM IGN_TIMESTAMP_PLUSMINUS
The Flag BACKWARD if to subtract.
Reward Points if useful.
Neelav
‎2014 Nov 27 12:12 PM
Try this
DATA : diff TYPE i.
PARAMETERS :
iv_stime TYPE t,
iv_sdate TYPE d,
iv_atime TYPE t.
ev_endtime = iv_stime - iv_atime.
diff = ev_endtime - iv_stime.
IF diff > 0.
ev_enddate = iv_sdate - 1.
ELSE.
ev_enddate = iv_sdate.
ENDIF.
WRITE : ev_endtime.
WRITE : ev_enddate.
‎2021 Sep 27 2:03 PM
Try these two function module
IGN_TIMESTAMP_PLUSMINUS
CATT_ADD_TO_TIME