Parcours
/
ABAP
ABAP
/
Exercices
/
Imbrication des ITAB
Imbrication des ITAB

Imbrication des ITAB

Facile

Instructions

Apprends à combiner les données de trois tables internes différentes en une seule table interne de résultat, tout en imbriquant les données associées.

Ta classe recevra trois tables internes qui contiennent trois jeux de données complètement différents : ARTISTS, ALBUMS et 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.

Les données de la table ARTISTS sont les suivantes.

ARTIST_ID ARTIST_NAME
1 Godsmack
2 Shinedown

Les données de la table ALBUMS sont les suivantes.

ARTIST_ID ALBUM_ID ALBUM_NAME
1 1 Faceless
1 2 When Lengends Rise
2 1 The Sound of Madness
2 2 Planet Zero

Les données de la table SONGS sont les suivantes.

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

Ta tâche consiste à renvoyer une table interne dont les enregistrements combinent de manière structurée les valeurs de chaque table interne, en imbriquant la table interne SONGS dans la table interne ALBUMS et, bien sûr, en imbriquant la table interne ALBUMS dans la table interne ARTISTS.

La table de retour attendue est définie comme suit :

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.

Bonus

Il existe de nombreuses façons d'accomplir cette tâche en ABAP. Avec quelle efficacité peux-tu la mener à bien ?

Modifie via GitHub Le lien s'ouvre dans une nouvelle fenêtre ou un nouvel onglet
ABAP Exercism

Prêt à commencer Imbrication des ITAB ?

Inscris-toi sur Exercism pour apprendre et maîtriser ABAP avec 54 exercices, et un vrai mentorat humain, le tout gratuitement.