You are on page 1of 2

SELECT DISTINCT in SAP ABAP - Select Statements types | Sapnuts.com about:reader?url=https://www.sapnuts.com/courses/core-abap/select-sta...

sapnuts.com

SELECT DISTINCT in SAP ABAP -


Select Statements types | Sapnuts.com
Ashok Kumar Reddy

SELECT DISTINCT is a SQL Select query, which is used to get


distinct values of a column from a database table.

SELECT DISTINCT eliminates duplicates records of a column of a


table.

Syntax for SELECT DISTINCT in SAP ABAP

SELECT DISTINCT <COLUMN> FROM <TABLE> INTO TABLE


<ITAB> WHERE <CONDITION>.

Example for SELECT DISTINCT in SAP ABAP

The below example is used to get distinct MTART(Material type)


from MARA(Material Master) table.

TYPES: BEGIN OF ty_mtart,


mtart TYPE mara-mtart,
END OF ty_mtart.
DATA: it_mtart TYPE TABLE OF ty_mtart,
wa_mtart TYPE ty_mtart.

1 of 2 8/24/2016 2:59 AM
SELECT DISTINCT in SAP ABAP - Select Statements types | Sapnuts.com about:reader?url=https://www.sapnuts.com/courses/core-abap/select-sta...

START-OF-SELECTION.
SELECT DISTINCT mtart FROM mara INTO TABLE
it_mtart UP TO 5 ROWS.

LOOP AT it_mtart INTO wa_mtart.


WRITE:/ wa_mtart-mtart.
ENDLOOP.

Related Lessons

Was this lesson helpful to you? Yes No 4 People out of 4 think this
lesson helpful

2 of 2 8/24/2016 2:59 AM

You might also like