ABAPAT_EXTRACT - AT EXTRACT

RFUMSV00 - Advance Return for Tax on Sales/Purchases   ABAP Short Reference  
This documentation is copyright by SAP AG.

AT - Extract

Short Reference



Syntax

LOOP.
  [AT FIRST.
     ...
   ENDAT.]
  [AT field_groupi [WITH field_groupj]
     ...
   ENDAT.]
    [AT NEW field1.
       ...
     ENDAT.
      [AT NEW field2.
         ...
       ENDAT.
         [...]]]
           [ ... ]
        [[[...]
        AT END OF field2.
         ...
       ENDAT.]
     AT END OF field1.
       ...
     ENDAT.]
  [AT LAST.
     ...
  ENDAT.]
ENDLOOP.

Additions

1. ... FIRST

2. ... field_groupi [WITH field_groupj]

3. ... {NEW}|{END OF} fieldi

4. ... LAST

Effect

The statement block of a LOOP for extracts can contain control structures forcontrol level processing. The corresponding control statement is AT. The statements AT and ENDAT define statement blocks that are executed atcontrol breaks. Within some of these statement blocks, it is possible to access the automatically created data objectssum(field) and cnt(field).

A prerequisite for control level processing is that theextractiondataset is sorted. From the line structure and the respective sorting, you get a group structureof the content of the extraction dataset. Its levels can be evaluated using AT statements. TheAT- ENDAT control structures must be aligned one behind the other in accordance with thegroup structure. This is not necessarily the sequence of the fields in the field group header, but it can be determined by the BY addition in the SORT statement.

The statement blocks within the AT-ENDAT control structures are executed if there is anappropriate control break in the current line. Statements in the LOOP-ENDLOOP controlstructure that are not executed within an AT-ENDAT control structure are executed at each loop run.

Addition 1

... FIRST

Effect

The control level is defined by the first line of the extract dataset.

Addition 2

... field_groupi [WITH field_groupj]

Effect

A line that is attached to the extract dataset using the statement EXTRACT field_groupi. If the WITH addition is specified, the next line must be defined by the field group field_groupj.

Addition 3

... {NEW}|{END OF} fieldi

Effect

The control level is defined by the beginning or end of a group of lines with the same content in thecomponent fieldi and in the component links of fieldi. The component field mustbe part of the field group header. Components whose content is hexadecimal 0 are not included as a control break criterion.

For fieldi, a field symbol can be specified. If a component of field group header is assignedto the field symbol at the execution of the statement, this has the same effect as the specificationof the respective component. If no data object is assigned to the field symbol, the specification is ignored. If another data object is assigned to the field symbol, there is an exception that cannot be handled.

Addition 4

... LAST

Effect

The control level is defined by the last line of the extraction dataset.

Example

This example continues the example given under EXTRACT. At the event END-OF-SELECTION,the extract dataset is sorted by field group header and, afterwards, control level processing is executed in a LOOP. Here a structured list will be created.

NODES: spfli, sflight.

FIELD-GROUPS: header, flight_info, flight_date.

START-OF-SELECTION.
  INSERT: spfli-carrid spfli-connid sflight-fldate
            INTO header,
          spfli-cityfrom spfli-cityto
            INTO flight_info.

GET spfli.
  EXTRACT flight_info.

GET sflight.
  EXTRACT flight_date.

END-OF-SELECTION.
  SORT STABLE.
  LOOP.
    AT FIRST.
      WRITE / 'Flight list'.
      ULINE.
    ENDAT.
    AT flight_info WITH flight_date.
      WRITE: / spfli-carrid , spfli-connid, sflight-fldate,
               spfli-cityfrom, spfli-cityto.
    ENDAT.
    AT flight_date.
      WRITE: / spfli-carrid , spfli-connid, sflight-fldate.
    ENDAT.
    AT LAST.
      ULINE.
      WRITE: cnt(spfli-carrid), 'Airlines'.
      ULINE.
    ENDAT.
  ENDLOOP.






CPI1466 during Backup   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.


Length: 8019 Date: 20120518 Time: 193312     triton ( 194 ms )