SAP® Documentation

Single view

ABAPCOLUMN_REFERENCE - COLUMN REFERENCE

Addresses (Business Address Services)   rdisp/max_wprun_time - Maximum work process run time  
This documentation is copyright by SAP AG.
SAP E-Book

Column Reference

Variants:

1. fdescriptor

2. aggregate_expression

Effect

Used in the SELECT and ORDER BY clause of a SELECT or OPEN CURSOR statement to identify a column of the selection result by its field descriptorfdescriptor. You can use the field descriptorfdescriptor either on its own or as an argument in an aggregate expression.

Variant 1

fdescriptor

Addition:

... AS alias

Effect

The column of the selection result named in the AS condition corresponds to a column of a database table or view described by the field labelfdescriptor and specified in the FROM clause.

Example

Display a list of all customers:

DATA SCUSTOM_WA TYPE SCUSTOM.

SELECT ID NAME
       FROM SCUSTOM
       INTO (SCUSTOM_WA-ID, SCUSTOM_WA-NAME).
  WRITE: / SCUSTOM_WA-ID, SCUSTOM_WA-NAME.
ENDSELECT.

Addition

... AS alias

Effect

For this column in the selection result, the alternative column namealias is used in the INTO or ORDER-BY clause. You can use an alternative column name with INTO CORRESPONDING FIELDS OF ... in the INTO clause to assign a column of the selection result to a component of the target area with the name alias.

Example

Display a list of the customer numbers of all customers on all Lufthansa flights on 02.28.1995:

DATA SCUSTOM_WA TYPE SCUSTOM.

SELECT DISTINCT CUSTOMID AS ID
       FROM SBOOK
       INTO CORRESPONDING FIELDS OF SCUSTOM_WA
       WHERE
         CARRID   = 'LH '      AND
         FLDATE   = '19950228'.
  WRITE: / SCUSTOM_WA-ID.
ENDSELECT.

Variant 2

aggregate_expression

Addition:

... AS alias

Effect

An aggregate expression uses one of the aggregate functionsMAX, MIN, AVG, SUM, or COUNT to combine data from one or all columns in a database table in the resulting set.

Example

Display a list of all customers on Lufthansa flight 0400 in 1995, along with the highest price paid, sorted by customer name:

DATA: SCUSTOM_WA TYPE SCUSTOM, SBOOK_WA TYPE SBOOK.

SELECT SCUSTOM~NAME SCUSTOM~POSTCODE SCUSTOM~CITY
         MAX( SBOOK~LOCCURAM )
       INTO (SCUSTOM_WA-NAME, SCUSTOM_WA-POSTCODE, SCUSTOM_WA-CITY,
             SBOOK_WA-LOCCURAM)
       FROM SCUSTOM INNER JOIN SBOOK
         ON SCUSTOM~ID = SBOOK~CUSTOMID
       WHERE SBOOK~FLDATE BETWEEN '19950101' AND '19951231' AND
             SBOOK~CARRID   = 'LH '                         AND
             SBOOK~CONNID   = '0400'
       GROUP BY SCUSTOM~NAME SCUSTOM~POSTCODE SCUSTOM~CITY
       ORDER BY SCUSTOM~NAME.
  WRITE: / SCUSTOM_WA-NAME, SCUSTOM_WA-POSTCODE, SCUSTOM_WA-CITY,
           SBOOK_WA-LOCCURAM.
ENDSELECT.

Addition

... AS alias

Effect

As in variant 1. You can also use an alternative column name with aggregate expressions to sort the result by an aggregate expression. Unlike aggregate expressions, you can use alternative column names in the ORDER-BY clause.

Example

Display a list of all customers on Lufthansa flight 0400 in 1995, along with the individual average price paid, sorted by price and customer name:

DATA: SCUSTOM_WA TYPE SCUSTOM, SBOOK_WA TYPE SBOOK.

SELECT SCUSTOM~NAME SCUSTOM~POSTCODE SCUSTOM~CITY
         AVG( SBOOK~LOCCURAM ) AS AVG
       INTO (SCUSTOM_WA-NAME, SCUSTOM_WA-POSTCODE, SCUSTOM_WA-CITY,
             SBOOK_WA-LOCCURAM)
       FROM SCUSTOM INNER JOIN SBOOK
         ON SCUSTOM~ID = SBOOK~CUSTOMID
       WHERE SBOOK~FLDATE BETWEEN '19950101' AND '19951231' AND
             SBOOK~CARRID   = 'LH '                         AND
             SBOOK~CONNID   = '0400'
      GROUP BY SCUSTOM~NAME SCUSTOM~POSTCODE SCUSTOM~CITY
      ORDER BY AVG DESCENDING SCUSTOM~NAME.
  WRITE: / SCUSTOM_WA-NAME, SCUSTOM_WA-POSTCODE, SCUSTOM_WA-CITY,
           SBOOK_WA-LOCCURAM.
ENDSELECT.

Additional help

Reading Data






BAL Application Log Documentation   General Material Data  
This documentation is copyright by SAP AG.

Length: 8378 Date: 20191206 Time: 164602     sap01-206 ( 64 ms )

Our Service

Looking for Support? Questions?

The

Consolut

Callback-Service

Leave us your contact details and we will call you back. Panels marked with * are mandatory.