[SAP ABAP] Data Types 및 변수 선언

🌼JOYGARDEN·2025년 1월 7일
1

SAP ABAP

목록 보기
1/19

ABAP의 Data Types ❓

ABAP의 Data Type에는
1. Predefined ABAP Type
2. Local Data Type in Program
3. Global Data Type in ABAP Dictionary
이렇게 3가지 그룹의 Data Type이 있다.

 

Predefined ABAP Type은 Kernel 레벨에서 정의되어 있는 기본 데이터 타입이다.
1. Complete
2. Incomplete
이렇게 두 종류가 있다.

Complete는 완성형 Data Types로 Data Type의 길이, 모양이 정해져 있어서 사용자가 정의 할 필요가 없다.

Complete ABAP Standard Data Types

Standard Types               Description

D                            Date, format : YYYYMMDD, length 8 (fixed)
T                            Time, format : HHMMSS,   length 6 (fixed)
I, INT8                      Integer, length 4(for I) , or length 8(for INT8)
F                            Floating point number, length 8 (fixed)
STRING                       Dynamic length character string (길이 제한 X)
XSTRING                      Dynamic length byte sequence
DECFLOAT16                   전체길이 8 바이트(소수점 자리 16자리로 fix)
DECFLOAT 34                  전체길이 16 바이트 (소수점 자리 34자리로 fix) 

 

Incomplete ABAP Standard Data Type

Incomplete는 미완성이므로 길이를 정해줘야 한다.

Standard Types               Description

C                            Character string
N                            Numerical character (숫자를 취급하기 위한 문자 필드)
                             -> 산술적인 목적 X, 날짜, 시간, 순번 등
X                            HeXadecimal string
P                            Packed number (정수, 소수)

 

Local Data Types

ABAP Program 내에서 Predefined ABAP Type을 이용하여 local에 생성하는 것을 의미한다.
-> Predefined ABAP Type을 조합하여 여러 필드가 추가된 Structure 타입을 정의하여 사용 가능

타입 선언
TYPES lv_c_type TYPE c LENGTH 8.
TYPES lv_p_type TYPE p LENGTH 3 DECIMALS 2.   " 2자리는 소수 사용

TYPES : BEGIN OF lt_ex,
	col1 TYPE c,
    col2 TYPE i,
    col3 TYPE d,
    END OF lt_ex.
    
* 이렇게 체인을 사용하여 local type 선언 가능.

타입 사용
DATA gv_c TYPE lv_c_type.

여기서 DECIMALS n(숫자)는 Data Type P에서만 가능하며 1~14 사이의 소수 자리 수를 설정한다.
P Type : Packed numbers (소수 자리를 허용하는 Type)

 

Global Data Type in ABAP Dictionary

모든 ABAP Program에서 사용할 수 있는 Type이다.
즉 SE11(ABAP Dictionary)에서 생성하는 Type은 모든 ABAP Program에서 변수를 선언할 때 데이터 타입으로 사용할 수 있다.

Global Types

Data Element  - Elementary Type
Structure     - Structure Type
Table Type    - Type for Internal Tables
profile
블로그 내용은 Easy ABAP과 SAP에서 교육용으로 제공하는 자료를 참고하였습니다.

0개의 댓글