‎2009 Jul 27 5:29 AM
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..
‎2009 Jul 27 5:37 AM
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.
‎2009 Jul 27 5:49 AM
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..
‎2009 Jul 27 6:56 AM
Hi,
Can you please elaborate a bit more as to what validation needs to be done and when should the error message be thrown?
‎2009 Jul 27 7:12 AM
At selection screen.
if p_date+4(2) <> p_mon + 3 or p_date(4) <> p_year.
Message "your error message".
endif.
‎2009 Jul 27 7:23 AM
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
‎2009 Jul 27 8:56 AM
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.
‎2009 Jul 27 5:38 AM
>
> 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.
‎2009 Jul 27 7:01 AM
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
‎2009 Jul 27 7:30 AM
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)
‎2009 Jul 27 9:14 AM
Hi Hari,
Try this way,
Thanks
Venkat.O
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.