ABAPCOLUMN_REFERENCE - COLUMN REFERENCE
CPI1466 during Backup ABAP Short ReferenceThis documentation is copyright by SAP AG.
Column Reference
Variants:
1. fdescriptor
2. aggregate_expression
Effect
Used in the SELECT andORDER BY clause of aSELECT orOPEN CURSOR statement to identify a column of the selection result by itsfield descriptor fdescriptor. You can use thefield descriptor fdescriptor either on its own or as an argument in an aggregate expression.
Variant 1
fdescriptor
Addition:
Effect
The column of the selection result named in the AS condition corresponds to a column of adatabase table orview described by thefield label fdescriptor and specified in theFROM 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 name alias is used in theINTO orORDER-BY clause. You can use an alternative column name with INTO CORRESPONDING FIELDS OF ... in theINTO 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:
Effect
An aggregateexpression uses one of the aggregate functions MAX, 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 theORDER-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
General Material Data BAL_S_LOG - Application Log: Log header data
This documentation is copyright by SAP AG.
Length: 8048 Date: 20120518 Time: 205838 triton ( 137 ms )






