I am relatively new to ABAP and so I still need to get used to internal tables and the like, so currently I am a little bit struggling with how to use SQL in ABAP to fill a nested structure.
For example:
TYPES: BEGIN of <<mystructure>>,
someID type sometype,
relatedItemsInDataModel type table of sometabletype,
END of <<mystructure>>.
DATA wa type <<mystructure>>.
<<SELECT INTO STATEMENT>>
DATA(lv_json) = /ui2/cl_json=>serialize( data = wa compress abap_true ... ).
So basically, I've got a table (A) in the dictionary which has a one-to-many relationship to another table (B) and I want to select all items in A and for every item in A I want to select all related items in B for that record.
The reason I wanna do this is because I later on want to convert that data to JSON looking like:
[
{
"someID": "someValue",
"relatedItemsInDataModel": [{...}, {...}]
},
{
"someID": "someValue2",
"relatedItemsInDataModel": [{...}, {...}, {...}, ...]
},
...
]
So, am I approaching this the right way in the first place and how can I achieve what I just described?