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

NEsted IF

Former Member
0 Likes
1,372

Hi,

can anyone correct this statement

select * from zco where co = siitab-id.

ENDSELECT.

if co = '11' and /cotyp = '14'.

j_itab-typ = 'aa' OR 'bb' OR 'cc' OR 'dd' OR 'dd'.

J_ITAB-RCOST_CENTER_ID = 'Y'

co = 'aa' and cotyp = '10'.

j_itab-typ = 'aa'.

else.

messsage e001 with ' values are out of range

endif.

14 REPLIES 14
Read only

Former Member
0 Likes
1,353

see the code below :

REPORT ZTEST3 line-size 400.

select * from zco where co = siitab-id.

if co = '11' and /cotyp = '14'.

j_itab-typ = 'aa' OR 'bb' OR 'cc' OR 'dd' OR 'dd'.

J_ITAB-RCOST_CENTER_ID = 'Y'

co = 'aa' and cotyp = '10'.

j_itab-typ = 'aa'.

else.

messsage e001 with ' values are out of range

endif.

ENDSELECT.

You need to use if condition between select endselect.

Read only

0 Likes
1,353

Hi,

iam getting error in this line.....

j_itab-typ = 'aa' OR 'bb' OR 'cc' OR 'dd' OR 'dd'.

for OR operator its not allwoing this

Anjali

Read only

0 Likes
1,353

Hi

select single * from zco where co = siitab-id.

if co = '11' and /cotyp = '14'.

j_itab-typ = 'aa' OR 'bb' OR 'cc' OR 'dd' OR 'dd'.

J_ITAB-RCOST_CENTER_ID = 'Y'

co = 'aa' and cotyp = '10'.

j_itab-typ = 'aa'.

else.

messsage e001 with ' values are out of range

endif.

Thanks

Venki

Read only

0 Likes
1,353

use like this :

if j_itab-typ = 'aa' OR

if j_itab-typ = 'bb' OR

if j_itab-typ = 'cc' OR

if j_itab-typ = 'dd' .

endif.

endif

endif

endif

Read only

0 Likes
1,353

'OR' and 'AND' are used only for conditional statement and not for ASSIGNMENT.


SELECT * from zco where co = siitab-id.

if co = '11' and cotyp = '14'.
  j_itab-typ1 = 'aa'.
  j_itab-typ2 = 'bb'.
  j_itab-typ3 = 'c'.
  j_itab-typ4 = 'd'.
  J_ITAB-RCOST_CENTER_ID = 'Y'.
  co = 'aa'.
  cotyp = '10'.
  j_itab-typ = 'aa'.
else.
  messsage e001 with ' values are out of range
endif.

ENDSELECT.

Read only

0 Likes
1,353

Hi,

what about my previous condition... if i use this then i will ahve n no of if's

anjali

Read only

0 Likes
1,353

i did not have system right now..

if j_itab-typ1 = 'aa' or j_itab-typ1 = 'bb' or j_itab-typ1 = 'cc'.

endif.

check this condition

Read only

0 Likes
1,353

Hi Anjali,

I don't understand why you are using or when you are assing a value

j_itab-typ = 'aa' OR 'bb' OR 'cc' OR 'dd' OR 'dd' -- this is not correct syntax

the control doesn't know which value you are assingning this is correct when your checking

if j_itab-typ = 'aa' OR 'bb' OR 'cc' OR 'dd' OR 'dd'.-- yOu can do this here you are check whether it has anyone of those value

j_itab-typ = 'aa' OR 'bb' OR 'cc' OR 'dd' OR 'dd' - this doesn't make any sense for me

tell me what you are trying to do

Thanks

venki

Read only

0 Likes
1,353

Is these your conditions

if co = '11' and cotyp = '14'.

and

j_itab-typ1 = 'aa' or j_itab-typ1 = 'bb' or j_itab-typ1 = 'cc' or j_itab-typ1 = 'dd'

if this is. try this


SELECT * from zco where co = siitab-id.
 
if co = '11' and cotyp = '14'.
  if j_itab-typ1 = 'aa' or 
   j_itab-typ1 = 'bb' or
   j_itab-typ1 = 'cc' or
   j_itab-typ1 = 'dd'.
     J_ITAB-RCOST_CENTER_ID = 'Y'.
     co = 'aa'.
     cotyp = '10'.
     j_itab-typ = 'aa'.
  endif.
else.
  messsage e001 with ' values are out of range
endif.
 
ENDSELECT.

Read only

0 Likes
1,353

Hi Ardrian,

-


if co = '11' and cotyp = '14'.

j_itab-typ1 = 'aa'.

j_itab-typ2 = 'bb'.

j_itab-typ3 = 'c'.

j_itab-typ4 = 'd'.

J_ID = 'Y'.

co = 'aa'.

cotyp = '10'.

j_itab-typ = 'aa'.

...................................

in this if my IF condition is true ... it can fall under any one type....

for this can i go head with case and when...

plz suggest me.

Read only

0 Likes
1,353

Hi Venki,

IF my coid is '11' and '14'.

then they types with be either one of it j_itab-typ1 = 'aa'.

j_itab-typ2 = 'bb'.

j_itab-typ3 = 'c'.

j_itab-typ4 = 'd'.

J_ITAB-RCOST_CENTER_ID = 'Y'.

anjali

Read only

0 Likes
1,353

CASE Statment

case j_itab-typ1

when 'aa'.

J_ITAB-RCOST_CENTER_ID = 'Y'.

when 'bb'.

J_ITAB-RCOST_CENTER_ID = 'Y'.

when = 'c'.

J_ITAB-RCOST_CENTER_ID = 'Y'.

when 'd'.

J_ITAB-RCOST_CENTER_ID = 'Y'.

when others.

message

endcase.

Read only

0 Likes
1,353

i am not clear your requirement and why you are using nested select query,

alrady you have jtab,then use loop..

loop at jtab.

get the data from ur ztable comapre with jtab.

endloop.

Read only

Former Member
0 Likes
1,353

hi Anjali

do this may be help you

select * from zco where co = siitab-id.

if co = '11' and cotyp = '14'.

if j_itab-typ = 'aa' OR

j_itab-typ = 'bb' OR

j_itab-typ = 'cc' OR

j_itab-typ = 'dd' OR

j_itab-typ = 'dd'.

J_ITAB-RCOST_CENTER_ID = 'Y'

co = 'aa' .

cotyp = '10'.

j_itab-typ = 'aa'.

else.

messsage e001 with ' values are out of range

endif.

ENDSELECT.