루프를 돌리때 아래와 같이 IN을 사용하기는 불가능한가요?
저걸 어떻게 돌려야 하는거죠? 루프안에 if문 사용해야 하나요? if는 in 사용 가능한것 같은데요
loop at it_zf04 where mark = 'X'
AND STATUS IN ('N' ,'E').
댓글 7
-
보나
2009.10.21 01:16
-
아밥돌이
2009.10.21 01:18
위에 대로 코딩하니 에러가 걸리네요 쩝...
-
MadMax
2009.10.21 01:22
loop at it_zf04 where mark = 'X' and ( status = 'N' or status = 'E' ).
in operation 을 꼭 써야 한다면 range 변수를 잡아서 사용하시면 됩니다.
아래 source 참고하세요.
DATA: BEGIN OF lt_tab OCCURS 0,
key(02),
data(10),
END OF lt_tab.
CLEAR: lt_tab[].
lt_tab-key = '1'. lt_tab-data = 'AAA'. APPEND lt_tab.
lt_tab-key = ' '. lt_tab-data = 'AAA'. APPEND lt_tab.
lt_tab-key = '1'. lt_tab-data = 'BBB'. APPEND lt_tab.
lt_tab-key = ' '. lt_tab-data = 'AAA'. APPEND lt_tab.
lt_tab-key = '1'. lt_tab-data = 'CCC'. APPEND lt_tab.
lt_tab-key = ' '. lt_tab-data = 'AAA'. APPEND lt_tab.
data lr_aa like RANGE OF lt_tab-data WITH HEADER LINE.
lr_aa-sign = 'I'.
lr_aa-option = 'EQ'.
lr_aa-low = 'AAA'.
APPEND lr_aa.
lr_aa-low = 'BBB'.
APPEND lr_aa.
LOOP AT lt_tab WHERE key = '1' AND ( data = 'AAA' OR data = 'BBB' ).
WRITE:/ lt_tab.
ENDLOOP.
LOOP AT lt_tab WHERE key = '1' AND data in lr_aa.
WRITE:/ lt_tab.
ENDLOOP.
결과는 같습니다.
-
보나
2009.10.21 01:30
IN 에서 다시 F1 눌러보시면
log_exp - IN
Syntax
... [operand [NOT] IN] seltab ...
Effect
In a logical expression with language element IN, the conditions of a selection table are checked.
The logical expression checks whether an operand operand meets the conditions of a selection table or, with addition NOT (as of release 6.10), does not meet them.
For operand, you can use data objects, predefined functions (as of release 6.10) and functional methods. As a selection table seltab, you can specify any internal table whose row type matches that of a selection table, or a functional method with the respective type of return value. This especially includes ranges tables. As of release 6.10, the selection table can be of any kind. Before release 6.10, only standard tables were allowed.
For the structure of a selection table, refer to section SELECT-OPTIONS. The evaluation of a selection table requires the table to contain the valid values specified in that section in the columns sign and option. If the selection table contains invalid values, an untreatable exception occurs. If the selection table is initial, the logical expression is always true.
-
쭈니
2009.10.21 01:48
위에 madmax님 말씀처럼 in명령을 쓰려면 range변수를 선언 해야 하는걸로 알고있습니다.
저도 그전에 한번 in명형을 사용할적에.. range변수를 선언하고 사용한적이 있던걸로 기억합니다.
-
아밥돌이
2009.10.21 01:51
아 그렇군요 전 select문에서는 in ( 'A' , 'B' ) 이런식으로 되길래 loop도 되는줄 알았습니다.
감사합니다.
-
보나
2009.10.21 01:58
위 F1 내용처럼 IN을 꼭 사용하려면 seltab 을 쓰시면 됩니다.
select-option, ranges 를 사용하셔도 되고,
Madmax 님의 답변처럼 ...and ( ... or ...) 를 쓰셔도 되구요...
syntax 문제(뿐만 아니라 전부일수도;;;)는 F1 눌러보시면 모든 답이 들어있습니다...
그럼... IN 을 쓰는게 좋을까요? 아니면 ...and (... or ...) 를 쓰는게 좋을까요?
log_exp - Logical Expressions
The result of a logical expression log_exp is either true or false. Since ABAP has no Boolean data type for the values true or false, logical expressions cannot be assigned to data objects. Instead, you use logical expressions to formulate conditions in control structures or other structures. There are logical expressions with relational operators and with other language elements.
Language Elements for Logical Expressions
=, EQ, <>, NE, <, LT, >, GT, <=, LE, >=, GE
CO, CN, CA, NA, CS, NS, CP, NP
BYTE-CO, BYTE-CN, BYTE-CA, BYTE-NA, BYTE-CS, BYTE-NS
O, Z, M
BETWEEN
IS
IN
AND, OR, NOT, ( )
Note
If in a logical expression functional methods are specified as operands, they are executed from left to right before the expression is evaluated. If the logical expressions are concatenated, this applies for every subexpression and not for the entire expression.