SAP ABAP SELECT OPTION
SELECT-OPTION은 대표적인 RANGE변수 중에 하나이다.
여기서 자산클래스에 기본값을 세팅해 보자
SELECT-OPTION은 헤더라인을 가진 인터널테이블이고
RANGE변수처럼 4가지 구조로 이루어진다.
버튼을 누르면 이런 화면이 나오는데,
RANGE변수임을 이용하여 INITIAL 값을 세팅하면
이 화면에 조건을 디폴트로 입력할 수 있다.
RANGE 변수는 4가지 구조로 이루어져 있다.
-SIGN : I (포함) ,E(제외)
-OPTION: EQ(같다) GE(이상) LE(이하) GT(초과) LT(미만) NE(같지않다) BT(사이값) CP(패턴포함)
-LOW :최소값
-HIGH : 최대값
CLEAR S_ANLKL. REFRESH S_ANLKL.
S_ANLKL-SIGN = 'E'.
S_ANLKL-OPTION = 'EQ'.
S_ANLKL-LOW = '1000'.
APPEND S_ANLKL.
S_ANLKL-LOW = '1100'.
APPEND S_ANLKL.
S_ANLKL-SIGN = 'E'.
S_ANLKL-OPTION = 'EQ'.
S_ANLKL-LOW = '1000'.
APPEND S_ANLKL.
S_ANLKL-LOW = '1100'.
APPEND S_ANLKL.
범위로 제외할 경우의 로직
CLEAR S_ANLKL. REFRESH S_ANLKL.
S_ANLKL-SIGN = 'E'.
S_ANLKL-OPTION = 'CP'.
S_ANLKL-LOW = '1000'.
* APPEND S_ANLKL.
S_ANLKL-HIGH = '2000'.
APPEND S_ANLKL.
S_ANLKL-SIGN = 'E'.
S_ANLKL-OPTION = 'CP'.
S_ANLKL-LOW = '1000'.
* APPEND S_ANLKL.
S_ANLKL-HIGH = '2000'.
APPEND S_ANLKL.
범위 포함일때의 로직
CLEAR S_ANLKL. REFRESH S_ANLKL.
S_ANLKL-SIGN = 'I'.
S_ANLKL-OPTION = 'BT'.
S_ANLKL-LOW = '2000'.
S_ANLKL-HIGH = '6000'.
APPEND S_ANLKL.
S_ANLKL-SIGN = 'I'.
S_ANLKL-OPTION = 'BT'.
S_ANLKL-LOW = '2000'.
S_ANLKL-HIGH = '6000'.
APPEND S_ANLKL.
해당 로직의 결과값
아래는 참고용 코드이다.
TABLES : ANLA.
DATA: BEGIN OF GS_DATA,
BUKRS TYPE ANLA-BUKRS,
ANLKL TYPE ANLA-ANLKL,
ANLN1 TYPE ANLA-ANLN1,
END OF GS_DATA.
DATA : GT_DATA LIKE TABLE OF GS_DATA.
PARAMETERS : P_BUKRS TYPE ANLA-BUKRS.
SELECT-OPTIONS: S_ANLKL FOR ANLA-ANLKL ,
S_ANLN1 FOR ANLA-ANLN1 .
*----------------------------------------------------------------
INITIALIZATION.
*----------------------------------------------------------------
CLEAR S_ANLKL. REFRESH S_ANLKL.
S_ANLKL-SIGN = 'I'.
S_ANLKL-OPTION = 'BT'.
S_ANLKL-LOW = '2000'.
S_ANLKL-HIGH = '6000'.
APPEND S_ANLKL.
*----------------------------------------------------------------
START-OF-SELECTION.
*----------------------------------------------------------------
SELECT ANLKL ANLN1
FROM ANLA
INTO CORRESPONDING FIELDS OF TABLE GT_DATA
WHERE ANLN1 IN S_ANLN1
AND ANLKL IN S_ANLKL
AND BUKRS = P_BUKRS.
*----------------------------------------------------------------
END-OF-SELECTION.
*----------------------------------------------------------------
WRITE : '회사코드' , P_BUKRS, / , /.
WRITE : '클래스' , '자산'.
SORT GT_DATA BY ANLKL.
LOOP AT GT_DATA INTO GS_DATA .
WRITE : / GS_DATA-ANLKL , GS_DATA-ANLN1.
ENDLOOP.
LOOP AT GT_DATA INTO GS_DATA .
WRITE : / GS_DATA-ANLKL , GS_DATA-ANLN1.
ENDLOOP.
DATA: BEGIN OF GS_DATA,
BUKRS TYPE ANLA-BUKRS,
ANLKL TYPE ANLA-ANLKL,
ANLN1 TYPE ANLA-ANLN1,
END OF GS_DATA.
DATA : GT_DATA LIKE TABLE OF GS_DATA.
PARAMETERS : P_BUKRS TYPE ANLA-BUKRS.
SELECT-OPTIONS: S_ANLKL FOR ANLA-ANLKL ,
S_ANLN1 FOR ANLA-ANLN1 .
*----------------------------------------------------------------
INITIALIZATION.
*----------------------------------------------------------------
CLEAR S_ANLKL. REFRESH S_ANLKL.
S_ANLKL-SIGN = 'I'.
S_ANLKL-OPTION = 'BT'.
S_ANLKL-LOW = '2000'.
S_ANLKL-HIGH = '6000'.
APPEND S_ANLKL.
*----------------------------------------------------------------
START-OF-SELECTION.
*----------------------------------------------------------------
SELECT ANLKL ANLN1
FROM ANLA
INTO CORRESPONDING FIELDS OF TABLE GT_DATA
WHERE ANLN1 IN S_ANLN1
AND ANLKL IN S_ANLKL
AND BUKRS = P_BUKRS.
*----------------------------------------------------------------
END-OF-SELECTION.
*----------------------------------------------------------------
WRITE : '회사코드' , P_BUKRS, / , /.
WRITE : '클래스' , '자산'.
SORT GT_DATA BY ANLKL.
LOOP AT GT_DATA INTO GS_DATA .
WRITE : / GS_DATA-ANLKL , GS_DATA-ANLN1.
ENDLOOP.
LOOP AT GT_DATA INTO GS_DATA .
WRITE : / GS_DATA-ANLKL , GS_DATA-ANLN1.
ENDLOOP.
Tags:
SAP ABAP