Entering content frame

Formatting Data Using Extracts Locate the document in its SAP Library structure

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.

REPORT demo_data_process_extract.

NODES: spfli, sflight, sbook.

FIELD-GROUPS: header, flight_info, flight_booking.

  spfli-cityfrom spfli-cityto
  spfli-connid sflight-fldate
  sbook-class sbook-smoker sbook-bookid INTO header,
  spfli-carrid                          INTO flight_info,
  sbook-luggweight sbook-wunit          INTO flight_booking.


GET spfli.
  EXTRACT flight_info.

GET sflight.

GET sbook.
  EXTRACT flight_booking.



    AT flight_info.
      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'.
    AT flight_booking.
      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:',
              sum(sbook-luggweight), sbook-wunit.


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(...).




Leaving content frame