Basic SELECT Statement
SELECT *
FROM TABLE MARA
WHERE MATNR = 'ABC'
ENDSELECT.
SELECT WERKS MATKL
FROM TABLE MARA
WHERE MATNR = 'ABC'
ENDSELECT.
Using the SINGLE keyword to select only one row
SELECT SINGLE MARA-WERKS MATKL
FROM TABLE MARA
WHEREMARA-MATNR = 'ABC'.
- Use - between the table name and field name.
- No ENDSELECT statement when using the SINGLE keyword.
SELECT M~WERKS M~MATKL
FROM TABLE MARA AS M
UP TO 5 ROWS
WHERE M~MATNR = 'ABC'.
ENDSELECT.
Use ~ instead of - when using a table alias to specify column names.
SELECT WERKS MATKL INTO (lv1, lv2)
FROM TABLE MARA
UP TO 1 ROWS
WHERE MATNR = 'ABC'.
ENDSELECT.
- Use a space to separate the column names in the SELECT clause.
- Use , to separate the variable names in the INTO clause. The variable names must be defined in the DATA section.
Using Aggregates in the SELECT clause
SELECT SUM( GSMNG ) MAX( PEDTR )FROM PLAF
INTO (ORDERQTY, ORDERFIN)
WHERE MATNR = 'ABC' AND PEDTR <> '00000000'.
ENDSELECT.
- Possible aggregate functions:
- MAX
- MIN
- AVG
- SUM
- COUNT
- The column name within the aggregate function's brackets must be separated from the brackets by a space. Eg: SUM( COL )
- Use , to separate the variable names in the INTO clause. The variable names must be defined in the DATA section.