[SAP ABAP] CDS View with Parameter, Currency Conversion (SQL Code 719 Error)

2024. 12. 12. 16:01·SAP ABAP

CDS View와 Dictionary View 비교하기

생성 방식

Dictionary View: SAP GUI 또는 Eclipse에서 생성 가능

CDS View : Eclipse 또는 SAP HANA Studio에서 생성 가능 (SAP GUI 에서 생성 불가능)

 

주요 기능의 차이

기능 Dictionary View CDS View
Annotations 정의 불가 메타데이터 보강을 위한 주석 제공
집계 기능 불가능 가능
Grouping 불가능 가능
Join 기본 Join만 가능 Join, Union 모두 사용 가능

 

CDS View의 추가 기능

- Case Expression 사용 가능

- 데이터 필더링과 컬럼 계산을 위한 입력 파라미터 허용

- 연산자 사용 가능

- CDS 주석을 사용한 OData 서비스 생성 가능

 

 

ODatat 서비스?

클라이언트와 서버 간의 데이터 통신을 위한 표준화된 프로토콜

웹 서비스를 위한 데이터 모델, 메타 데이터, 쿼리 및 데이터 수정 기능을 제공하며 , 클라이언트 애플리케이션이 서버에서 데이터를 쉽게 가져오고 조작할 수 있게 도움

OData는 REST 아키텍쳐 스타일을 따르며, HTTP를 통해 통신하며 xml또는 jason과 같은 표준 데이터 형식을 사용한다.

 

CDS View 예시

CDS View 예시 1

@AbapCatalog.sqlViewName: 'Z_TEST'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Sales order header interface'
@Metadata.ignorePropagatedAnnotations: true
define view z_test_1
  as select from vbak
{
  key vbeln as sonumber,
      erdat,
      auart,
      netwr,
      waerk,
      vkorg,
      vtweg,
      spart,
      kunnr,
      case bestk
      when 'A' then 'Not yet processed'
      when 'B' then 'Partically processed'
      when 'C' then 'Completely processed'
      else 'Not Relevant'
      end   as dlv_comfirmation,

      currency_conversion(
       amount => netwr,
       source_currency => waerk,
       target_currency => cast( 'INR' as waerk ),
       exchange_rate_date => erdat
      )     as price_inr


}

 

CDS View 예시 2 with Parameter

define view zfkr003_test_2 
with parameters p_vbeln : vbeln_va
as select from vbap

 

where 절에서 입력된 파라미터와 일치하는 필드의 레코드만 반환하도록 결과를 필터링한다.

where vbeln = $parameters.p_vbeln

 

전체 코드

@AbapCatalog.sqlViewName: 'Z_TEST2'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'CDS View with parameter'
@Metadata.ignorePropagatedAnnotations: true
define view z_test_2 
with parameters p_vbeln : vbeln_va // vbeln_va 타입을 가진 파라미터
as select from vbap
{
    key vbeln,
    key posnr,
        matnr,
        arktx,
        kwmeng,
        vrkme
    
} where vbeln = $parameters.p_vbeln

 

 

Currency Conversion

통화 변환을 수행해서 한화로 가격을 표시하는 기능을 제공한다.

      currency_conversion(
       amount => netwr,
       source_currency => waerk,
       target_currency => cast( 'KRW' as waerk ),
       exchange_rate_date => erdat,
      error_handling => 'SET_TO_NULL' //Add error handling
      )     as price_inr

 

error_handling

error_handling => 'SET_TO_NULL' //Add error handling

 

에러 핸들링이 없으면 SQL Code 719 에러가 나니 써주기로 한다.

 

전체코드

@AbapCatalog.sqlViewName: 'Z_TEST'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Sales order header interface'
@Metadata.ignorePropagatedAnnotations: true
define view z_test_1
  as select from vbak
{
  key vbeln as sonumber,
      erdat,
      auart,
      netwr,
      waerk,
      vkorg,
      vtweg,
      spart,
      kunnr,
      case bestk
      when 'A' then 'Not yet processed'
      when 'B' then 'Partically processed'
      when 'C' then 'Completely processed'
      else 'Not Relevant'
      end   as dlv_comfirmation,

      currency_conversion(
       amount => netwr,
       source_currency => waerk,
       target_currency => cast( 'KRW' as waerk ),
       exchange_rate_date => erdat,
      error_handling => 'SET_TO_NULL' //Add error handling
      )     as price_inr


}

728x90
저작자표시 비영리 변경금지 (새창열림)

'SAP ABAP' 카테고리의 다른 글

[SAP ABAP] ALV 만들기 - PAI와 PBO에 대해 알아보자  (0) 2025.04.15
[SAP] CDS의 Associations 이해하기 1  (2) 2025.04.12
[SAP] Code-To-Data와 Data-To-Code 비교 실습하기 (2편)  (0) 2025.04.07
[SAP] Code-To-Data와 Data-To-Code 비교 실습하기 (1편)  (0) 2025.04.07
[SAP/ABAP ]SAP의 기본 : 3계층 구조 (Three-Tier Architecture) , S/4 HANA 동작 원리  (0) 2025.02.19
'SAP ABAP' 카테고리의 다른 글
  • [SAP] CDS의 Associations 이해하기 1
  • [SAP] Code-To-Data와 Data-To-Code 비교 실습하기 (2편)
  • [SAP] Code-To-Data와 Data-To-Code 비교 실습하기 (1편)
  • [SAP/ABAP ]SAP의 기본 : 3계층 구조 (Three-Tier Architecture) , S/4 HANA 동작 원리
지니어스팍
지니어스팍
  • 지니어스팍
    생각하고 이해하고 정리하기
    지니어스팍
  • 전체
    오늘
    어제
    • 분류 전체보기 (101)
      • SAP ABAP (7)
      • FI,CO 모듈 (3)
        • 전산세무회계 (3)
      • 알고리즘 (35)
        • 자료구조 (5)
        • 문제 해결 전략 (2)
        • Java 알고리즘 (25)
        • JavaScript 알고리즘 (0)
      • 기사 스크랩 (12)
        • SSAFY 기자 (19)
      • Front-end (7)
        • React (7)
      • 기타 (11)
        • Android app 만들기 (2)
        • JAVA (2)
        • Git (2)
        • 그래픽 디자인 제작 (4)
        • Back-end (0)
        • Study (1)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    맥북vsc
    adobe PhotoShop
    unlink '/usr/local/bin/code'
    EACCES: permission denied
    ReactError
    상태관리
    jdk설치
    git init 끊기
    eclipse
    일러스트레이터
    React
    eclipse 설치
    git bash
    jdk
    missing in props validation
    Java
    암살포스터
    2d 디자인
    github
    code.
    포토샵
    push 에러
    합성
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
지니어스팍
[SAP ABAP] CDS View with Parameter, Currency Conversion (SQL Code 719 Error)
상단으로

티스토리툴바