Update content
This commit is contained in:
@@ -21,6 +21,11 @@
|
||||
* short and simple and focuses on specific RAP aspects. For this reason,
|
||||
* the example might not fully meet the requirements of the RAP BO contract.
|
||||
*
|
||||
* In newer ABAP releases, you can use side effects to trigger data
|
||||
* changes (in terms of this example, the recalculation of the calculation
|
||||
* result) and other things based on data changes in UI scenarios with
|
||||
* draft-enabled BOs.
|
||||
*
|
||||
* The code presented in this class is intended only to support the ABAP
|
||||
* cheat sheets. It is not intended for direct use in a production system
|
||||
* environment. The code examples in the ABAP cheat sheets are primarily
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
* output in the ADT console
|
||||
*
|
||||
* -------------------------- NOTE -------------------------------------
|
||||
* This class is used to display deep types contained in the cheat sheet
|
||||
* example classes in older ABAP releases.
|
||||
*
|
||||
* The code presented in this class is intended only to support the ABAP
|
||||
* cheat sheets. It is not intended for direct use in a production system
|
||||
* environment. The code examples in the ABAP cheat sheets are primarily
|
||||
|
||||
@@ -390,7 +390,7 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
|
||||
<fs_tab_f> = VALUE #( BASE <fs_tab_f> ( <fs_struc_f> ) ).
|
||||
ENDLOOP.
|
||||
|
||||
output->display( input = tab_f1 ).
|
||||
output->display( input = tab_f1 name = `tab_f1` ).
|
||||
|
||||
"Regarding the field symbol, the data type is derived automatically.
|
||||
LOOP AT <fs_tab_f> ASSIGNING FIELD-SYMBOL(<fs_struc_f2>).
|
||||
@@ -862,7 +862,7 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `21) Dynamically Specifying a Data Object` ).
|
||||
output->next_section( `21) Dynamically Specifying Components` ).
|
||||
|
||||
"A field is determined at runtime on whose basis a sorting is done on an
|
||||
"internal table.
|
||||
@@ -945,7 +945,7 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
|
||||
output->next_section( `25) Excursion: Multiple Dynamically Specified ` &&
|
||||
`Clauses in an ABAP SQL SELECT Statement` ).
|
||||
|
||||
"In this nonsense example, multiple clauses in a SELECT statement are
|
||||
"In this example, multiple clauses in a SELECT statement are
|
||||
"determined at runtime to demonstrate the rich variety of possibilities.
|
||||
"Note: The rows and target table specifications are not real dynamic specifications in the
|
||||
"SELECT statement in the sense of syntax elements enclosed by parentheses. Here, they are just
|
||||
@@ -1005,7 +1005,7 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
|
||||
|
||||
DATA method TYPE string VALUE `FILL_STRING`.
|
||||
|
||||
"Note that method has no parameters in this example.
|
||||
"Note that the method has no parameters in this example.
|
||||
"Similar to above. The method stores some text in a string which is
|
||||
"displayed to see the effect of the dynamic method call.
|
||||
CALL METHOD lcl_det_at_runtime=>(method).
|
||||
|
||||
@@ -89,7 +89,7 @@ CLASS lcl_det_at_runtime IMPLEMENTATION.
|
||||
seed = cl_abap_random=>seed( ) min = 1
|
||||
max = lines( built ) )->get_next( ).
|
||||
|
||||
"Providing the returning parameter with a random table name
|
||||
"Providing the returning parameter with a random type name
|
||||
TRY.
|
||||
builtin_type = VALUE #( builtin_type = built[ idx ] dec = idx len = idx ).
|
||||
CATCH cx_sy_itab_line_not_found.
|
||||
|
||||
@@ -110,16 +110,12 @@ protected section.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
|
||||
CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
|
||||
METHOD class_constructor.
|
||||
fill_dbtabs( ).
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD fill_dbtabs.
|
||||
"Initializing and filling of database tables to have data to work with
|
||||
|
||||
@@ -141,7 +137,6 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD fill_itabs_for_corresponding.
|
||||
tab1 = VALUE #( ( a = 1 b = 'aaa' c = 'aaa' d = 'A' )
|
||||
( a = 2 b = 'bbb' c = 'bbb' d = 'B' ) ).
|
||||
@@ -182,7 +177,6 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD if_oo_adt_classrun~main.
|
||||
|
||||
DATA(output) = NEW zcl_demo_abap_display( out ).
|
||||
@@ -221,6 +215,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = it_st name = `it_st` ).
|
||||
output->display( input = it_so name = `it_so` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `2) Adding initial line` ).
|
||||
|
||||
APPEND INITIAL LINE TO it_st.
|
||||
@@ -230,6 +226,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = it_st name = `it_st` ).
|
||||
output->display( input = it_so name = `it_so` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `3) Adding mutliple lines of an internal table to` &&
|
||||
` another one` ).
|
||||
|
||||
@@ -249,6 +247,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = it_st name = `it_st` ).
|
||||
output->display( input = it_so name = `it_so` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `4) Adding lines of an internal table to` &&
|
||||
` another one by specifying the index range.` ).
|
||||
|
||||
@@ -263,6 +263,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it_st name = `it_st` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `5) Inserting lines of an internal table` &&
|
||||
` into another one at a specific position` ).
|
||||
|
||||
@@ -275,6 +277,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it_st name = `it_st` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `6) Adding lines using constructor expressions` ).
|
||||
|
||||
"Creating a line to be added to an internal table.
|
||||
@@ -287,6 +291,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it_st name = `it_st` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `7) Creating a new table inline and adding lines` &&
|
||||
` using a constructor expression` ).
|
||||
|
||||
@@ -301,6 +307,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it_st2 name = `it_st2` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `8) Adding lines using constructor expressions ` &&
|
||||
`and keeping existing table content` ).
|
||||
|
||||
@@ -311,6 +319,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it_st name = `it_st` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `9) Adding lines from other internal tables using` &&
|
||||
` constructor expressions` ).
|
||||
|
||||
@@ -323,6 +333,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it_st name = `it_st` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `10) Copying table content (without constructor ` &&
|
||||
`expression)` ).
|
||||
|
||||
@@ -331,6 +343,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it_st name = `it_st` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `11) CORRESPONDING Operator and MOVE-CORRESPONDING` ).
|
||||
output->display( `Internal table content before assignments` ).
|
||||
|
||||
@@ -343,6 +357,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = tab3 name = `tab3` ).
|
||||
output->display( input = tab4 name = `tab4` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `Copying content from another table that has ` &&
|
||||
`a different line type ...` ).
|
||||
output->display( `11a) ... and deleting existing table content ` &&
|
||||
@@ -354,6 +370,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
fill_itabs_for_corresponding( ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `11b) ... and deleting existing table content ` &&
|
||||
`using MOVE-CORRESPONDING` ).
|
||||
|
||||
@@ -363,6 +381,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
fill_itabs_for_corresponding( ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `11c) ... and keeping existing table ` &&
|
||||
`content using the CORRESPONDING operator` ).
|
||||
|
||||
@@ -372,6 +392,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
fill_itabs_for_corresponding( ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `11d) ... and keeping existing table ` &&
|
||||
`content using MOVE-CORRESPONDING` ).
|
||||
|
||||
@@ -381,6 +403,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
fill_itabs_for_corresponding( ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `11e) ... respecting component ` &&
|
||||
`mapping` ).
|
||||
|
||||
@@ -392,6 +416,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
fill_itabs_for_corresponding( ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `11f) ... excluding components` ).
|
||||
|
||||
"Excluding components from the assignment
|
||||
@@ -407,6 +433,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
fill_itabs_for_corresponding( ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `11h) ... discarding duplicates` ).
|
||||
|
||||
"Preventing runtime errors if duplicate lines are assigned to
|
||||
@@ -423,6 +451,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = tab3 name = `tab3` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `11i) Copying data from a deep ` &&
|
||||
`internal table to another deep internal table` ).
|
||||
output->display( `Original table content` ).
|
||||
@@ -430,6 +460,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = itab_nested1 name = `itab_nested1` ).
|
||||
output->display( input = itab_nested2 name = `itab_nested2` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `11j) ... deleting ` &&
|
||||
`existing content (CORRESPONDING operator)` ).
|
||||
|
||||
@@ -439,6 +471,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
fill_itabs_for_corresponding( ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `11k) ... deleting ` &&
|
||||
`existing content (MOVE-CORRESPONDING)` ).
|
||||
|
||||
@@ -449,6 +483,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
fill_itabs_for_corresponding( ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `11l) ... keeping ` &&
|
||||
`existing content (CORRESPONDING operator)` ).
|
||||
|
||||
@@ -459,6 +495,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
fill_itabs_for_corresponding( ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `11m) ... keeping ` &&
|
||||
`existing content (MOVE-CORRESPONDING)` ).
|
||||
|
||||
@@ -467,6 +505,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = itab_nested2 name = `itab_nested2` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `Filling internal tables: Excursions` ).
|
||||
output->display( `12) Selecting multiple rows from a database ` &&
|
||||
`table into an internal table` ).
|
||||
@@ -478,6 +518,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = itab_select1 name = `itab_select1` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `13) Sequentially adding multiple rows from ` &&
|
||||
`a database table to an internal table` ).
|
||||
|
||||
@@ -500,6 +542,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = itab name = `itab` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `14) Adding multiple rows from a database table ` &&
|
||||
`to an internal table that has a different line type than the ` &&
|
||||
`database table and keeping existing table content` ).
|
||||
@@ -511,6 +555,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = itab name = `itab` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `15) Adding multiple rows from a database table ` &&
|
||||
`to an internal table that has a different line type than the ` &&
|
||||
`database table and deleting existing table content` ).
|
||||
@@ -522,6 +568,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = itab name = `itab` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `16) Adding multiple rows from an internal table ` &&
|
||||
`to an internal table using SELECT` ).
|
||||
|
||||
@@ -531,6 +579,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = itab_clone name = `itab_clone` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `17) Combining data of multiple tables into an` &&
|
||||
` internal table using an inner join` ).
|
||||
|
||||
@@ -552,6 +602,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = join_result name = `join_result` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `18) Filling internal table ` &&
|
||||
`using a subquery (1)` ).
|
||||
|
||||
@@ -566,6 +618,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = subquery_result1 name = `subquery_result1` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `19) Filling internal table ` &&
|
||||
`using a subquery (2)` ).
|
||||
|
||||
@@ -583,6 +637,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = subquery_result2 name = `subquery_result2` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `20) Filling an internal table from a table ` &&
|
||||
`depending on the existence of data in another internal table ` &&
|
||||
`using the addition FOR ALL ENTRIES` ).
|
||||
@@ -602,6 +658,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = select_result name = `select_result` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `21) Adding content from a database to internal` &&
|
||||
` table by using alias names in the SELECT list` ).
|
||||
|
||||
@@ -618,6 +676,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = itab2 name = `itab2` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `22) FILTER: Filtering internal table by condition` ).
|
||||
|
||||
"This section covers multiple examples demonstrating the syntactical variety
|
||||
@@ -717,6 +777,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = f11 name = `f11` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `25) Inserting data into an internal table ` &&
|
||||
`using a COLLECT statement` ).
|
||||
|
||||
@@ -735,6 +797,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = itab_num name = `itab_num` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `Reading from internal tables` ).
|
||||
|
||||
"Filling internal tables
|
||||
@@ -767,6 +831,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = it_so_sec name = `it_so_sec` ).
|
||||
output->display( input = it_ha_sec name = `it_ha_sec` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `26) Reading a single line into target area` ).
|
||||
|
||||
"The examples anticipate the reading of a line by index since the
|
||||
@@ -801,6 +867,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = dref->* name = `dref->*` ).
|
||||
output->display( input = dref2->* name = `dref2->*` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `Reading a single line via index ...` ).
|
||||
output->display( `27) ... using READ TABLE` ).
|
||||
|
||||
@@ -830,6 +898,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = wa7 name = `wa7` ).
|
||||
output->display( input = wa8 name = `wa8` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `28) ... table expressions (1)` ).
|
||||
|
||||
"Reading via index; primary table index is used implicitly
|
||||
@@ -867,6 +937,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = lv4 name = `lv4` ).
|
||||
output->display( input = lv5 name = `lv5` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `29) ... table expressions (2)` ).
|
||||
|
||||
"Copying a table line via table expression and embedding in
|
||||
@@ -888,6 +960,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = lv7 name = `lv7` ).
|
||||
output->display( input = lv8 name = `lv8` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `Reading a single line via table keys ...` ).
|
||||
output->display( `30) ... using READ TABLE (1)` ).
|
||||
|
||||
@@ -915,6 +989,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = wa12 name = `wa12` ).
|
||||
output->display( input = wa13 name = `wa13` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `31) ... using READ TABLE (2)` ).
|
||||
|
||||
"Reading a line based on keys specified in a work area
|
||||
@@ -941,6 +1017,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = wa15 name = `wa15` ).
|
||||
output->display( input = wa16 name = `wa16` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `32) ... using table expressions` ).
|
||||
"Primary table key (COMPONENTS addition is optional)
|
||||
DATA(lv9) = it_so_sec[ KEY primary_key COMPONENTS a = 1 ].
|
||||
@@ -960,6 +1038,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = lv12 name = `lv12` ).
|
||||
output->display( input = lv13 name = `lv13` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `33) Reading a single line via free key` ).
|
||||
"Note: If there a multiple matching entries, the first found
|
||||
"is returned.
|
||||
@@ -970,6 +1050,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = wa17 name = `wa17` ).
|
||||
output->display( input = lv14 name = `lv14` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `34) Excursion: Addressing individual components` ).
|
||||
"Addressing a component using the component selector
|
||||
DATA(comp1) = it_so_sec[ 1 ]-b.
|
||||
@@ -990,6 +1072,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = comp3 name = `comp3` ).
|
||||
output->display( input = comp4 name = `comp4` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `35) Checking if a line exists in an internal table` ).
|
||||
|
||||
"Defining the key
|
||||
@@ -1013,6 +1097,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( |Line { key1 } does not exist in internal table.| ).
|
||||
ENDIF.
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `36) Checking the index of a ` &&
|
||||
`specific line` ).
|
||||
|
||||
@@ -1077,9 +1163,11 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( |The internal table consists of { itab_lines } | &&
|
||||
|lines.| ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `Processing multiple internal table lines ` &&
|
||||
`sequentially` ).
|
||||
output->display( `38) Reading a complete table by sequentially ` &&
|
||||
output->display( `38a) Reading a complete table by sequentially ` &&
|
||||
`reading all lines` ).
|
||||
|
||||
"No further addition: All lines are respected.
|
||||
@@ -1090,6 +1178,83 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it_so_sec name = `it_so_sec` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->display( `38b) LOOP AT statements with different targets` ).
|
||||
|
||||
"The following examples demonstrate the different targets that
|
||||
"are possible for LOOP AT statements. In the example above,
|
||||
"a field symbol is created inline.
|
||||
"As above, there are no additions to the loop statement, i.e. all lines
|
||||
"are processed.
|
||||
|
||||
DATA(lines_in_table) = lines( it_so_sec ).
|
||||
output->display( |There should be { lines_in_table } iterations per loop.| ).
|
||||
|
||||
"Target: Existing work area
|
||||
output->display( `---- Loop target: Existing work area ----` ).
|
||||
DATA wa_lo LIKE LINE OF it_so_sec.
|
||||
|
||||
LOOP AT it_so_sec INTO wa_lo.
|
||||
IF sy-tabix = 1.
|
||||
output->display( |This text is displayed when reaching line { sy-tabix }.| ).
|
||||
ELSEIF sy-tabix = lines_in_table.
|
||||
output->display( |This text is displayed when reaching line { sy-tabix }.| ).
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
output->display( `---- Loop target: Work area created inline ----` ).
|
||||
LOOP AT it_so_sec INTO DATA(wa_inl).
|
||||
IF sy-tabix = 1.
|
||||
output->display( |This text is displayed when reaching line { sy-tabix }.| ).
|
||||
ELSEIF sy-tabix = lines_in_table.
|
||||
output->display( |This text is displayed when reaching line { sy-tabix }.| ).
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
output->display( `---- Loop target: Existing field symbol ----` ).
|
||||
FIELD-SYMBOLS <fs_lo> LIKE LINE OF it_so_sec.
|
||||
|
||||
LOOP AT it_so_sec ASSIGNING <fs>.
|
||||
IF sy-tabix = 1.
|
||||
output->display( |This text is displayed when reaching line { sy-tabix }.| ).
|
||||
ELSEIF sy-tabix = lines_in_table.
|
||||
output->display( |This text is displayed when reaching line { sy-tabix }.| ).
|
||||
ENDIF.
|
||||
|
||||
ENDLOOP.
|
||||
|
||||
output->display( `---- Loop target: Field symbol created inline ----` ).
|
||||
LOOP AT it_so_sec ASSIGNING FIELD-SYMBOL(<fs_inl>).
|
||||
IF sy-tabix = 1.
|
||||
output->display( |This text is displayed when reaching line { sy-tabix }.| ).
|
||||
ELSEIF sy-tabix = lines_in_table.
|
||||
output->display( |This text is displayed when reaching line { sy-tabix }.| ).
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
output->display( `---- Loop target: Existing data reference variable ----` ).
|
||||
DATA dref_lo TYPE REF TO struc1 .
|
||||
|
||||
LOOP AT it_so_sec REFERENCE INTO dref_lo.
|
||||
IF sy-tabix = 1.
|
||||
output->display( |This text is displayed when reaching line { sy-tabix }.| ).
|
||||
ELSEIF sy-tabix = lines_in_table.
|
||||
output->display( |This text is displayed when reaching line { sy-tabix }.| ).
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
output->display( `Loop target: Data reference variable created inline` ).
|
||||
LOOP AT it_so_sec REFERENCE INTO DATA(dref_inl).
|
||||
IF sy-tabix = 1.
|
||||
output->display( |This text is displayed when reaching line { sy-tabix }.| ).
|
||||
ELSEIF sy-tabix = lines_in_table.
|
||||
output->display( |This text is displayed when reaching line { sy-tabix }.| ).
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `39) Reading multiple lines by an index range` ).
|
||||
|
||||
"Specific lines in an index range are respected
|
||||
@@ -1101,6 +1266,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it_so_sec name = `it_so_sec` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `40) Reading multiple lines by condition` ).
|
||||
|
||||
LOOP AT it_so_sec ASSIGNING FIELD-SYMBOL(<fs6>) WHERE a < 3.
|
||||
@@ -1110,6 +1277,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it_so_sec name = `it_so_sec` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `41) Looping across a table without an interest` &&
|
||||
` in the table content` ).
|
||||
|
||||
@@ -1121,6 +1290,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( |There are { num } lines in the table | &&
|
||||
|fulfilling the condition.| ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `42) Loop with table key specification` ).
|
||||
|
||||
DATA it_st_em TYPE TABLE OF struc1 WITH EMPTY KEY.
|
||||
@@ -1136,6 +1307,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it_st_em name = `it_st_em` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `Creating and filling tables using table ` &&
|
||||
`iterations with FOR and VALUE` ).
|
||||
output->display( `43) Retrieving values of one column in ` &&
|
||||
@@ -1152,6 +1325,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = lv_num_a name = `lv_num_a` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `44) Retrieving values of one column in ` &&
|
||||
`an internal table based on conditions` ).
|
||||
|
||||
@@ -1160,6 +1335,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = lv_num_b name = `lv_num_b` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `45) Looping across 2 tables ` &&
|
||||
`and retrieving values based on conditions` ).
|
||||
@@ -1174,6 +1350,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = itab_for_2tab name = `itab_for_2tab` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `46) Retrieving and changing values from an ` &&
|
||||
`internal tables sequentially` ).
|
||||
DATA(it_changed) = VALUE tabtype( FOR ls5 IN it_so_sec
|
||||
@@ -1218,6 +1396,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = it1 name = `it1` ).
|
||||
output->display( input = it2 name = `it2` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `47) Sorting by primary table key` ).
|
||||
|
||||
"Primary key: component a
|
||||
@@ -1225,6 +1405,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it1 name = `it1` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `48) Sorting by primary table key in ascending` &&
|
||||
` order` ).
|
||||
|
||||
@@ -1234,6 +1416,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it1 name = `it1` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `49) Sorting by primary table key respecting all ` &&
|
||||
`non-numeric fields` ).
|
||||
|
||||
@@ -1248,6 +1432,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
"SORT it3.
|
||||
"output->display( input = it3 name = `it3` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `50) Sorting by primary table key in ` &&
|
||||
`descending order` ).
|
||||
|
||||
@@ -1256,6 +1442,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it1 name = `it1` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `51) Sorting by explicitly specified component (1)` ).
|
||||
"Here, the component is the primary table key.
|
||||
"The sorting result is the same as above.
|
||||
@@ -1263,6 +1451,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it1 name = `it1` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `52) Sorting by explicitly specified component (2)` ).
|
||||
|
||||
"Sorting by arbitrary, non-key field
|
||||
@@ -1270,6 +1460,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it1 name = `it1` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `53) Sorting by multiple explicitly specified` &&
|
||||
` components` ).
|
||||
|
||||
@@ -1278,6 +1470,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it1 name = `it1` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `54) Sorting by respecting the values of all` &&
|
||||
` components` ).
|
||||
|
||||
@@ -1286,6 +1480,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it1 name = `it1` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `Modifying internal table content` ).
|
||||
output->display( `Internal table content before modifications` ).
|
||||
|
||||
@@ -1298,6 +1494,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
"Hashed table
|
||||
output->display( input = it_ha_sec name = `it_ha_sec` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `55) Directly modifying recently read table lines` ).
|
||||
|
||||
"READ TABLE
|
||||
@@ -1315,6 +1513,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = it_so_sec[ 1 ] name = `it_so_sec[ 1 ]` ).
|
||||
output->display( input = it_st[ 1 ] name = `it_st[ 1 ]` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `56) Modifying internal table content using MODIFY` ).
|
||||
"Modifying table lines via key values
|
||||
"Line that is used to modify internal table
|
||||
@@ -1367,6 +1567,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = it_so_sec name = `it_so_sec` ).
|
||||
output->display( input = it_ha_sec name = `it_ha_sec` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `57) Deleting internal table content using DELETE` ).
|
||||
"Deleting via index
|
||||
"Primary table index is used implicitly.
|
||||
@@ -1406,6 +1608,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
output->display( input = it_so_sec name = `it_so_sec` ).
|
||||
output->display( input = it_ha_sec name = `it_ha_sec` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `Deleting adjacent duplicate entries` ).
|
||||
output->display( `Original table content (restored before` &&
|
||||
` each of the following examples)` ).
|
||||
@@ -1429,6 +1633,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it_st2 name = `it_st2` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->display( `58) Deleting adjacent duplicates based on` &&
|
||||
` primary table key` ).
|
||||
@@ -1441,6 +1646,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
it_st2 = it_st.
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `59) Deleting adjacent duplicates by comparing ` &&
|
||||
`all field values` ).
|
||||
|
||||
@@ -1450,6 +1657,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
it_st2 = it_st.
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `60) Deleting adjacent duplicates by comparing ` &&
|
||||
`specific field values` ).
|
||||
|
||||
@@ -1459,6 +1668,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
it_st2 = it_st.
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `61) Deleting adjacent duplicates by using a` &&
|
||||
` table key` ).
|
||||
|
||||
@@ -1467,6 +1678,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = it_st2 name = `it_st2` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `62) Deleting the entire internal table content` ).
|
||||
|
||||
CLEAR it_st.
|
||||
@@ -1474,8 +1687,17 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
"Additionally, FREE releases memory space.
|
||||
FREE it_st2.
|
||||
|
||||
"Excursion: Assigning an empty constructor expression with VALUE clears
|
||||
"the internal table.
|
||||
DATA(it_str) = VALUE string_table( ( `a` ) ( `b` ) ( `c` ) ).
|
||||
|
||||
it_str = VALUE #( ).
|
||||
|
||||
output->display( input = it_st name = `it_st` ).
|
||||
output->display( input = it_st2 name = `it_st2` ).
|
||||
output->display( input = it_str name = `it_str` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `Excursions` ).
|
||||
output->display( `63) Secondary table keys and hashed tables` ).
|
||||
@@ -1515,6 +1737,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||
|
||||
output->display( input = line_of_ht name = `line_of_ht` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `64) Empty keys in internal table created inline` ).
|
||||
"This example visualizes the fact that when using an inline
|
||||
"construction like INTO TABLE @DATA(itab) in SELECT statements, the
|
||||
|
||||
@@ -117,7 +117,6 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
TYPES: ref_type TYPE REF TO local_class.
|
||||
DATA: ref1d TYPE ref_type.
|
||||
|
||||
|
||||
IF ref1a IS INITIAL
|
||||
AND ref1b IS INITIAL
|
||||
AND ref1c IS INITIAL
|
||||
@@ -127,6 +126,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
output->display( `One or more of the declared reference ` &&
|
||||
`variables are not initial.` ).
|
||||
ENDIF.
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `2) Creating objects` ).
|
||||
|
||||
@@ -145,10 +146,9 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
ref2a = NEW #( ).
|
||||
DATA(ref2b) = NEW local_class( ).
|
||||
|
||||
"Alternative syntax.
|
||||
"NEW replaces the following statement
|
||||
CREATE OBJECT ref2a.
|
||||
|
||||
|
||||
IF ref2a IS INSTANCE OF local_class
|
||||
AND ref2b IS INSTANCE OF local_class.
|
||||
output->display( `ref2a and ref2b point to instances ` &&
|
||||
@@ -157,7 +157,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
output->display( `One or more of the reference variables ` &&
|
||||
`do not point to instances of the class local_class.` ).
|
||||
ENDIF.
|
||||
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `3) Assigning object references` ).
|
||||
|
||||
@@ -176,6 +177,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
ELSE.
|
||||
output->display( `ref3b has not been assigned to ref3a.` ).
|
||||
ENDIF.
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `4) Overwriting object references` ).
|
||||
|
||||
@@ -194,6 +197,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
ref4 = NEW #( ).
|
||||
|
||||
output->display( input = ref4->no_of_instances name = `ref4->no_of_instances` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `5) Keeping references variables in internal tables` ).
|
||||
|
||||
@@ -214,6 +219,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
ENDDO.
|
||||
|
||||
output->display( input = itab5 name = `itab5` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `6) Clearing object references` ).
|
||||
|
||||
@@ -234,6 +241,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
ELSE.
|
||||
output->display( `ref6 is not initial.` ).
|
||||
ENDIF.
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `7) Accessing and using attributes` ).
|
||||
|
||||
@@ -262,6 +271,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
output->display( input = obj_instance_attr name = `obj_instance_attr` ).
|
||||
output->display( input = obj_static_attr_obj name = `obj_static_attr_obj` ).
|
||||
output->display( input = class_static_attr name = `class_static_attr` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `8) Calling static and instance methods` ).
|
||||
|
||||
@@ -296,6 +307,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
hallo_static_method( ).
|
||||
|
||||
output->display( input = string name = `string` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `9) Calling methods: Examples` &&
|
||||
` with importing parameters` ).
|
||||
@@ -340,6 +353,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
lcl_demo=>addition_optional( i_add_mand = 1 ).
|
||||
|
||||
output->display( input = lcl_demo=>calc_result name = `lcl_demo=>calc_result` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `10) Calling methods: Examples ` &&
|
||||
`with exporting parameters` ).
|
||||
@@ -366,6 +381,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
|
||||
output->display( input = hallo name = `hallo` ).
|
||||
output->display( input = subtraction_result name = `subtraction_result` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `11) Calling methods: Example with changing parameter` ).
|
||||
|
||||
@@ -378,6 +395,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
lcl_demo=>square_root( CHANGING i_sqr = num ).
|
||||
|
||||
output->display( input = num name = `num` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `12) Calling methods: Examples with returning parameters` ).
|
||||
|
||||
@@ -440,6 +459,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
output->display( input = random_no1 name = `random_no1` ).
|
||||
output->display( input = random_no2 name = `random_no2` ).
|
||||
output->display( input = random_no3 name = `random_no3` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `13) Calling methods: Examples with error handling` ).
|
||||
|
||||
@@ -480,6 +501,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
ENDTRY.
|
||||
|
||||
output->display( input = greets name = `greets` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `14) Constructors` ).
|
||||
|
||||
@@ -530,6 +553,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
|
||||
output->display( input = lcl_constructors=>stat_text name = `lcl_constructors=>stat_text` ).
|
||||
output->display( input = lcl_constructors=>stat_number name = `lcl_constructors=>stat_number` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `15) Parameters: Generic types` ).
|
||||
|
||||
@@ -568,6 +593,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
lcl_demo=>generic_tab( EXPORTING i_anytab = c_tab ).
|
||||
|
||||
output->display( input = lcl_demo=>some_data->* name = `lcl_demo=>some_data->*` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `16) Inheritance: Method redefinition` ).
|
||||
|
||||
@@ -597,6 +624,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
output->display( input = first_string name = `first_string` ).
|
||||
output->display( input = second_string name = `second_string` ).
|
||||
output->display( input = third_string name = `third_string` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `17) Polymorphism and Casting` ).
|
||||
|
||||
@@ -637,7 +666,9 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
output->display( input = str1 name = `str1` ).
|
||||
output->display( input = str2 name = `str2` ).
|
||||
|
||||
output->next_section( `18) Downcast` ).
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `18a) Downcast` ).
|
||||
|
||||
"In this example, the possibility of downcasts are checked, i. e. the
|
||||
"assignment of a more generic object reference variable to a specific
|
||||
@@ -738,6 +769,34 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
|
||||
output->display( input = dc_check name = `dc_check` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `18b) Excursion RTTI: Downcasts and Method Chaining` ).
|
||||
|
||||
"Downcasts particularly play, for example, a role in the context of
|
||||
"retrieving type information using RTTI. Method chaining is handy
|
||||
"because it reduces the lines of code in this case.
|
||||
"The example contains the retrieval of type information for a
|
||||
"structure (structure components).
|
||||
"Due to the method chaining in the second example, the three
|
||||
"statements in the first example are reduced to one statement.
|
||||
|
||||
DATA struct4cast TYPE zdemo_abap_carr.
|
||||
|
||||
DATA(rtti_a) = cl_abap_typedescr=>describe_by_data( struct4cast ).
|
||||
DATA(rtti_b) = CAST cl_abap_structdescr( rtti_a ).
|
||||
DATA(rtti_c) = rtti_b->components.
|
||||
|
||||
output->display( input = rtti_c name = `rtti_c` ).
|
||||
|
||||
DATA(rtti_d) = CAST cl_abap_structdescr(
|
||||
cl_abap_typedescr=>describe_by_data( struct4cast )
|
||||
)->components.
|
||||
|
||||
output->display( input = rtti_d name = `rtti_d` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `19) Interfaces` ).
|
||||
|
||||
"Addressing instance interface components using interface reference variable
|
||||
@@ -816,6 +875,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
output->display( input = intf_const1 name = `intf_const1` ).
|
||||
output->display( input = intf_const2 name = `intf_const2` ).
|
||||
output->display( input = intf_const3 name = `intf_const3` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `20) Singleton` ).
|
||||
|
||||
@@ -862,6 +923,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
|
||||
output->display( input = timestamp name = `timestamp` ).
|
||||
output->display( input = no_of_instances name = `no_of_instances` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `21) Factory method in an abstract class` ).
|
||||
|
||||
@@ -895,6 +958,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
ENDTRY.
|
||||
|
||||
output->display( input = lcl_abstract=>message name = `lcl_abstract=>message` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `22) Friendship: Accessing components of friends` ).
|
||||
|
||||
@@ -912,6 +977,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
DATA(string_table) = zcl_demo_abap_objects_friend=>get_strings( ).
|
||||
|
||||
output->display( input = string_table name = `string_table` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `23) Self-reference me` ).
|
||||
|
||||
@@ -930,6 +997,8 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
||||
|
||||
output->display( input = string_without_me name = `string_without_me` ).
|
||||
output->display( input = string_with_me name = `string_with_me` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `24) Events` ).
|
||||
|
||||
|
||||
@@ -389,13 +389,13 @@ CLASS zcl_demo_abap_prog_flow_logic IMPLEMENTATION.
|
||||
|
||||
CASE TYPE OF oref_check.
|
||||
WHEN TYPE zcl_demo_abap_prog_flow_logic.
|
||||
output->display( |Type zcl_demo_abap_prog_flow_logic? True!| ).
|
||||
output->display( `Type zcl_demo_abap_prog_flow_logic? True!` ).
|
||||
WHEN TYPE if_oo_adt_classrun.
|
||||
output->display( |Type if_oo_adt_classrun? True!| ).
|
||||
output->display( `Type if_oo_adt_classrun? True!` ).
|
||||
WHEN TYPE zcl_demo_abap_sql.
|
||||
output->display( |Type zcl_demo_abap_sql? True!| ).
|
||||
output->display( `Type zcl_demo_abap_sql? True!` ).
|
||||
WHEN OTHERS.
|
||||
output->display( |Other type.| ).
|
||||
output->display( `Other type.` ).
|
||||
ENDCASE.
|
||||
|
||||
"The same logic as above is realized in the following IF statements
|
||||
@@ -404,13 +404,13 @@ CLASS zcl_demo_abap_prog_flow_logic IMPLEMENTATION.
|
||||
"This type is also true for the object reference variable. This class
|
||||
"implements the interface.
|
||||
IF oref_check IS INSTANCE OF if_oo_adt_classrun.
|
||||
output->display( |Type if_oo_adt_classrun? True!| ).
|
||||
output->display( `Type if_oo_adt_classrun? True!` ).
|
||||
ELSEIF oref_check IS INSTANCE OF zcl_demo_abap_prog_flow_logic.
|
||||
output->display( |Type zcl_demo_abap_prog_flow_logic? True!| ).
|
||||
output->display( `Type zcl_demo_abap_prog_flow_logic? True!` ).
|
||||
ELSEIF oref_check IS INSTANCE OF zcl_demo_abap_sql.
|
||||
output->display( |Type zcl_demo_abap_sql? True!| ).
|
||||
output->display( `Type zcl_demo_abap_sql? True!` ).
|
||||
ELSE.
|
||||
output->display( |Other type.| ).
|
||||
output->display( `Other type.` ).
|
||||
ENDIF.
|
||||
|
||||
**********************************************************************
|
||||
|
||||
@@ -138,7 +138,7 @@ CLASS zcl_demo_abap_string_proc IMPLEMENTATION.
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `3) String Templates (1): Constructing Strings` ).
|
||||
output->next_section( `3a) String Templates (1): Constructing Strings` ).
|
||||
|
||||
"The expression must be convertible to a string. A blank (not
|
||||
"within the curly brackets) means a blank in the resulting string.
|
||||
@@ -148,6 +148,10 @@ CLASS zcl_demo_abap_string_proc IMPLEMENTATION.
|
||||
DATA(str_c4) = |{ str_c1 } { sy-uname }, | &&
|
||||
|{ str_c2 } { str_c3 } you?|.
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `3b) String Templates (2): Control Characters` ).
|
||||
|
||||
"Interpretation of character combinations as control characters
|
||||
"\n interpreted as a line break
|
||||
DATA(str_c5) = |{ str_c1 }\n{ sy-uname },| &&
|
||||
@@ -156,9 +160,26 @@ CLASS zcl_demo_abap_string_proc IMPLEMENTATION.
|
||||
output->display( input = str_c4 name = `str_c4` ).
|
||||
output->display( input = str_c5 name = `str_c5` ).
|
||||
|
||||
"Excursion: Class CL_ABAP_CHAR_UTILITIES provides attributes and methods as utilities for string processing.
|
||||
"See the class documentation.
|
||||
"The following examples demonstrate that attributes that contain control characters can be replaced by
|
||||
"a representation of control characters in a string template.
|
||||
DATA(str_c6) = |{ str_c1 }{ cl_abap_char_utilities=>newline }{ sy-uname }|.
|
||||
DATA(str_c7) = |{ str_c1 }\n{ sy-uname }|.
|
||||
DATA(str_c8) = |{ str_c1 }{ cl_abap_char_utilities=>horizontal_tab }{ sy-uname }|.
|
||||
DATA(str_c9) = |{ str_c1 }\t{ sy-uname }|.
|
||||
DATA(str_c10) = |{ str_c1 }{ cl_abap_char_utilities=>cr_lf }{ sy-uname }|.
|
||||
DATA(str_c11) = |{ str_c1 }\r\n{ sy-uname }|.
|
||||
ASSERT str_c10 = str_c11.
|
||||
|
||||
output->display( input = str_c6 name = `str_c6` ).
|
||||
output->display( input = str_c7 name = `str_c7` ).
|
||||
output->display( input = str_c8 name = `str_c8` ).
|
||||
output->display( input = str_c9 name = `str_c9` ).
|
||||
|
||||
**********************************************************************
|
||||
|
||||
output->next_section( `4) String Templates (2): Formatting Options` ).
|
||||
output->next_section( `4) String Templates (3): Formatting Options` ).
|
||||
"Time, date
|
||||
DATA(str_d1) =
|
||||
|Date: { cl_abap_context_info=>get_system_date( ) DATE = USER }\n| &&
|
||||
|
||||
@@ -32,6 +32,8 @@ define view entity zdemo_abap_cds_ve_agg_exp
|
||||
// - A GROUP BY clause is required. It must list all non-aggregated fields from the element list.
|
||||
// - Additions: If ALL is used, all rows in the result set are respected. This is the default setting.
|
||||
// If DISTINCT is used, only distinct values of an argument are respected.
|
||||
// - Note: There may or may not be spaces between the parentheses following avg, min, etc., and the
|
||||
// content specified within.
|
||||
|
||||
// AVG (Returns the average value of an argument)
|
||||
avg( seatsocc as abap.dec(15,2)) as avg_seats_occ,
|
||||
|
||||
Reference in New Issue
Block a user