[ZEDU] CDS View → Fiori Elements Web UI 정리

1. 목표

ZEDU_COURSE, ZEDU_ENROLL 테이블 데이터를 CDS View로 조회하고, Service Binding을 통해 Fiori Elements Preview 화면으로 확인한다.

ZEDU_COURSE / ZEDU_ENROLL
        ↓
ZI_ZEDU_ENROLL        CDS View
        ↓
ZUI_ZEDU_ENROLL       Service Definition
        ↓
ZUI_ZEDU_ENROLL_O4    Service Binding
        ↓
Fiori Elements Preview

2. CDS View 생성

ADT에서 패키지 ZPKG_ZEDU 선택 후 생성했다.

ZPKG_ZEDU
→ New
→ Other ABAP Repository Object
→ Core Data Services
→ Data Definition

입력값은 아래처럼 잡았다.

Name        : ZI_ZEDU_ENROLL
Description : ZEDU Enrollment CDS View
Package     : ZPKG_ZEDU
Template    : Define View Entity

생성된 CDS 파일에 아래 내용을 작성했다.

@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'ZEDU 교육 신청 조회'
@Metadata.allowExtensions: true
@UI.headerInfo: {
  typeName: '교육신청',
  typeNamePlural: '교육신청목록',
  title: {
    type: #STANDARD,
    value: 'EnrollId'
  },
  description: {
    value: 'CourseName'
  }
}
define root view entity ZI_ZEDU_ENROLL
  as select from zedu_enroll as Enroll
    inner join zedu_course as Course
      on Enroll.course_id = Course.course_id
{
  @UI.lineItem: [{ position: 10, label: '신청ID' }]
  @UI.selectionField: [{ position: 10 }]
  key Enroll.enroll_id as EnrollId,

  @UI.lineItem: [{ position: 20, label: '과정ID' }]
  @UI.selectionField: [{ position: 20 }]
  Enroll.course_id as CourseId,

  @UI.lineItem: [{ position: 30, label: '과정명' }]
  @UI.selectionField: [{ position: 30 }]
  Course.course_name as CourseName,

  @UI.lineItem: [{ position: 40, label: '교육유형' }]
  Course.course_type as CourseType,

  @UI.lineItem: [{ position: 50, label: '사번' }]
  @UI.selectionField: [{ position: 40 }]
  Enroll.emp_id as EmpId,

  @UI.lineItem: [{ position: 60, label: '성명' }]
  Enroll.emp_name as EmpName,

  @UI.lineItem: [{ position: 70, label: '부서' }]
  Enroll.dept_name as DeptName,

  @UI.lineItem: [{ position: 80, label: '상태' }]
  @UI.selectionField: [{ position: 50 }]
  Enroll.status as Status,

  @UI.lineItem: [{ position: 90, label: '상태명' }]
  cast(
    case Enroll.status
      when 'A' then '신청'
      when 'C' then '이수'
      when 'N' then '미이수'
      when 'X' then '취소'
      else '기타'
    end as abap.char(10)
  ) as StatusText,

  @UI.lineItem: [{ position: 100, label: '신청일' }]
  @UI.selectionField: [{ position: 60 }]
  Enroll.req_date as ReqDate,

  @UI.lineItem: [{ position: 110, label: '이수일' }]
  Enroll.comp_date as CompDate,

  @UI.lineItem: [{ position: 120, label: '생성자' }]
  Enroll.created_by as CreatedBy,

  @UI.lineItem: [{ position: 130, label: '생성일' }]
  Enroll.created_date as CreatedDate
}

저장/활성화는 아래 단축키로 처리했다.

Ctrl + S
Ctrl + F3

3. CDS 데이터 확인

CDS 활성화 후 ADT에서 Data Preview를 실행했다.

ZI_ZEDU_ENROLL
→ 우클릭
→ Open With
→ Data Preview

여기서 ZEDU_INIT_DATA로 넣어둔 교육 신청 데이터가 조회되면 CDS는 정상이다.


4. Service Definition 생성

CDS View를 OData로 노출하기 위해 Service Definition을 생성했다.

ZPKG_ZEDU
→ New
→ Other ABAP Repository Object
→ Business Services
→ Service Definition

입력값:

Name        : ZUI_ZEDU_ENROLL
Description : ZEDU Enrollment Service Definition
Package     : ZPKG_ZEDU

소스:

@EndUserText.label: 'ZEDU 교육 신청 서비스'
define service ZUI_ZEDU_ENROLL {
  expose ZI_ZEDU_ENROLL as Enrollment;
}

저장 후 활성화했다.

Ctrl + S
Ctrl + F3

5. Service Binding 생성

Fiori Elements Preview로 띄우기 위해 Service Binding을 생성했다.

ZPKG_ZEDU
→ New
→ Other ABAP Repository Object
→ Business Services
→ Service Binding

입력값:

Name               : ZUI_ZEDU_ENROLL_O4
Description        : ZEDU Enrollment OData V4 UI
Service Definition : ZUI_ZEDU_ENROLL
Binding Type       : OData V4 - UI
Package            : ZPKG_ZEDU

생성 후 아래 순서로 처리했다.

Activate
→ Publish

정상 상태는 아래처럼 확인했다.

Binding Status : Published
Service Status : Active

6. Fiori Elements Preview 실행

Service Binding 화면에서 Entity Enrollment를 선택하고 Preview를 실행했다.

ZUI_ZEDU_ENROLL_O4
→ Entity: Enrollment
→ Preview

브라우저 로그인 정보:

Client   : 001
User     : DEVELOPER
Password : ABAPtr2023#00

Preview 화면에서 Go 버튼을 누르면 교육 신청 목록이 조회된다.


7. 현재까지 생성된 객체

ZPKG_ZEDU
├─ CDS View
│  └─ ZI_ZEDU_ENROLL
│
├─ Service Definition
│  └─ ZUI_ZEDU_ENROLL
│
└─ Service Binding
   └─ ZUI_ZEDU_ENROLL_O4

Profile picture

@shyun_im

COMMENTS

댓글

GitHub 계정으로 로그인하면 댓글을 남길 수 있습니다.

댓글을 불러오는 중입니다.