This is a short post to see how select works on ABAP Cloud Environment, although it mostly remains the same but there few small changes which every ABAPER should be aware about
The main difference is introduction of the keyword called FIELDS , so either you specify your fields in the with the SELECT keyword for example
SELECT SINGLE *
FROM /dmo/airport
WHERE City = 'Frankfurt'
INTO @airport_full.
OR
Alternate is to use FIELDS keyword where we will not specify the fields with select instead we will specify the fields we want to select after the FIELDS keyword for example
SELECT SINGLE
FROM /dmo/airport
FIELDS *
WHERE City = 'Frankfurt'
INTO @airport_full.
Let’s create a class and see with the help of an example
"This is my class definition
CLASS z_select_test DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun . " Added the interface so that console
" functions can be used
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
" Class implementation
CLASS Z_SELECT_TEST IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
TYPES : BEGIN OF ty_air, " this is structure
airportid TYPE /dmo/airport_id,
name1 TYPE /dmo/airport_name,
city TYPE /dmo/city,
END OF ty_air.
TYPES tt_airport TYPE STANDARD TABLE OF ty_air, "table type
WITH NON-UNIQUE KEY airportid.
data airports TYPE tt_airport. " internal table defined using
" table type
data : airport_full TYPE /dmo/airport, " work area
airport_partial TYPE /dmo/airport. " work area
data t_airport TYPE TABLE OF /dmo/airport. " internal table
" ===========================================
" select statements for work area
" ===========================================
SELECT SINGLE *
FROM /dmo/airport
WHERE City = 'Frankfurt'
INTO @airport_full.
" 2nd way using key word FIELDS it is similar to statement above just that
" specify the fields needs to be selected in the select in FIELDS section
SELECT SINGLE
FROM /dmo/airport
FIELDS *
WHERE City = 'Frankfurt'
INTO @airport_full.
" ===========================================
" select statements to select specific fields
" ===========================================
" Select single with specific fields
SELECT SINGLE airport_id, name, city, country
FROM /dmo/airport
WHERE City = 'Frankfurt'
INTO @airport_full.
SELECT single
FROM /dmo/airport
FIELDS airport_id, name, city, country
WHERE City = 'Frankfurt'
INTO @airport_full.
" ===========================================
" select statements with move corresponding
" ===========================================
" Note Inline declerations cannot be used corresponding fields of syntax
SELECT SINGLE airport_id, name
FROM /dmo/airport
WHERE City = 'Frankfurt'
INTO CORRESPONDING FIELDS OF @airport_partial.
" Inline data decleartions cannot be used with corresponding
SELECT SINGLE airport_id, name
FROM /dmo/airport
WHERE City = 'Frankfurt'
INTO CORRESPONDING FIELDS OF @data(airport_par). " this will be
"syntax error
" ===========================================
" select statements to select data into internal tables
" ===========================================
SELECT *
FROM /dmo/airport
WHERE City = 'Frankfurt'
into TABLE @t_airport.
SELECT
FROM /dmo/airport
FIELDS *
WHERE City = 'Frankfurt'
into TABLE @t_airport.
SELECT
FROM /dmo/airport
FIELDS *
WHERE City = 'Frankfurt'
into TABLE @data(t_airport1).
" MOVE CORRESPONDING in internal tables
SELECT airport_id, name
FROM /dmo/airport
WHERE City = 'Frankfurt'
INTO CORRESPONDING FIELDS OF TABLE @t_airport.
SELECT
FROM /dmo/airport
FIELDS airport_id, name
WHERE City = 'Frankfurt'
INTO CORRESPONDING FIELDS OF TABLE @t_airport.
" ===========================================
" select statements with Union
" ===========================================
SELECT FROM /dmo/carrier
FIELDS name
WHERE currency_code = 'USD'
UNION ALL
SELECT FROM /dmo/airport
FIELDS name
INTO TABLE @data(it_tab).
ENDMETHOD.
ENDCLASS.
Hope this helps , keep learning