Tracks
/
ABAP
ABAP
/
Ejercicios
/
Anidamiento de ITAB
Anidamiento de ITAB

Anidamiento de ITAB

Fácil

Instrucciones

Aprende a combinar los datos de tres tablas internas diferentes en una sola tabla interna de resultado mientras anidas los datos asociados.

Tu clase recibirá tres tablas internas que contienen tres conjuntos de datos completamente diferentes: ARTISTS, ALBUMS y 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.

Los datos de la tabla ARTISTS se muestran a continuación.

ARTIST_ID ARTIST_NAME
1 Godsmack
2 Shinedown

Los datos de la tabla ALBUMS se muestran a continuación.

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

Los datos de la tabla SONGS se muestran a continuación.

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

Tu tarea es devolver una tabla interna con registros que combinen los valores de cada tabla interna de forma estructurada, anidando la tabla interna SONGS dentro de la tabla interna ALBUMS y, por supuesto, anidando la tabla interna ALBUMS dentro de la tabla interna ARTISTS.

La tabla esperada como resultado tiene la siguiente definición:

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

Hay muchas maneras de realizar esta tarea en ABAP. ¿Qué tan eficiente puedes ser al completarla?

Editar en GitHub El enlace se abre en una ventana o una pestaña nuevas
ABAP Exercism

¿Todo listo para empezar Anidamiento de ITAB?

Regístrate en Exercism para aprender y dominar ABAP con 54 ejercicios y mentoría humana real, todo gratis.