세 개의 서로 다른 인터널 테이블에 담긴 데이터를 하나의 결과 인터널 테이블로 결합하는 방법을 배워요. 이때 관련된 데이터는 중첩해서 넣어요.
여러분이 작성할 클래스에는 서로 완전히 다른 세 가지 데이터셋, 즉 ARTISTS, ALBUMS, SONGS를 담은 세 개의 인터널 테이블이 주어져요.
TYPES: BEGIN OF artists_type,
artist_id TYPE string,
artist_name TYPE string,
END OF artists_type.
TYPES: artists TYPE STANDARD TABLE OF artists_type WITH KEY artist_id.
TYPES: BEGIN OF albums_type,
artist_id TYPE string,
album_id TYPE string,
album_name TYPE string,
END OF albums_type.
TYPES: albums TYPE STANDARD TABLE OF albums_type WITH KEY artist_id album_id.
TYPES: BEGIN OF songs_type,
artist_id TYPE string,
album_id TYPE string,
song_id TYPE string,
song_name TYPE string,
END OF songs_type.
TYPES: songs TYPE STANDARD TABLE OF songs_type WITH KEY artist_id album_id song_id.
ARTISTS 테이블의 데이터는 다음과 같아요.
| ARTIST_ID | ARTIST_NAME |
|---|---|
| 1 | Godsmack |
| 2 | Shinedown |
ALBUMS 테이블의 데이터는 다음과 같아요.
| ARTIST_ID | ALBUM_ID | ALBUM_NAME |
|---|---|---|
| 1 | 1 | Faceless |
| 1 | 2 | When Lengends Rise |
| 2 | 1 | The Sound of Madness |
| 2 | 2 | Planet Zero |
SONGS 테이블의 데이터는 다음과 같아요.
| ARTIST_ID | ALBUM_ID | SONG_ID | SONG_NAME |
|---|---|---|---|
| 1 | 1 | 1 | Straight Out Of Line |
| 1 | 1 | 2 | Changes |
| 1 | 2 | 1 | Bullet Proof |
| 1 | 2 | 2 | Under Your Scars |
| 2 | 1 | 1 | Second Chance |
| 2 | 1 | 2 | Breaking Inside |
| 2 | 2 | 1 | Dysfunctional You |
| 2 | 2 | 2 | Daylight |
여러분이 할 일은 각 인터널 테이블의 값을 구조적으로 결합한 레코드로 이루어진 인터널 테이블을 반환하는 거예요. 이때 SONGS 인터널 테이블은 ALBUMS 인터널 테이블 안에, 그리고 ALBUMS 인터널 테이블은 ARTISTS 인터널 테이블 안에 중첩해요.
반환해야 할 테이블의 정의는 다음과 같아요.
TYPES: BEGIN OF song_nested_type,
song_id TYPE string,
song_name TYPE string,
END OF song_nested_type.
TYPES: BEGIN OF album_song_nested_type,
album_id TYPE string,
album_name TYPE string,
songs TYPE STANDARD TABLE OF song_nested_type WITH KEY song_Id,
END OF album_song_nested_type.
TYPES: BEGIN OF artist_album_nested_type,
artist_id TYPE string,
artist_name TYPE string,
albums TYPE STANDARD TABLE OF album_song_nested_type WITH KEY album_id,
END OF artist_album_nested_type.
TYPES: nested_data TYPE STANDARD TABLE OF artist_album_nested_type WITH KEY artist_id.
ABAP에서 이 작업을 해내는 방법은 여러 가지예요. 이 작업을 얼마나 효율적으로 끝낼 수 있을까요?