SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Internal Tables → Expressions and Functions for Internal Tables → table_exp - Table Expressions → table_exp - itab_line →Table Expressions, Specified Rows
This example demonstrates how the row is specified in table expressions.
Source Code
REPORT demo_tab_exp_line.
CLASS demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS: class_constructor,
main.
PRIVATE SECTION.
CLASS-DATA
flight_tab
TYPE STANDARD TABLE OF spfli
WITH EMPTY KEY
WITH UNIQUE HASHED KEY id COMPONENTS carrid connid
WITH NON-UNIQUE SORTED KEY cities COMPONENTS cityfrom cityto.
ENDCLASS.
CLASS demo IMPLEMENTATION.
METHOD main.
TRY.
DATA(out) = cl_demo_output=>new(
)->begin_section(
`Primary index line 1`
)->write(
flight_tab[ 1 ] ).
out->next_section(
`Secondary index CITIES line 1`
)->write(
flight_tab[ KEY cities INDEX 1 ] ).
out->next_section(
`Free key CARRID, CONNID not optimized`
)->write(
flight_tab[ carrid = 'UA'
connid = '0941' ] ) ##primkey[id].
out->next_section(
`Secondary key ID optimized`
)->write(
flight_tab[ KEY id COMPONENTS carrid = 'UA'
connid = '0941' ] ).
out->next_section(
`Secondary key CITIES optimized`
)->write(
flight_tab[ KEY cities cityfrom = 'FRANKFURT'
cityto = 'NEW YORK' ] ).
CATCH cx_sy_itab_line_not_found.
out->write( `Nothing found` ).
ENDTRY.
out->display( ).
ENDMETHOD.
METHOD class_constructor.
SELECT *
FROM spfli
INTO TABLE flight_tab
ORDER BY carrid connid.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
demo=>main( ).
Description
Table expressions that specify different rows are used as input parameters of the method WRITE_DATA of the output class CL_DEMO_OUTPUT. The following output is produced: