이번 글에서는 ABAP 숫자 타입별 연산 실습과 함수 호출 시 대소문자 구분으로 인해 발생하는 CX_SY_DYN_CALL_ILLEGAL_FUNC 오류의 원인과 해결 방법을 정리했다.
📐 숫자 타입별 계산 실습
1. 정수 타입 i 연산
REPORT z02_04.
DATA gv_int1 TYPE i VALUE 2.
DATA gv_int2 TYPE i VALUE 3.
DATA gv_iresult TYPE i.
gv_iresult = gv_int1 * gv_int2.
WRITE :/ '1: ', gv_iresult. "6
ADD 1 TO gv_iresult."6+1
WRITE :/ '2: ', gv_iresult. "7
2. 고정 소수점 타입 p 연산
고정 소수점(p)는 자릿수를 명시할 수 있어서 정확한 소수점 계산이 필요한 경우 유용하다. 고정 소수점 타입은 내부적으로 정수처럼 처리되지만 출력 시 소수점 자릿수가 보장된다.
DATA gv_packl TYPE p DECIMALS 2 VALUE '2.17'.
DATA gv_pack2 TYPE p DECIMALS 2 VALUE '5.43'.
DATA gv_presult TYPE p DECIMALS 2.
gv_presult = gv_pack2 / gv_pack2.
WRITE :/ '3: ', gv_presult. "1.00
MULTIPLY gv_presult by gv_pack2.
WRITE :/ '4: ', gv_presult. "5.43
DIVIDE gv_presult BY gv_pack1.
WRITE :/ '5: ', gv_presult. "2.50
3. 부동 소수점 타입 f 연산 및 변환
부동 소수점은 정밀도 손실이 발생할 수 있으므로 출력 시 가독성을 위해 FLTP_CHAR_CONVERSION
함수를 호출하여 문자열로 변환해주는 처리가 필요하다. (선택사항)
DATA gv_float1 TYPE f VALUE '1.337'.
DATA gv_float2 TYPE f VALUE '2.7'.
DATA gv_fresult TYPE f.
DATA gv_cresult TYPE c LENGTH 16.
gv_fresult = gv_float1 * gv_float2.
WRITE :/ '6: ', gv_fresult. "3.6099000000000001E+00
CALL FUNCTION 'FLTP_CHAR_CONVERSION' "case-sensitive
EXPORTING
decim = 2
input = gv_fresult
IMPORTING
flstr = gv_cresult.
WRITE :/ '7: ', gv_cresult. "3.61
🚧 CX_SY_DYN_CALL_ILLEGAL_FUNC 에러 발생
처음에 함수명을 소문자로 작성했더니 다음과 같은 오류가 발생했다.
[확인할 메세지]
Funcion module "fltp\_char\_conversion" not found.
No function module can be found named "fltp\_char\_conversion" however. All function modules are listed in Function Library(SE37).
Possible Causes:
a) Wrong name specified. Pay particular attention to whether the name is case-sensitive and to underscores ("_").
🔍 CX_SY_DYN_CALL_ILLEGAL_FUNC 의미 해석
CX
→ Class Exception : 예외 클래스(exception class)를 나타내는 표준 접두사SY
→ System : 시스템 수준에서 발생한 예외 클래스DYN
→ Dynamic : 동적 호출 관련CALL
: 함수 호출ILLEGAL
: 잘못된FUNC
: Function module
즉, 시스템 수준에서 동적으로 호출된 함수(Function module)의 이름이 잘못되어 발생한 예외 클래스라는 뜻이다. Function Builder(SE37)에서 함수를 검색해보니 FLTP_CHAR_CONVERSION 함수가 존재하며 활성화되어 있는 상태이다. 함수는 생성되어 있고 다른 게 문제라는 말이다.
✅ CX_SY_DYN_CALL_ILLEGAL_FUNC 해결
SE37에서 소문자로 검색해도 자동으로 대문자로 변환되어 보여진다. 하지만 소스코드 내에서 함수를 동적으로 호출할 땐 대소문자 구분을 해줘야 한다.
명확한 이유를 알고 싶어서 구글링 끝에 공식문서에서 case에 대한 설명을 찾았다. 생각한대로 대소문자를 다르게 인식하는 문제였고, 동적 프로그래밍의 경우 대문자를 사용하는 것이 필수라고 나와 있다.
In contrast to many other modern programming languages, ABAP is not case-sensitive for ABAP words (tokens of an ABAP statement that express its semantics; either ABAP keywords or additions) nor for operators and names of operands. The only exception is dynamic programming, where the names of operands usually have to be specified in uppercase.
'SAP' 카테고리의 다른 글
🔄 STATICS vs. DATA – ABAP 변수 선언의 차이점 비교 정리 (0) | 2025.06.09 |
---|---|
ABAP 시스템 변수로 날짜와 시간 다루기 - sy-datum, sy-datlo, sy-datar, sy-uzeit, sy-timlo (0) | 2025.05.30 |
ABAP Fixed Point Arithmetic에 따른 TYPE P 계산 차이 완전 정리 (0) | 2025.05.27 |
ABAP CX_SY_CONVERSION_OVERFLOW - Packed Type(P) 변수 오버플로우 에러 해결 (1) | 2025.05.26 |
BP (Business Partner) | 비즈니스 파트너 마스터 데이터 관리 (1) | 2025.04.10 |