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 statement

Former Member
0 Likes
547

hi gurus,

need to seek advice on this.

any way to make the [perform no] only show once? as abap not supports goto, what can i streamline this kind of code so that only show once.

thanks

select single .......

if sy-subrc = 0.

select single ......

if sy-subrc = 0 .

select single ....

if sy-subrc = 0.

perform yes.

else.

perform no.

endif.

else.

perform no.

endif.

else.

perform no.

endif.

1 ACCEPTED SOLUTION
Read only

Pawan_Kesari
Active Contributor
0 Likes
522

if i understood the problem correctly... can this be the solution?


SELECT SINGLE .......
IF sy-subrc = 0.
  SELECT SINGLE ......
  IF sy-subrc = 0 .
    SELECT SINGLE ....
    IF sy-subrc = 0.
      PERFORM yes.
    ENDIF.
  ENDIF.
ENDIF.
IF sy-subrc <> 0 .
  PERFORM no.
ENDIF.

4 REPLIES 4
Read only

Pawan_Kesari
Active Contributor
0 Likes
523

if i understood the problem correctly... can this be the solution?


SELECT SINGLE .......
IF sy-subrc = 0.
  SELECT SINGLE ......
  IF sy-subrc = 0 .
    SELECT SINGLE ....
    IF sy-subrc = 0.
      PERFORM yes.
    ENDIF.
  ENDIF.
ENDIF.
IF sy-subrc <> 0 .
  PERFORM no.
ENDIF.

Read only

0 Likes
522

hi,

thanks and point given.

so i do not need to have else and when sy-subrc <> 0 will all perform no. right?

rgds

Read only

0 Likes
522

if any of select statement fails the corresponding if statenment will not be executed and execution will come to to IF SY-SUBRC <> 0 with non zero sy-subrc value .

so answer is yes.. just remove all ELSEs

Read only

JozsefSzikszai
Active Contributor
0 Likes
522

hi Eliana,

do like this:

PERFORM select_singles.

IF sy-subrc eq 0.

PERFORM yes.

ELSE.

PERFROM no.

ENDIF.

FORM select_singles.

SELECT SINGLE ...

CHECK sy-subrc EQ 0.

SELECT SINGLE ...

CHECK sy-subrc EQ 0.

SELECT SINGLE ...

ENDFORM.

hope this helps

ec