Search code examples
abapsap-query

IN operator in check statement


In SQ02 transaction, I want to use the check command. Can I replace the OR operator with another operator, which shorts the command? Is there an operator like IN, which exists in SQL? The check command is something like: CHECK SKB1-BUKRS EQ '1000' or CHECK SKB1-BUKRS EQ '2001' or CHECK SKB1-BUKRS EQ '5221' . Is there an operator like IN, which exists in SQL? CHECK SKB1-BUKRS in ('1000', '2001', '5221')

When I write in the Record Processing section: START-OF-SELECTION. CHECK skb1-bukrs IN gt_ranges.

Section Record Processing

then I receive ABAP error: Error message


Solution

  • I am not an expert when it comes to SQ02 I can see however that there are sections for DATA and INITIALIZATION so the example below should work. IN operator in ABAP (excluding OpenSQL of course) can only be used with ranges.

    Example:

    REPORT zzz.
    
    DATA: gt_ranges TYPE RANGE OF bukrs.
    TABLES: skb1.
    
    INITIALIZATION.
      gt_ranges = VALUE #(
        ( sign = 'I' option = 'EQ' low = '1000' )
        ( sign = 'I' option = 'EQ' low = '2001' )
        ( sign = 'I' option = 'EQ' low = '5221' )
      ).
    
    START-OF-SELECTION.
      CHECK skb1-bukrs IN gt_ranges.