5

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

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
hag
  • 53
  • 1
  • 5

1 Answers1

4

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.
Jagger
  • 10,350
  • 9
  • 51
  • 93
  • Thanks for your replay. In DATA section I wrote the code gt_ranges TYPE RANGE OF bukrs. and received an error: Statement "GT_RANGES" is not defined. Check your spelling. spelling. – hag Jan 24 '17 at 12:39
  • Try to put `DATA` keyword in front of it. Even if the section is named DATA I am not sure if it's added automatically there. – Jagger Jan 24 '17 at 15:00
  • jsdfhksaj
    – hag Jan 25 '17 at 07:43
  • Thanks for your replay. I wrote DATA: as you suggested and it helped. When I put "START-OF-SELECTION. CHECK skb1-bukrs IN gt_ranges." In the START-OF-SELECTION section, then I received the message: "No data was selected" ( It should fetch records). When I put it in "Record processing" section then I received ABAP error. I don't know how to paste the screenshot to the stack overflow comment) – hag Jan 25 '17 at 08:33
  • Please update your question and put the screenshot there. – Jagger Jan 25 '17 at 14:50
  • @hag Get rid of `START-OF-SELECTION` keyword in "5 Record processing" section and it should work. – Jagger Jan 26 '17 at 19:50