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: 

Multiple condition check using if statement.

Former Member
0 Kudos

Hi

i NEED to check two conditions using if statment. I was wondering whether it is possible.

say fields zx and zy in an internal table itab. if one of those is intiial i have to display a message.

i tried this way

if itab-zx or itab-zy is initial.

error message.

-


endif.

It gives me error in syntax check.

I think i can check for first field using if and second one with elseif but for that matter of fact i have like 10 fields .out of which even one is initial i have to throw a message saying 'DATA CANNOT BE SAVED'.

Please suggest me how to go about this.

Thanks in advance.

1 ACCEPTED SOLUTION

suresh_datti
Active Contributor
0 Kudos

change it to

if ( itab-zx is initial or itab-zy is initial ).

Regards,

Suresh Datti

9 REPLIES 9

suresh_datti
Active Contributor
0 Kudos

change it to

if ( itab-zx is initial or itab-zy is initial ).

Regards,

Suresh Datti

Former Member
0 Kudos

Hi,

use this

<b>if itab-zx is initial or itab-zy is initial.</b>

Mark Helpful Answers

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Try this.



if ( itab-zx is initial ) 
  or ( itab-zy is initial ).
error message.
----

endif.

Regards,

Rich Heilman

Former Member
0 Kudos

Hi,

A internal table will multiple rows, so which row you want to check whether data is there or not.

If you don't want even a single row, then you could do this.

loop at itab where x is initial or y is initial.

endloop.

if sy-subrc = 0.

message error

endif.

Regards,

Ravi

Former Member
0 Kudos

Hi,

Please award points and close the thread if solved.

since it is a table u can check the same condition in loop.

<b>loop.........</b>

condition mentiohned above

<b>

endloop.</b>

Message was edited by: Manoj Gupta

former_member188685
Active Contributor
0 Kudos
if itab-zx is initial or itab-zy is initial.
error message.

endif.

change your code like above..

regards

vijay

Former Member
0 Kudos

Hi Swathi,

You have to loop your internal table and then check.

Try this code.


LOOP AT itab.


  IF itab-z1 IS INITIAL OR
     itab-z2 IS INITIAL OR
     itab-z3 IS INITIAL OR
     itab-z4 IS INITIAL OR
     itab-z5 IS INITIAL OR
     itab-z6 IS INITIAL OR
     itab-z7 IS INITIAL OR
     itab-z8 IS INITIAL OR
     itab-z9 IS INITIAL OR
     itab-z10 IS INITIAL.

    MESSAGE 'DATA CANNOT BE SAVED' TYPE 'E'.

  ELSE.

    " Processing if none of the fields are Initial

  ENDIF.

ENDLOOP.

Regards,

Arun Sambargi.

Former Member
0 Kudos

hi swathi,

<b>if ( itab-zx is initial )

or ( itab-zy is initial ).</b>

message e001(zz2).

---

endif.

hope this helps,

priya.

Former Member
0 Kudos

Hi

Thanks for your efforts.

I GOT THAT FIXED.

swathi