DATA:
BEGIN OF super,
col1 TYPE i VALUE 1,
BEGIN OF sub,
col2 TYPE i VALUE 2,
col3 TYPE i VALUE 3,
END OF sub,
END OF super.
cl_demo_output=>display( super ).
CLASS demo_class DEFINITION.
PUBLIC SECTION.
TYPES:
BEGIN OF spfli_line,
carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
cityfrom TYPE spfli-cityfrom,
cityto TYPE spfli-cityto,
END OF spfli_line,
spfli_tab TYPE HASHED TABLE OF spfli_line
WITH UNIQUE KEY carrid connid,
BEGIN OF struct,
carrname TYPE scarr-carrname,
spfli TYPE REF TO spfli_tab,
END OF struct.
DATA result TYPE SORTED TABLE OF struct WITH UNIQUE KEY carrname.
METHODS constructor.
ENDCLASS.
CLASS demo_class IMPLEMENTATION.
METHOD constructor.
SELECT s~carrname, p~carrid, p~connid, p~cityfrom, p~cityto
FROM scarr AS s
INNER JOIN spfli AS p
ON s~carrid = p~carrid
ORDER BY s~carrname
INTO TABLE @DATA(itab).
LOOP AT itab ASSIGNING FIELD-SYMBOL(<fs>) GROUP BY <fs>-carrname.
INSERT VALUE #( carrname = <fs>-carrname ) INTO TABLE result
ASSIGNING FIELD-SYMBOL(<line>).
<line>-spfli = NEW #(
FOR <wa> IN GROUP <fs> ( CORRESPONDING #( <wa> ) ) ).
ENDLOOP.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA(oref) = NEW demo_class( ).
cl_demo_output=>display( oref ).
DATA(o) = cl_demo_output=>new(
)->write_doc( cl_demo_output_helper=>get_infobox_html(
`This output is produced by program ` && sy-repid )
)->next_section( 'ABAP CDS View Entity'
)->write_doc( cl_demo_output_helper=>get_ddls_source_code_html(
source = 'DEMO_CDS_SPFLI_ENTITY' )
)->next_section( `ABAP SQL SELECT`
)->write_doc(
`The following code snippet demonstrates a ` &&
`<code>SELECT</code> statement accessing ` &&
`the CDS view entity without ` &&
`<code>ORDER BY</code> clause:`
)->begin_code( `select1` ).
SELECT *
FROM demo_cds_spfli_entity
INTO TABLE @DATA(itab). "#EC CI_NOWHERE
o->end_code( `select1`
)->write_doc( `The result in <code>itab</code> is:`
)->write( itab
)->write_doc( `Adding`
)->write_doc(
cl_demo_output_helper=>get_abap_source_code_html(
code = `ORDER BY cityfrom, cityto` )
)->write_doc( `as follows`
)->begin_code( `select2` ).
SELECT *
FROM demo_cds_spfli_entity
ORDER BY cityfrom, cityto
INTO TABLE @itab. "#EC CI_NOWHERE
o->end_code( `select2`
)->write_doc( `gives:`
)->write( itab
)->display( ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |