본문 바로가기
🧑‍💼 SAP/ABAP

[SAP ABAP] 비교 연산자(=, >, >=, <, >=, <> 또는 EQ, GT, GE, LT, LE, NE)

by Jay Din 2023. 12. 26.
728x90
반응형

비교 연산자

abap 에서는 비교 연산자를 =, >, >=, <, >=, <> 또는 EQ(Equals), GT(Greater Than), GE(Greater Than or Equal To), LT(Less Than), LE(Less Than or Equal To), NE(Not Equal) 로 표기합니다.

EQ A = B A와 B가 같다
NE A <> B A와 B가 다르다
LT A < B A보다 B가 작
GT A > B A가 B보다 크다
LE A <= B A가 B보다 작거나 같다
GE A >= B A가 B보다 크거나 같다

 

비교 연산자 사용 예시

DATA lv_number1 TYPE i VALUE 10.
DATA lv_number2 TYPE i VALUE 20.

" 같음
IF lv_number1 EQ lv_number2.
  WRITE 'lv_number1 is equal to lv_number2'.
ELSE.
  WRITE 'lv_number1 is not equal to lv_number2'.
ENDIF.

" 크다
IF lv_number1 GT lv_number2.
  WRITE 'lv_number1 is greater than lv_number2'.
ELSE.
  WRITE 'lv_number1 is not greater than lv_number2'.
ENDIF.

" 크거나 같음
IF lv_number1 GE lv_number2.
  WRITE 'lv_number1 is greater than or equal to lv_number2'.
ELSE.
  WRITE 'lv_number1 is not greater than or equal to lv_number2'.
ENDIF.

" 작다
IF lv_number1 LT lv_number2.
  WRITE 'lv_number1 is less than lv_number2'.
ELSE.
  WRITE 'lv_number1 is not less than lv_number2'.
ENDIF.

" 작거나 같음
IF lv_number1 LE lv_number2.
  WRITE 'lv_number1 is less than or equal to lv_number2'.
ELSE.
  WRITE 'lv_number1 is not less than or equal to lv_number2'.
ENDIF.

" 다르다
IF lv_number1 NE lv_number2.
  WRITE 'lv_number1 is not equal to lv_number2'.
ELSE.
  WRITE 'lv_number1 is equal to lv_number2'.
ENDIF.
728x90
반응형