You can use a single extract to store entries from more than one database table, since the records in an extract can have different structures.
Assume the following program is linked to the logical database F1S.
NODES: spfli, sflight, sbook.
FIELD-GROUPS: header, flight_info, flight_booking.
sbook-class sbook-smoker sbook-bookid INTO header,
spfli-carrid INTO flight_info,
sbook-luggweight sbook-wunit INTO flight_booking.
WRITE: / spfli-carrid,
'from', (15) spfli-cityfrom,
'to', (15) spfli-cityto.
AT NEW sflight-fldate.
WRITE: / 'Date:', sflight-fldate.
WRITE: 20 'Book-ID', 40 'Smoker', 50 'Class'.
WRITE: / sbook-bookid UNDER 'Book-ID',
sbook-smoker UNDER 'Smoker',
sbook-class UNDER 'Class'.
AT END OF sflight-fldate.
WRITE: 'Number of bookings: ', (3) cnt(sbook-bookid),
/ 'Total luggage weight:',
This program creates the same list as in the Example of Formatted Data.
The system creates three field groups and fills them with several fields. The extract dataset is filled through EXTRACTstatements during the GET events. There is no EXTRACT statement for GET sflight, since the required field sflight-fldate is part of the header field group and thus automatically extracted for each subordinate event GET sbook.
After retrieving the data, the system completes the creation of the dataset when the SORT statement occurs, and sorts the dataset by the header sort key. In the LOOP – ENDLOOP block, it writes the sorted extract dataset to the output list, using various AT – ENDAT blocks and the fields cnt(...) and sum(...).