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: 

Need validation logic

Former Member
0 Kudos

Hi al,

I have period field on selection csreen , how can i validate the period field start from JULY of 2007 and June of 2008.

How cai write validation.

regards,

Ajay

8 REPLIES 8

former_member181962
Active Contributor
0 Kudos

if period is month, thendo something like this.

if period < 7 and year = 2007.

message e000(zz) with 'Invalid period'.

endif.

if period > 6 and year = 2008.

message e000(zz) with 'Invalid period'.

endif.

REgards,

Ravi

0 Kudos

data: current_year(4) type n,

next_year(4) type n.

current_year = sy-datum+0(4).

if period < 7 and year = current_year.

message e000(zz) with 'Invalid period'.

endif.

next_year = current_year + 1.

if period > 6 and year = next_year.

message e000(zz) with 'Invalid period'.

endif.

0 Kudos

When i executed report with this valiation,it is giving Dump.

regards,Ajay

0 Kudos

Hi Ajay,

Can you post your code??

and what does the dump analysis say??

Former Member
0 Kudos

Hello,

Do like this.

at selection screen on P_data.
data: lv_start like sy-datum value '20070701',
        lv_end   like sy-datum value '20080630'.
if P_date between  lv_start and lv_end.
else.
" Error Message
endif.

Vasanth

0 Kudos

HI,

year should be dynamic ..not static .

regards,AJay

Former Member
0 Kudos

see if the reason for the short dump is elsewhere in the code. that piece of code is suitable for you. there shouldn't be any prob in that.

<b> better u give ur code!</b>

regards,

srinivas

0 Kudos

see the code.

FORM VALIDATE_PERIOD .

data: L_current_year(4) type n,

L_next_year(4) type n.

L_current_year = sy-datum+0(4).

if S_MONAT < 7 and S_GJAHR = L_current_year.

message e000(zz) with 'Invalid period'.

endif.

L_next_year = L_current_year + 1.

if S_MONAT > 6 and S_GJAHR = L_next_year.

message e000(zz) with 'Invalid period'.

endif.

ENDFORM. " VALIDATE_PERIOD

regards,

AJay