Application Development 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: 

Date field validation

Former Member
0 Kudos

Hi all,

im creating a report in which i want the user should enter the posting date vaules only in the folowing 2 cond.

1. both values blank

2. both values mentioned.

i dont want the user to be enter only one value whether its budat-low or budat-high.

i tried it by using if cond. but its not working..

so plz give me the soln.

thanx....

1 ACCEPTED SOLUTION

former_member203501
Active Contributor
0 Kudos

see this...

REPORT Zpopup message-id zmsg.

select-options : s_date for sy-datum .

at selection-screen output .

if s_date-low is initial and s_date-high is not initial .

message i023 with 'enter both values or enter both blank'.

elseif s_date-low is not initial and s_date-high is initial .

message i023 with 'enter both values or enter both blank'.

endif.

.

14 REPLIES 14

GauthamV
Active Contributor
0 Kudos

hi,

use at selection screen on field event and write your logic.


ex:
at selection-screen on bpvno.
select single bukrs belnr gjahr augdt from bseg into ibseg3
where bukrs = ccode and
augdt in p_clrdt and
belnr in bpvno .
if sy-subrc = 0.
select single bukrs belnr blart from bkpf into ibkpf3 where
 bukrs = ccode and
 belnr in bpvno and
 gjahr = ibseg3-gjahr.
endif.
if ibkpf3-blart ne 'BR'.
message 'Enter BR Document Type' type 'E'.
endif.

former_member404244
Active Contributor
0 Kudos

Hi,

If it is a selection screen field then when u execute the program they will appear as blank and if u give some values , i mean default values then they will have values....

Regards,

Nagaraj

Former Member
0 Kudos

Hi,

try this,

If budat-low is initial or budat-high is initial.

message w005(ZA).

endif.

it will work.

Regards,

Kusuma.

former_member203501
Active Contributor
0 Kudos

see this...

REPORT Zpopup message-id zmsg.

select-options : s_date for sy-datum .

at selection-screen output .

if s_date-low is initial and s_date-high is not initial .

message i023 with 'enter both values or enter both blank'.

elseif s_date-low is not initial and s_date-high is initial .

message i023 with 'enter both values or enter both blank'.

endif.

.

0 Kudos

>

> see this...

>

> REPORT Zpopup message-id zmsg.

>

> select-options : s_date for sy-datum .

>

> at selection-screen output .

>

> if s_date-low is initial and s_date-high is not initial .

>

> message i023 with 'enter both values or enter both blank'.

>

> elseif s_date-low is not initial and s_date-high is initial .

>

> message i023 with 'enter both values or enter both blank'.

>

> endif.

> .

thanx a lot it worked i just added stop to this .

and removed 'i' from mesg id and added 's'.

can u tel me how to increase the length of the message if it is possible..?

and also i dont want the msg. no to be display..

thanx...

0 Kudos

>

> >

> > see this...

> >

> > REPORT Zpopup message-id zmsg.

> >

> > select-options : s_date for sy-datum .

> >

> > at selection-screen output .

> >

> > if s_date-low is initial and s_date-high is not initial .

> >

> > message i023 with 'enter both values or enter both blank'.

> >

> > elseif s_date-low is not initial and s_date-high is initial .

> >

> > message i023 with 'enter both values or enter both blank'.

> >

> > endif.

> > .

>

> thanx a lot it worked i just added stop to this .

> and removed 'i' from mesg id and added 's'.

> can u tel me how to increase the length of the message if it is possible..?

> and also i dont want the msg. no to be display..

> thanx...

plzz answer this one..

Former Member
0 Kudos

i have already created the report but this is the last minute change so i dont want to make changes in my code now. so im trying to do it by if i.e simple way and without changeing the code..

Former Member
0 Kudos

Hi Nilesh,

Try this,

IF ( budat-low is initial and budat-high is initial ) OR (budat-low is not initial and budat-high is not initial ).

ENDIF.

Former Member
0 Kudos

Hi Nilesh,

Try it this way:

Data:
  w_date type budat.

Select-options:
  s_date for w_date.

At selection-screen on s_date.

  If s_date-low is initial and s_date-high is not initial.
    Message: 'enter a value in s_date-low' type 'E'.
  Elseif s_date-high is initial and s_date-low is not initial.
    Message: 'enter a value in s_date-high' type 'E'.
  Endif.

End-of-selection.

Write:/ s_date-low,
        s_date-high.

With luck,

Pritam.

Former Member
0 Kudos

Hi Nilesh,

Do it in this way:

at selection-screen output .

if s_budat-low is initial and not s_budat-high is initial.

        • Give your error message***

elseif not s_budat-low is initial and s_budat-high is initial.

        • Check your condition and give error message***

endif.

Regards,

Nitin.

Former Member
0 Kudos

sample example.

select-options : s_budat for bsad-budat.

at selection-screen.

if s_budat-low ne '' or s_budat-high = ''.

.

message E001(0) with 'remove date you entered'.

endif.

Former Member
0 Kudos

not answered

Former Member
0 Kudos

Hi Nilesh,

To increase the length of message, just go through the following link:

Hope this will help.

Regards,

Nitin.

Former Member
0 Kudos

ok