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

How to validate for proper date format

Kloud_Nilesh
Participant
0 Likes
661

Hi Experts,

I am using following Fm to calculate date difference.....

call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

exporting

i_date_from = wa_draw-zdm_vld_to_dat

i_date_to = sy-datum

importing

e_days = v_days.

if sy-subrc = 0 .

if v_days > 0.

-


-


But value of field zdm_vld_to_dat (data type DATS , YYYYMMDD) in database tables itself is wrong ...like ct/-0/29-o

I want to avoid passing these wrong data entry, in the FM...as also i give info message for this in spool.

So can anybody tel me How can I detect or know this fields zdm_vld_to_dat conatins wrong date other than YYYYMMDD...e.g.

ct/-0/29-o means any charecter or hyphen

Thank you.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
611

Just use this FM CONVERT_DATE_TO_INTERNAL if the date what you have given is correct then it will convert to your format. other wise skip that record or pass error msg.

Hi Experts,

I am using following Fm to calculate date difference.....

call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

exporting

i_date_from = wa_draw-zdm_vld_to_dat

i_date_to = sy-datum

importing

e_days = v_days.

if sy-subrc = 0 .

if v_days > 0.

-


-


But value of field zdm_vld_to_dat (data type DATS , YYYYMMDD) in database tables itself is wrong ...like ct/-0/29-o

I want to avoid passing these wrong data entry, in the FM...as also i give info message for this in spool.

So can anybody tel me How can I detect or know this fields zdm_vld_to_dat conatins wrong date other than YYYYMMDD...e.g.

ct/-0/29-o means any charecter or hyphen

Thank you.

2 REPLIES 2
Read only

Former Member
0 Likes
612

Just use this FM CONVERT_DATE_TO_INTERNAL if the date what you have given is correct then it will convert to your format. other wise skip that record or pass error msg.

Read only

Former Member
0 Likes
611

Hi Nilesh Hiwale,

1. First thing is there is no need for any function module for difference between two dates

See this.

Data:

days type i

date1 type wa_draw-zdm_vld_to_dat

date2 type sy-datum.

days = date2 - date1.

Write / days.

> (OR)

2. write this condition in PAI module of your screen.

At selection-screen.

if date1 cn '1234567890'. or date2 cn '123456789'.

write e000(Sabapdocu) with 'Enter YYYYMMDD Formate'.

endif.

Reward if it is useful,

Mahi.