2009 Mar 14 10:42 PM
I have this code that is not reacting properly when I have some bad dates.
data: zfirst_dat TYPE sy-datum, zfirst_tim type sy-uzeit.
data: zlast_dat TYPE sy-datum, zlast_tim type sy-uzeit.
data: my_dur TYPE F, my_dur_fix type p length 5 decimals 1.
if zfirst_dat is NOT initial or zlast_dat is NOT initial.
"call the fm to get the mday duration
call function 'DURATION_DETERMINE'
EXPORTING
UNIT = 'DY'
FACTORY_CALENDAR = 'Z1'
IMPORTING
DURATION = my_dur
CHANGING
START_DATE = zfirst_dat
START_TIME = zfirst_tim
END_DATE = zlast_dat
END_TIME = zlast_tim.
"adjust the duration
my_dur_fix = my_dur.
else.
my_dur_fix = 0.
endif.
So if I have a date like 00000000 then it is getting passed to the FM. I thought that 00000000 would be defined as NOT initial.
If there a better way I should be writing this code?
Mike
2009 Mar 14 10:50 PM
2009 Mar 14 10:50 PM
2009 Mar 14 11:00 PM
nope ... it still got past that ck into the fm.
I need some check to see if I have a valid date.
I noticed in debugging that the fm i called got passed to this fm:
DATE_CONVERT_TO_FACTORYDAT
and that fm passed back a 'ivalid date'
Mike
2009 Mar 14 11:12 PM
it shud work:
try it like this:
if zfirst_dat GT '0' or zlast_dat GT '0'.
if its still dont wrk:
try this:
if zfirst_dat ne 0 or zlast_dat ne 0
Edited by: BrightSide on Mar 14, 2009 11:12 PM
2009 Mar 14 11:49 PM
check these two fms
RP_CHECK_DATE
DATE_CHECK_PLAUSIBILITY <-- this seems most likely to suit u
if one of these can succesfully validate the date then use it in ur fm,
кu03B1ятu03B9к
2009 Mar 15 4:53 AM
Try if date1 <> '00000000' or date2 <> '00000000'.
endif.
Mathews
2009 Mar 15 11:54 PM
The method I ended up using was DATE_CHECK_PLAUSIBILITY.
Thank you all very much !