Update content
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user