selectabapopensql

Calculated fields in SELECT statement in ABAP


Does ABAP support calculated fields in SELECT statement? Such as:

SELECT price quantity price*quantity AS sum
FROM ...
INTO ...
WHERE ...

If not, let advanced coders tell me what solutions they use to cope with this task. Do not offer such performance decreasing ways as calculation into temporary variable within SELECT cycle.

SELECT.
...
ENDSELECT.

Solution

  • Open SQL only supports a couple of aggregate functions. Calculations should be done in memory, after selecting the records and saving the result into an internal table.
    So in short:

    select ... into table itab from ...
    loop at itab assigning <itab_row>.
      " Perform calculations on row here
    endloop.