[ABAP] CDS View 입문 — Association과 Annotation으로 데이터 모델 설계하기

AI News · 조회 3

[ABAP] CDS View 입문 — Association과 Annotation으로 데이터 모델 설계하기

개요

CDS(Core Data Services) View는 SAP ABAP에서 데이터 모델을 정의하는 핵심 기술입니다. 기존 SE11 Dictionary View와 달리, SQL 기반 문법으로 Association(관계), Annotation(메타데이터), 계산 필드를 선언적으로 정의할 수 있습니다. S/4HANA와 RAP(RESTful ABAP Programming)의 기반이 되므로, Clean Core 개발의 필수 역량입니다.

이 글에서 다루는 것

핵심 개념

코드 예제

판매 오더(VBAK)와 아이템(VBAP)을 Association으로 연결하는 Basic CDS View 예제입니다.

@AbapCatalog.sqlViewName: 'ZV_SO_HDR'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Sales Order Header View'
@VDM.viewType: #BASIC

define view Z_I_SalesOrderHeader
  as select from vbak
  association [1..*] to Z_I_SalesOrderItem as _Item
    on $projection.SalesOrder = _Item.SalesOrder
{
  key vbeln as SalesOrder,
      erdat as CreationDate,
      erzet as CreationTime,
      ernam as CreatedBy,
      auart as SalesOrderType,
      vkorg as SalesOrganization,
      netwr as NetAmount,
      waerk as Currency,

      // Association - 필요시에만 로딩
      _Item
}

아이템 뷰에 UI Annotation을 추가한 Consumption View 예제입니다.

@AbapCatalog.sqlViewName: 'ZV_SO_ITEM'
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Sales Order Item View'
@VDM.viewType: #BASIC

@UI.headerInfo: {
  typeName: 'Sales Order Item',
  typeNamePlural: 'Sales Order Items'
}

define view Z_I_SalesOrderItem
  as select from vbap
{
      @UI.lineItem: [{ position: 10 }]
  key vbeln as SalesOrder,

      @UI.lineItem: [{ position: 20 }]
  key posnr as SalesOrderItem,

      @UI.lineItem: [{ position: 30 }]
      matnr as Material,

      @Semantics.quantity.unitOfMeasure: 'OrderUnit'
      kwmeng as OrderQuantity,
      vrkme as OrderUnit,

      @Semantics.amount.currencyCode: 'Currency'
      netwr as NetAmount,
      waerk as Currency
}

실무 팁

자세한 내용은 본문에서

참고 자료


📌 본 게시물은 AI(Claude)가 공개된 자료를 기반으로 자동 생성한 콘텐츠입니다. 기술 내용의 정확성은 SAP 공식 문서 와 교차 확인하시기 바랍니다.

™ SAP, S/4HANA, ABAP, Fiori, SAP BTP 등은 SAP SE 또는 그 계열사의 등록 상표입니다. 본 사이트는 SAP SE 와 공식적인 관련이 없는 비공식 학습 자료 입니다.

📧 저작권 침해 / 오류 / 콘텐츠 신고: btpstacks.com 의 "문의" 메뉴를 이용해주세요.