cancel
Showing results for 
Search instead for 
Did you mean: 

how to combine/simplify these multiple IF Statements?

sh4il3sh
Participant
0 Kudos

I have below multiple IF statements which I want to see combined,
I tried using ELSEIF and CASE but its not applicable here because the comparison operator is <> instead of =

Below is the code:

 

        IF <ls_load>-atnam <> 'AA'.
          IF VALUE #( lt_num[ charact = 'AA' ]-value_from OPTIONAL ) IS INITIAL.
            DELETE lt_num WHERE charact = 'AA'.
          ENDIF.
        ENDIF.

        IF <ls_load>-atnam <> 'BB'.
          IF VALUE #( lt_num[ charact = 'BB' ]-value_from OPTIONAL ) IS INITIAL.
            DELETE lt_num WHERE charact = 'BB'.
          ENDIF.
        ENDIF.

        IF <ls_load>-atnam <> 'CC'.
          IF VALUE #( lt_num[ charact = 'CC' ]-value_from OPTIONAL ) IS INITIAL.
            DELETE lt_num WHERE charact = 'CC'.
          ENDIF.
        ENDIF.

 

 

View Entire Topic
Tomas_Buryanek
Active Contributor

Hello, consider creating a method in this case. All three conditions looks same, just parameter 'AA'.