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

IF condition

Former Member
0 Likes
1,198

Dear All,

I am facing a very weired problem.I have a module pool program where there is one input field with input help(F4).This field is mandatory field in certain scenarios.If this field is empty then the system should displya an error saying "Reject Reason is required field".

Case 1 -

If the field is empty ---the system display error message - This is correct

Case 2 -If this field is not empty - The system still displays an error message saying it is a required field - This is wrong.

In the code there is the following If condition

-


CHECK error_flag EQ space.

IF zpc0-responsibil EQ '95' OR

zpc0-responsibil EQ '98'.

IF zpc0-rjc_rea EQ space OR

zpc0-rej_remarks EQ space.

MESSAGE i653 WITH 'Reject Reason'.

error_flag = 'Y'.

position_flag = 'RJC_REA'.

ENDIF.

ELSE.

IF zpc0-rjc_rea NE space OR

zpc0-rej_remarks NE space.

MESSAGE i416 WITH

'Must be empty reject reason & remark for rejection'.

error_flag = 'Y'.

position_flag = 'RJC_REA'.

ENDIF.

ENDIF.

-


I am sending zpc0-responsibil = 95 and zpc0-rjc_rea = 99..Still the IF condition is satisfied and i system executes the stmt MESSAGE i653 WITH 'Reject Reason'.

Can any one please suggest what could be the problem .

NOTE- In debugging mode i see the values for zpc0-responsibil as 95 and zpc0-rjc_rea as 99.

Thanks in advance,

Swati

8 REPLIES 8
Read only

Former Member
0 Likes
1,153

HI,

Check this code

IF zpc0-responsibil EQ '95' OR
zpc0-responsibil EQ '98'.

" If You use OR and pass 99 to zpc0-rjc_rea and space in zpc0-rej_remarks 
" then if any one is satisfied the error message is displayed
IF zpc0-rjc_rea EQ space AND  " -->NOT OR 
zpc0-rej_remarks EQ space.

MESSAGE i653 WITH 'Reject Reason'.
error_flag = 'Y'.
position_flag = 'RJC_REA'.
ENDIF.
ELSE.
IF zpc0-rjc_rea NE space OR
zpc0-rej_remarks NE space.
MESSAGE i416 WITH
'Must be empty reject reason & remark for rejection'.
error_flag = 'Y'.
position_flag = 'RJC_REA'.
ENDIF.
ENDIF.

Read only

Former Member
0 Likes
1,153

SO what about this field

zpc0-rej_remarks

is that equal to space at that time in that case that will be the prob

Read only

Former Member
0 Likes
1,153

Hi,

You said you are passing the following values:-

""zpc0-responsibil = 95 and zpc0-rjc_rea = 99.

Still the IF condition is satisfied and i system executes the stmt MESSAGE i653 WITH 'Reject Reason'.""

But you have not specified what you are passing in zpc0-rej_remarks .

If zpc0-rej_remarks contains space then you will definitely get your error message because you are using 'OR' condition.

Regards,

Ankur Parab

Read only

Former Member
0 Likes
1,153

Hi,

u have put OR condition in IF,

IF zpc0-rjc_rea EQ space OR
zpc0-rej_remarks EQ space.

.

therefore even u are passing zpc0-rjc_rea = 99 , but zpc0-rej_remarks is taking space hense if condition is true and giving u that message.

Use AND in above IF condition.

Regards

Vishal

Read only

0 Likes
1,153

I cant believe this ..this simple thing didnt strike me ....Guys you all are correct .The zpc0-rej_remarks is passed as space hence the errror.

Thanks a lot for this help.

Problem Solved.

Read only

Former Member
0 Likes
1,153

Hi,

IF zpc0-rjc_rea EQ space OR

zpc0-rej_remarks EQ space.

MESSAGE i653 WITH 'Reject Reason'.

if any of the above condition is true the 'if' condition gets satisfied..

if the zpc0-rej_remarks field is empty then it would giv u the error msg.

pass the value in zpc0-rej_remarks field

Regards,

Read only

Former Member
0 Likes
1,153

hhh

Edited by: Arun on May 14, 2009 8:17 AM

Read only

Former Member
0 Likes
1,153

do like this

IF zpc0-responsibil EQ '95' and

zpc0-responsibil EQ '98'.

IF zpc0-rjc_rea EQ space OR

zpc0-rej_remarks EQ space.

MESSAGE i653 WITH 'Reject Reason'.

error_flag = 'Y'.

position_flag = 'RJC_REA'.

ENDIF.

ELSE.

IF zpc0-rjc_rea NE space OR

zpc0-rej_remarks NE space.

MESSAGE i416 WITH

'Must be empty reject reason & remark for rejection'.

error_flag = 'Y'.

position_flag = 'RJC_REA'.

ENDIF.

ENDIF.

Regards

Shashi