Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Date is initial

Former Member
0 Likes
1,214

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

1 ACCEPTED SOLUTION
Read only

Former Member
1,051

Make >>>>if zfirst_dat GT 0 or zlast_dat is GT 0.

6 REPLIES 6
Read only

Former Member
1,052

Make >>>>if zfirst_dat GT 0 or zlast_dat is GT 0.

Read only

0 Likes
1,051

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

Read only

0 Likes
1,051

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

Read only

0 Likes
1,051

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к

Read only

0 Likes
1,051

Try if date1 <> '00000000' or date2 <> '00000000'.

endif.

Mathews

Read only

0 Likes
1,051

The method I ended up using was DATE_CHECK_PLAUSIBILITY.

Thank you all very much !