06-08-2006 4:29 PM
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.
06-08-2006 4:32 PM
change it to
if ( itab-zx is initial or itab-zy is initial ).
Regards,
Suresh Datti
06-08-2006 4:32 PM
change it to
if ( itab-zx is initial or itab-zy is initial ).
Regards,
Suresh Datti
06-08-2006 4:32 PM
Hi,
use this
<b>if itab-zx is initial or itab-zy is initial.</b>
Mark Helpful Answers
06-08-2006 4:32 PM
06-08-2006 4:33 PM
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
06-08-2006 4:35 PM
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
06-08-2006 4:37 PM
if itab-zx is initial or itab-zy is initial.
error message.
endif.
change your code like above..
regards
vijay
06-08-2006 4:39 PM
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.
06-08-2006 4:45 PM
hi swathi,
<b>if ( itab-zx is initial )
or ( itab-zy is initial ).</b>
message e001(zz2).
---
endif.
hope this helps,
priya.
06-08-2006 5:10 PM