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

selection screen validation

Former Member
0 Likes
1,093

hi experts,

on my selection screen THREE fields MONTH , YEAR , POSTING DATE.

if month is 1 and year 2008 the date field month and year should be 4 and 2008 .

otherwise error message should appear.

how can i follow plz guide me.

Thanks & Regards ,

Hari..

10 REPLIES 10
Read only

Former Member
0 Likes
1,044

Hi,

Check this code..

AT SELECTION-SCREEN ON <Posting Date>.

l_month = <Month> + 3.
IF l_month GT 12.
  l_month = l_Month - 12.
ENDIF.

IF <Posting Date>(4) NE <YEAR> or <Posting Date>+4(2) NE l_month.
  " Error Message
ENDIF.

Read only

0 Likes
1,044

Thanks for reply,

PARAMETERS: p_mon LIKE bkpf-monat OBLIGATORY.

PARAMETERS: p_year LIKE bkpf-gjahr OBLIGATORY.

SELECT-OPTIONS: p_date for bkpf-budat OBLIGATORY..

on these fields i want to write validation.

plz guide me..

Thanks & Regards,

Hari..

Read only

0 Likes
1,044

Hi,

Can you please elaborate a bit more as to what validation needs to be done and when should the error message be thrown?

Read only

0 Likes
1,044

At selection screen.

if p_date+4(2) <> p_mon + 3 or p_date(4) <> p_year.

Message "your error message".

endif.

Read only

0 Likes
1,044
TABLES bkpf.
PARAMETERS: p_mon LIKE bkpf-monat.
PARAMETERS: p_year LIKE bkpf-gjahr.
SELECT-OPTIONS: p_date for bkpf-budat.

AT SELECTION-SCREEN on p_date.
data  mon type bkpf-monat.
mon = p_date-low+4(2).

if p_mon = '01' and mon ne '04'.
 " u can also use: data mon1 type bkpf-monat. mon1 = p_mon + 3. if mon1 ne mon. message 'error' type 'E'.
  MESSAGE 'error' type 'E'.
endif.

edit it as per ur need

Edited by: soumya prakash mishra on Jul 27, 2009 8:26 AM

Read only

0 Likes
1,044

Hi,

As you said ...if month is 1 and year 2008 the date field month and year should be 4 and 2008

why do you want the p_date field as range field...as per the above statement the what even user enter's the date in the p_date field .. the month should be +3 from the p_month and year should be equal to p_year.

Read only

sridhar_meesala
Active Contributor
0 Likes
1,044

>

> if month is 1 and year 2008 the date field month and year should be 4 and 2008 .

Hi,

Could you explain your requirement more clearly.

Thanks,

Sri.

Read only

Former Member
0 Likes
1,044

check the below logic.

DATA: z_v_var(8) TYPE c.

AT SELECTION-SCREEN ON p_date.

IF p_mon = '1' AND

p_year = '2008' .

LOOP AT p_date.

MOVE p_date-low TO z_v_var.

IF z_v_var(6) NE '200804'.

error message.

ENDIF.

IF NOT p_date-high IS INITIAL.

MOVE p_date-high TO z_v_var.

IF z_v_var(6) NE '200804'.

error message.

ENDIF.

ENDIF.

ENDLOOP.

ENDIF.

I am not sur if I have understood your requirement clearly.

Edited by: venkatesh PH on Jul 27, 2009 8:01 AM

Read only

Former Member
0 Likes
1,044

data v_num type i,

AT SELECTION-SCREEN.

v_num = p_mon + 3.

if p_date-low(4) ne p_year or p_date-low+4(2) ne v_num

error messgae.

endif

do the same for p_date-high also

handle the month's overflow(Eg- For November)

Read only

venkat_o
Active Contributor
0 Likes
1,044

Hi Hari, Try this way,


REPORT ztest_notepad.
TABLES bkpf.

PARAMETERS: p_mon LIKE bkpf-monat OBLIGATORY.
PARAMETERS: p_year LIKE bkpf-gjahr OBLIGATORY.
SELECT-OPTIONS: s_date FOR bkpf-budat OBLIGATORY.

AT SELECTION-SCREEN ON s_date.
  IF s_date-low+0(4) NE p_year OR
     s_date-low+4(2) NE p_mon.
    MESSAGE e020(z7) WITH 'Month & year should be ' p_mon '&' p_year.
  ENDIF.
  IF s_date-high+0(4) NE p_year OR
     s_date-high+4(2) NE p_mon.
    MESSAGE e020(z7) WITH 'Month & year should be ' p_mon '&' p_year.
  ENDIF.
Thanks Venkat.O