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: 

if statement

Former Member
0 Kudos

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

Pawan_Kesari
Active Contributor
0 Kudos

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

Pawan_Kesari
Active Contributor
0 Kudos

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.

0 Kudos

hi,

thanks and point given.

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

rgds

0 Kudos

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

JozsefSzikszai
Active Contributor
0 Kudos

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