Update content
This commit is contained in:
@@ -721,7 +721,7 @@ operator](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?f
|
||||
`FILTER` operator constructs an internal table according to a specified type (which can be an explicitly specified, non-generic table type or the `#` character as a symbol for the [operand type](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenoperand_type_glosry.htm) before the first parenthesis).
|
||||
- The lines for the new internal table are taken from an
|
||||
existing internal table based on conditions specified in a `WHERE` clause. Note that the table type of the existing internal table must be convertible into the specified target type.
|
||||
- The conditions can either be based on wither single values or a [filter
|
||||
- The conditions can either be based on either single values or a [filter
|
||||
table](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenconstructor_expr_filter_table.htm).
|
||||
- Additions:
|
||||
|
||||
@@ -732,7 +732,7 @@ operator](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?f
|
||||
|
||||
Examples:
|
||||
```abap
|
||||
"FILTER an conditions based on single values
|
||||
"FILTER on conditions based on single values
|
||||
"Assumption the component num is of type i.
|
||||
DATA itab1 TYPE SORTED TABLE OF struc WITH NON-UNIQUE KEY num.
|
||||
DATA itab2 TYPE STANDARD TABLE OF struc WITH NON-UNIQUE SORTED KEY sec_key COMPONENTS num.
|
||||
@@ -831,7 +831,7 @@ The following code snippets include [`READ TABLE`](https://help.sap.com/doc/abap
|
||||
for example, using an inline declaration (`ASSIGNING <fs>`). When you then access the field symbol, it means that you access the found table line. There is no actual copying of
|
||||
content. Therefore, modifying the field symbol means
|
||||
modifying the table line directly. Note that you cannot use the
|
||||
`TRANSPORTING` addition, since the entire table is
|
||||
`TRANSPORTING` addition since the entire table is
|
||||
assigned to the field symbol.
|
||||
|
||||
``` abap
|
||||
@@ -853,7 +853,7 @@ The following code snippets include [`READ TABLE`](https://help.sap.com/doc/abap
|
||||
```
|
||||
|
||||
**Which to use then?** Since all syntax options provide the same
|
||||
functionality, it depends on you and your use case. For example, the
|
||||
functionality, your use case, the
|
||||
performance or readability of the code may play a role. For more information, see
|
||||
the programming guidelines for the [target
|
||||
area (F1 docu for standard ABAP)](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abentable_output_guidl.htm "Guideline").
|
||||
@@ -1005,8 +1005,8 @@ READ TABLE it ASSIGNING FIELD-SYMBOL(<fs>) WITH KEY b = 2.
|
||||
DATA(comp3) = <fs>-c.
|
||||
|
||||
READ TABLE it REFERENCE INTO DATA(dref) WITH KEY b = 2.
|
||||
DATA(comp4) = dref->*-c.
|
||||
"Note: dref->c, which is more comfortable, also works
|
||||
DATA(comp4) = dref->c.
|
||||
"Note: The syntax dref->*-c is also possible.
|
||||
```
|
||||
|
||||
<p align="right">(<a href="#top">back to top</a>)</p>
|
||||
@@ -1078,21 +1078,50 @@ table content or in specific parts of it, you can use [`LOOP
|
||||
AT`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaploop_at_itab.htm)
|
||||
statements to process table lines sequentially. As above, you
|
||||
can use multiple options for target areas: work area, field
|
||||
symbol, data reference. The following snippets contain only the work
|
||||
area. There are multiple additions to the `LOOP AT`
|
||||
symbol, data reference. There are multiple additions to the `LOOP AT`
|
||||
statements to further restrict the table content to be processed.
|
||||
|
||||
Simple form:
|
||||
``` abap
|
||||
LOOP AT it INTO wa. "Inline declarations possible: INTO DATA(wa)
|
||||
"The target is an existing work area.
|
||||
DATA wa LIKE LINE OF it.
|
||||
|
||||
LOOP AT it INTO wa.
|
||||
"No addition of the loop statement; all lines are processed
|
||||
"Statements in this block are relevant for each individual table line.
|
||||
...
|
||||
ENDLOOP.
|
||||
|
||||
"Work area declared inline
|
||||
LOOP AT itab INTO DATA(wa_inl).
|
||||
...
|
||||
ENDLOOP.
|
||||
|
||||
"Field symbols
|
||||
FIELD-SYMBOLS <fs> LIKE LINE OF it.
|
||||
|
||||
LOOP AT it ASSIGNING <fs>.
|
||||
...
|
||||
ENDLOOP.
|
||||
|
||||
LOOP AT it ASSIGNING FIELD-SYMBOL(<fs_inl>).
|
||||
...
|
||||
ENDLOOP.
|
||||
|
||||
"Data reference variables
|
||||
DATA dref TYPE REF TO dbtab.
|
||||
|
||||
LOOP AT it REFERENCE INTO dref.
|
||||
...
|
||||
ENDLOOP.
|
||||
|
||||
LOOP AT it REFERENCE INTO DATA(dref_inl).
|
||||
...
|
||||
ENDLOOP.
|
||||
```
|
||||
|
||||
- The order in which tables are iterated depends on the table category.
|
||||
- Index tables are looped thorugh in ascending order by the index.
|
||||
- Index tables are looped over in ascending order by the index.
|
||||
- Hashed tables are looped in the order in which the lines were added to the table. You can also sort the table before the loop.
|
||||
- During the loop, the system field `sy-tabix` is set to the number of the currently processed table
|
||||
line. This is not true for hashed tables. There, `sy-tabix` is `0`.
|
||||
@@ -1384,7 +1413,7 @@ DELETE TABLE it_sec WITH TABLE KEY sec_key COMPONENTS ...
|
||||
DELETE it WHERE a < 6.
|
||||
```
|
||||
|
||||
`DELETE ADJACENT DUPLICATES` statements allow you to delete all adjacent lines except for the first line that have the same content in certain components. You usually need to doe some appropriate sorting before using these statements.
|
||||
`DELETE ADJACENT DUPLICATES` statements allow you to delete all adjacent lines except for the first line that have the same content in certain components. You usually need to perform some appropriate sorting before using these statements.
|
||||
``` abap
|
||||
"Implicitly uses the primary table key
|
||||
|
||||
@@ -1421,13 +1450,17 @@ allocated. If the table is filled again later, the memory space is still
|
||||
available, which is a performance advantag over
|
||||
clearing an internal table with `FREE`. Such a statement also
|
||||
deletes the table content, but it also releases the memory
|
||||
space.
|
||||
space.
|
||||
Note that an assignment using the `VALUE` operator without entries in the parentheses clears the internal table.
|
||||
|
||||
``` abap
|
||||
CLEAR it.
|
||||
|
||||
"Additionally, it releases memory space.
|
||||
"This statement additionally releases memory space.
|
||||
FREE it.
|
||||
|
||||
"Assignment using the VALUE operator without entries in the parentheses
|
||||
it = VALUE #( ).
|
||||
```
|
||||
<p align="right">(<a href="#top">back to top</a>)</p>
|
||||
|
||||
|
||||
@@ -295,9 +295,9 @@ ref_struc_1 = NEW #( ).
|
||||
DATA(ref_struc_2) = NEW structured_type( ).
|
||||
|
||||
... ref_struc_1->comp1 ...
|
||||
... ref_struc_1->*comp1 ... "Using the dereferencing operator
|
||||
... ref_struc_1->*-comp1 ... "Using the dereferencing operator
|
||||
... ref_struc_2->-comp2 ...
|
||||
... ref_struc_2->*-comp2 ... "Using the dereferencing operator
|
||||
... ref_struc_2->*-comp2 ... "Using the dereferencing operator
|
||||
```
|
||||
|
||||
Nested components can be addressed using chaining:
|
||||
|
||||
@@ -613,7 +613,7 @@ SELECT FROM zdemo_abap_flsch
|
||||
- Expressions in an ABAP SQL statement that are passed to the database
|
||||
system for evaluation.
|
||||
- For example, SQL expressions can be specified as columns in the
|
||||
`SELECT` as demonstrated in most of the following examples.
|
||||
`SELECT` list as demonstrated in most of the following examples.
|
||||
Find information on more possible positions and general information
|
||||
on SQL expressions
|
||||
[here](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapsql_expr.htm)
|
||||
@@ -1097,36 +1097,36 @@ just demonstrate how the `WHERE` clause might look like.
|
||||
SELECT *
|
||||
FROM dbtab
|
||||
WHERE comp1 = 'abc' "Equals some value
|
||||
|
||||
"More example WHERE conditions:
|
||||
comp2 > 100 "Greater than some value; alternatively GT is possible
|
||||
|
||||
"Not equals plus an additional condition that must be respected
|
||||
comp3 <> 100 AND comp4 = 'xyz'
|
||||
|
||||
"(Not) between a value range
|
||||
comp5 BETWEEN 1 AND 10
|
||||
|
||||
"More example WHERE conditions:
|
||||
comp2 > 100 "Greater than some value; alternatively GT is possible
|
||||
|
||||
"Not equals plus an additional condition that must be respected
|
||||
comp3 <> 100 AND comp4 = 'xyz'
|
||||
|
||||
"(Not) between a value range
|
||||
comp5 BETWEEN 1 AND 10
|
||||
comp6 NOT BETWEEN 1 AND 10
|
||||
|
||||
"A character literal has a certain pattern, preceded and
|
||||
"followed by any string.
|
||||
"comp7 LIKE '%XYZ%'
|
||||
|
||||
"The second character is not Y. _ stands for any character.
|
||||
comp8 NOT LIKE '_Y%'
|
||||
|
||||
"Contains one of the values specified in the parentheses
|
||||
comp9 IN ( 'ABC', 'DEF', 'GHI' )
|
||||
|
||||
"Does not contain one of the values specified in the parentheses
|
||||
comp10 NOT IN ( 'JKL', 'MNO' )
|
||||
|
||||
"Checking if an operand has an initial value
|
||||
comp11 IS INITIAL
|
||||
|
||||
"Combination of logical expression using AND, OR and parentheses
|
||||
( comp12 = a AND comp13 < b ) OR ( comp14 > c AND comp15 <> d )
|
||||
|
||||
|
||||
"A character literal has a certain pattern, preceded and
|
||||
"followed by any string.
|
||||
"comp7 LIKE '%XYZ%'
|
||||
|
||||
"The second character is not Y. _ stands for any character.
|
||||
comp8 NOT LIKE '_Y%'
|
||||
|
||||
"Contains one of the values specified in the parentheses
|
||||
comp9 IN ( 'ABC', 'DEF', 'GHI' )
|
||||
|
||||
"Does not contain one of the values specified in the parentheses
|
||||
comp10 NOT IN ( 'JKL', 'MNO' )
|
||||
|
||||
"Checking if an operand has an initial value
|
||||
comp11 IS INITIAL
|
||||
|
||||
"Combination of logical expression using AND, OR and parentheses
|
||||
( comp12 = a AND comp13 < b ) OR ( comp14 > c AND comp15 <> d )
|
||||
|
||||
INTO TABLE @DATA(itab_where).
|
||||
```
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ All components, i. e.
|
||||
- attributes (using `TYPES`, `DATA`, `CLASS-DATA`, and `CONSTANTS` for data types and data
|
||||
objects),
|
||||
- methods (using `METHODS` and `CLASS-METHODS`),
|
||||
- events `EVENTS` and `CLASS-EVENTS` as well as
|
||||
- events (using `EVENTS` and `CLASS-EVENTS`) as well as
|
||||
- interfaces,
|
||||
|
||||
are declared in the declaration part of the class. There, they must be
|
||||
@@ -627,10 +627,10 @@ stat_meth( b ).
|
||||
class_name=>meth( EXPORTING a = b c = d "a/c: importing parameters in the method signature
|
||||
IMPORTING e = f ). "e: exporting parameter in the method signature
|
||||
|
||||
"If f is not yet available, you could also declare it inline to store the value.
|
||||
"To store the value of the parameter, you may also declare it inline.
|
||||
|
||||
class_name=>meth( EXPORTING a = b c = d
|
||||
IMPORTING e = DATA(f) ). "f receives type of e
|
||||
IMPORTING e = DATA(z) ).
|
||||
|
||||
"Calling (static) methods having a changing parameter;
|
||||
"should be reserved for changing an existing local variable and value
|
||||
@@ -806,7 +806,7 @@ Note the concept of static and dynamic type in this context:
|
||||
must be triggered explicitly using the [casting
|
||||
operator](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencasting_operator_glosry.htm "Glossary Entry")
|
||||
[`CAST`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenconstructor_expression_cast.htm). You might see code using the older
|
||||
[`?=`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapmove_cast.htm)).
|
||||
operator [`?=`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapmove_cast.htm).
|
||||
- See more information in the topic [Assignment Rules for Reference
|
||||
Variables](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenconversion_references.htm).
|
||||
|
||||
@@ -833,7 +833,7 @@ super_ref = NEW lcl_sub( ).
|
||||
manually. Just an assignment like `oref_sub = oref_super.`
|
||||
does not work. A syntax error occurs saying the right-hand variable's type cannot be converted to the left-hand variable's type.
|
||||
- If you indeed want to carry out this casting, you must use
|
||||
`CAST` (or you might see code using the older `?=`) to overcome this syntax error (but just the syntax error!). Note: You might also use these casting operators for the upcasts. That means `oref_super = oref_sub.` has the same effect as `oref_super = CAST #( oref_sub ).`. Using the casting operator for upcasts is usually not necessary.
|
||||
`CAST` (or you might see code using the older operator `?=`) to overcome this syntax error (but just the syntax error!). Note: You might also use these casting operators for the upcasts. That means `oref_super = oref_sub.` has the same effect as `oref_super = CAST #( oref_sub ).`. Using the casting operator for upcasts is usually not necessary.
|
||||
- At runtime, the assignment is checked and if the conversion does not work, you face a (catchable) exception. Even more so, the assignment `oref_sub = CAST #( oref_super ).` does not throw a syntax error but it does not work in this example either because it violates the rule mentioned above (`oref_sub` is more specific than `oref_super`).
|
||||
- To check whether such an assignment is possible
|
||||
on specific classes, you can use the predicate expression [`IS INSTANCE OF`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenlogexp_instance_of.htm)
|
||||
@@ -863,6 +863,25 @@ IF oref_super IS INSTANCE OF lcl_sub.
|
||||
oref_sub = CAST #( oref_super ).
|
||||
...
|
||||
ENDIF.
|
||||
|
||||
"Excursion RTTI: Downcasts, CAST 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 below shows the retrieval of type information
|
||||
"regarding the components of a structure.
|
||||
"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.
|
||||
|
||||
DATA(rtti_d) = CAST cl_abap_structdescr(
|
||||
cl_abap_typedescr=>describe_by_data( struct4cast )
|
||||
)->components.
|
||||
```
|
||||
|
||||
<p align="right">(<a href="#top">back to top</a>)</p>
|
||||
@@ -884,7 +903,7 @@ Interfaces ...
|
||||
- are different from classes in the following ways:
|
||||
- They only consist of a part declaring the components without an
|
||||
implementation part. The implementation is done in classes that use the interface.
|
||||
- There a no visibility sections. All components of an interface are visible.
|
||||
- There are no visibility sections. All components of an interface are visible.
|
||||
- No instances can be created from interfaces.
|
||||
- Declarations as mentioned for classes, e. g. `DATA`,
|
||||
`CLASS-DATA`, `METHODS`,
|
||||
@@ -1086,7 +1105,7 @@ can trigger the processing of [processing blocks](https://help.sap.com/doc/abapd
|
||||
[`EVENTS`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapevents.htm)
|
||||
statement. Note that they can only be raised in instance methods of the same class.
|
||||
- static event using
|
||||
([`CLASS-EVENTS`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapclass-events.htm)). They can be raised in all methods of the same class or of a class that implements the interface. Static event handlers can be called by the event independently of an instance of the class.
|
||||
[`CLASS-EVENTS`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapclass-events.htm). They can be raised in all methods of the same class or of a class that implements the interface. Static event handlers can be called by the event independently of an instance of the class.
|
||||
|
||||
``` abap
|
||||
"Declaration part of a class/interface
|
||||
|
||||
@@ -714,6 +714,7 @@ chaining](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?f
|
||||
comes in handy, too.
|
||||
``` abap
|
||||
"The properties of a type are retrieved using RTTI
|
||||
"In ADT, you may want to choose CTRL + SPACE after ...=> to explore the options.
|
||||
|
||||
DATA(some_type) = cl_abap_typedescr=>describe_by_data( var ).
|
||||
|
||||
@@ -730,6 +731,12 @@ DATA(components) = CAST cl_abap_structdescr(
|
||||
DATA(attributes) = CAST cl_abap_classdescr(
|
||||
cl_abap_classdescr=>describe_by_name( 'CL_SOME_CLASS' )
|
||||
)->attributes.
|
||||
|
||||
"Casting and method chaining as above in contrast to the following extra declarations
|
||||
"If the variables were not declared inline as in the example, there would be even more lines of code.
|
||||
DATA(a) = cl_abap_typedescr=>describe_by_data( some_struc ).
|
||||
DATA(b) = CAST cl_abap_structdescr( a ).
|
||||
DATA(c) = b->components.
|
||||
```
|
||||
|
||||
The following example demonstrates the dynamic creation of data objects.
|
||||
|
||||
@@ -271,6 +271,14 @@ Syntax examples:
|
||||
"Control characters
|
||||
s4 = |{ s1 }\n{ s2 }\nSee you.|. "\n is interpreted as a line feed
|
||||
|
||||
"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.
|
||||
ASSERT cl_abap_char_utilities=>newline = |\n|.
|
||||
ASSERT cl_abap_char_utilities=>horizontal_tab = |\t|.
|
||||
ASSERT cl_abap_char_utilities=>cr_lf = |\r\n|.
|
||||
|
||||
"Various formatting options
|
||||
"Time and date
|
||||
"Formatting according to the user master data
|
||||
@@ -1432,7 +1440,7 @@ Patterns are not case-sensitive except for characters marked with
|
||||
`sy-fdpos` returns the offset of the first occurrence.
|
||||
Otherwise, it contains the length of the searched string.
|
||||
``` abap
|
||||
s1 = `abc_def_ghi`.
|
||||
DATA(s1) = `abc_def_ghi`.
|
||||
|
||||
"Pattern: f is preceded by any character sequence, must be followed
|
||||
"by '_' and then followed by any character sequence
|
||||
@@ -1527,28 +1535,26 @@ function](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?f
|
||||
|
||||
Syntax examples:
|
||||
``` abap
|
||||
s1 = `Cathy's black cat on the mat played with Matt.`.
|
||||
DATA(s1) = `Cathy's black cat on the mat played with Matt.`.
|
||||
|
||||
"Determining the position of the first occurrence
|
||||
"Here, the parameter occ is 1 by default.
|
||||
s2 = find( val = s1 pcre = `at.` ). "1
|
||||
DATA(int) = find( val = s1 pcre = `at.` ). "1
|
||||
|
||||
"Determining the number of all occurrences.
|
||||
"Respects all 'a' characters not followed by 't', all 'at' plus 'att'
|
||||
s2 = count( val = s1 pcre = `at*` ). "6
|
||||
int = count( val = s1 pcre = `at*` ). "6
|
||||
|
||||
"Respects all 'at' plus 'att'
|
||||
s2 = count( val = s1 pcre = `at+` ). "4
|
||||
int = count( val = s1 pcre = `at+` ). "4
|
||||
|
||||
"Extracting a substring matching a given pattern
|
||||
s1 = `The email address is jon.doe@email.com.`.
|
||||
s2 = match( val = s1
|
||||
pcre = `\w+(\.\w+)*@(\w+\.)+(\w{2,4})` ). "jon.doe@email.com
|
||||
DATA(s2) = match( val = `The email address is jon.doe@email.com.`
|
||||
pcre = `\w+(\.\w+)*@(\w+\.)+(\w{2,4})` ). "jon.doe@email.com
|
||||
|
||||
"Predicate function matches
|
||||
"Checking the validitiy of an email address
|
||||
s1 = `jon.doe@email.com`.
|
||||
IF matches( val = s1
|
||||
IF matches( val = `jon.doe@email.com`
|
||||
pcre = `\w+(\.\w+)*@(\w+\.)+(\w{2,4})` ). "true
|
||||
...
|
||||
ENDIF.
|
||||
@@ -1557,7 +1563,7 @@ ENDIF.
|
||||
"SUBMATCHES addition: Storing submatches in variables
|
||||
"Pattern: anything before and after ' on '
|
||||
FIND PCRE `(.*)\son\s(.*)` IN s1 IGNORING CASE SUBMATCHES DATA(a) DATA(b).
|
||||
"a: 'Cathy's black cat' / b: 'the mat played with Matt'.
|
||||
"a: 'Cathy's black cat' / b: 'the mat played with Matt.'.
|
||||
|
||||
"Determining the number of letters in a string
|
||||
FIND ALL OCCURRENCES OF PCRE `[A-Za-z]` IN s1 MATCH COUNT DATA(c). "36
|
||||
@@ -1616,7 +1622,8 @@ Keyword Documentation.
|
||||
|
||||
Syntax examples:
|
||||
``` abap
|
||||
s1 = `ab apppc app`.
|
||||
DATA(s1) = `ab apppc app`.
|
||||
DATA s2 TYPE string.
|
||||
|
||||
"Replaces 'p' with 2 - 4 repetitions, all occurences
|
||||
s2 = replace( val = s1 pcre = `p{2,4}` with = `#` occ = 0 ). "ab a#c a#
|
||||
|
||||
@@ -208,12 +208,19 @@ is triggered to access the transactional buffer of a RAP BO. As
|
||||
mentioned, for unmanaged RAP BOs or unmanaged parts of managed RAP BOs,
|
||||
the handler methods that are called are part of an ABAP behavior pool.
|
||||
|
||||
The global class of an ABP has the addition [`FOR BEHAVIOR OF
|
||||
bdef`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapclass_for_behavior_of.htm)
|
||||
The global class of an ABP has the addition [`FOR BEHAVIOR OF bdef`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapclass_for_behavior_of.htm)
|
||||
to the definition while `bdef` stands for the name of the BDEF.
|
||||
This class is usually empty.
|
||||
|
||||
The implementation is done in local classes in the CCIMP include. There,
|
||||
```abap
|
||||
CLASS zbp_demo_abap_rap_draft_m DEFINITION PUBLIC ABSTRACT FINAL FOR BEHAVIOR OF zdemo_abap_rap_draft_m.
|
||||
ENDCLASS.
|
||||
|
||||
CLASS zbp_demo_abap_rap_draft_m IMPLEMENTATION.
|
||||
ENDCLASS.
|
||||
```
|
||||
|
||||
The actual implementation is done in local classes in the CCIMP include. There,
|
||||
two kinds of local classes are to be defined and implemented that are
|
||||
related to the RAP BO's runtime: one or more [handler
|
||||
classes](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabp_handler_class_glosry.htm "Glossary Entry")
|
||||
@@ -377,7 +384,7 @@ CLASS lsc_bdef DEFINITION INHERITING FROM cl_abap_behavior_saver.
|
||||
PROTECTED SECTION.
|
||||
|
||||
"For final calculations and data modifications involving all
|
||||
"BOs in the current RAP LUW
|
||||
"BOs in the current RAP transaction
|
||||
METHODS finalize REDEFINITION.
|
||||
|
||||
"Checks the consistency of the transactional buffer before
|
||||
@@ -588,7 +595,7 @@ Bullet points on selected `%` components:
|
||||
and data fields of a RAP BO instance which indicate flags.
|
||||
- Used to get information on which fields are provided or set a
|
||||
flag for which fields are requested by RAP BO providers or RAP
|
||||
BO consumers respectively during the current transaction.
|
||||
BO consumers respectively during the current EML request.
|
||||
- For this purpose, the value of each field in the
|
||||
`%control` structure is of type
|
||||
`ABP_BEHV_FLAG`. For the value setting,
|
||||
@@ -1023,7 +1030,7 @@ instances](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?
|
||||
- In contrast to the primary key and the preliminary ID
|
||||
`%pid` for late numbering scenarios, `%cid` (and
|
||||
`%cid_ref`) are only available on a short-term basis
|
||||
for the current ABAP EML request within the [RAP interaction phase](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_int_phase_glosry.htm "Glossary Entry") in one [RAP LUW](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_luw_glosry.htm "Glossary Entry").
|
||||
for the current ABAP EML request within the [RAP interaction phase](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_int_phase_glosry.htm "Glossary Entry") in one RAP transaction.
|
||||
- **Note:** Specify `%cid` even if there are no further operations referring to it.
|
||||
- Special case: Late numbering
|
||||
- As mentioned above, in late numbering scenarios newly created
|
||||
@@ -1145,13 +1152,13 @@ contains all relevant components for the chosen scenario.
|
||||
|
||||
<br>
|
||||
|
||||
The [LUW](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenluw_glosry.htm) concept, which deals with the transfer of data from one consistent state to another, applies to applications using RAP. RAP comes with a special [RAP LUW](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_luw_glosry.htm) that is integrated with the [SAP LUW](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensap_luw_glosry.htm), which is a prerequisite for transactional consistency. RAP provides a standardized approach and rules ([RAP BO contract](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_bo_contract_glosry.htm)) for the [RAP business object](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_bo_glosry.htm) (BO) runtime to ensure that the RAP LUW is correctly implemented, data inconsistencies are avoided, and the SAP LUW is successfully completed.
|
||||
The [LUW](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenluw_glosry.htm) concept, which deals with the transfer of data from one consistent state to another, applies to applications using RAP. RAP transactions are integrated with the [SAP LUW](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensap_luw_glosry.htm), which is a prerequisite for transactional consistency. RAP provides a standardized approach and rules ([RAP BO contract](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_bo_contract_glosry.htm)) for the [RAP business object (BO)](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_bo_glosry.htm) runtime to ensure that the RAP transaction is correctly implemented, data inconsistencies are avoided, and the SAP LUW is successfully completed.
|
||||
|
||||
**Phases of the RAP LUW**
|
||||
**Phases of a RAP Transaction**
|
||||
|
||||
The RAP LUW is divided into two phases during the runtime of a RAP BO, while the second phase can be divided into two subphases that serve different purposes.
|
||||
A RAP transaction is divided into two phases during the runtime of a RAP BO, while the second phase can be divided into two subphases that serve different purposes.
|
||||
|
||||

|
||||

|
||||
|
||||
[RAP interaction phase](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_int_phase_glosry.htm):
|
||||
- [RAP handler methods](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabp_handler_method_glosry.htm) are called in a [RAP handler class](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabp_handler_class_glosry.htm) that inherits from `CL_ABAP_BEHAVIOR_HANDLER`.
|
||||
@@ -1161,7 +1168,7 @@ The RAP LUW is divided into two phases during the runtime of a RAP BO, while the
|
||||
[RAP save sequence](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_save_seq_glosry.htm):
|
||||
- The RAP save sequence is triggered by a `COMMIT ENTITIES` statement. In natively supported RAP scenarios, such as an SAP Fiori application using OData, the `COMMIT ENTITIES` call is implicitly and automatically performed by the RAP runtime engine.
|
||||
- RAP saver methods are called in the RAP saver class, which inherits from the base class `CL_ABAP_BEHAVIOR_SAVER`.
|
||||
- Is divided into the [RAP early save phase](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenearly_rap_save_phase_glosry.htm) (ensures that the RAP BO instances in the transactional buffer - all RAP BOs in the current RAP LUW are involved - are in a consistent state so that they can be saved to the database) and the [RAP late save phase](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenlate_rap_save_phase_glosry.htm) (to finally save data from the transactional buffer to the database).
|
||||
- Is divided into the [RAP early save phase](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenearly_rap_save_phase_glosry.htm) (ensures that the RAP BO instances in the transactional buffer - all RAP BOs in the current RAP transaction are involved - are in a consistent state so that they can be saved to the database) and the [RAP late save phase](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenlate_rap_save_phase_glosry.htm) (to finally save data from the transactional buffer to the database).
|
||||
|
||||
(Optional:) Saver methods called in the RAP early save phase:
|
||||
1. [`finalize`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensaver_finalize.htm): For final calculations and data changes before saving. In managed scenarios, determinations specified with `ON SAVE` are called when reaching this method.
|
||||
@@ -1170,17 +1177,18 @@ The RAP LUW is divided into two phases during the runtime of a RAP BO, while the
|
||||
|
||||
3. [`cleanup_finalize`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapsaver_class_cleanup_finalize.htm): If there are failures in at least one of the previous saver methods, further processing with the RAP late save phase is rejected and the transaction returns to the interaction phase. Before that, this saver method is called, allowing changes made in the finalize method to be rolled back.
|
||||
|
||||
If there are errors in the early save phase, `sy-subrc` returns the value 4 after `COMMIT ENTITIES` statements. If the data in the transactional buffer is consistent after the early save phase, the late save phase is processed, which also means that a point of no return has been reached. Unlike the early save phase, you cannot return to the interaction phase when you reach the late save phase. Either the RAP LUW ends with a successful commit, or the changes are rolled back and a runtime error occurs.
|
||||
If there are errors in the early save phase, `sy-subrc` returns the value 4 after `COMMIT ENTITIES` statements. If the data in the transactional buffer is consistent after the early save phase, the late save phase is processed, which also means that a point of no return has been reached. Unlike the early save phase, you cannot return to the interaction phase when you reach the late save phase. Either the RAP transaction ends with a successful commit, or the changes are rolled back and a runtime error occurs.
|
||||
|
||||
Saver methods called in the RAP late save phase:
|
||||
1. [`adjust_numbers`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensaver_adjust_numbers.htm): Provides RAP BO instances with their final numbers. This method is available only in late numbering scenarios.
|
||||
2. [`save`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensaver_method_save.htm) (or [`save_modified`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaprap_saver_meth_save_modified.htm) in managed scenarios with an unmanaged or additional save): Used to save data from the transactional buffer to the database. If there are no issues, the final database commit is triggered and an implicit `COMMIT WORK` is executed.
|
||||
3. [`cleanup`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensaver_method_cleanup.htm): Clears the transactional buffer. It completes the save sequence.
|
||||
|
||||
[`cleanup`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensaver_method_cleanup.htm) method: After a successful save, the [`cleanup`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensaver_method_cleanup.htm) method clears the transactional buffer. It completes the save sequence.
|
||||
|
||||
**Commit and Rollback in the RAP LUW**
|
||||
The default ABAP statements for RAP are `COMMIT ENTITIES` (triggers the RAP save sequence and the final database commit; as mentioned above, in natively supported RAP scenarios, the commit is performed implicitly and automatically by the RAP runtime engine) and `ROLLBACK ENTITIES` (rolls back all changes of the current RAP LUW, i.e. the transactional buffer is cleared by calling the `cleanup` method). Both are RAP-specific and end the RAP LUW.
|
||||
**Commit and Rollback in a RAP Transaction**
|
||||
The default ABAP statements for RAP are `COMMIT ENTITIES` (triggers the RAP save sequence and the final database commit; as mentioned above, in natively supported RAP scenarios, the commit is performed implicitly and automatically by the RAP runtime engine) and `ROLLBACK ENTITIES` (rolls back all changes of the current RAP transaction, i.e. the transactional buffer is cleared by calling the `cleanup` method). Both are RAP-specific and end the RAP transaction.
|
||||
|
||||
*Notes on `COMMIT ...` and `ROLLBACK ...` statements due to the integration of the RAP LUW into the SAP LUW:*
|
||||
*Notes on `COMMIT ...` and `ROLLBACK ...` statements due to the integration of RAP transactions into the SAP LUW:*
|
||||
|
||||
- `COMMIT ENTITIES` implicitly triggers `COMMIT WORK`.
|
||||
- Using `COMMIT WORK` in RAP (instead of `COMMIT ENTITIES`) also triggers the RAP save sequence. If there are no errors in the RAP save sequence, the final database commit is successful. Only in this best-case scenario does `COMMIT WORK` have the same effect as `COMMIT ENTITIES`. However, if there are errors in the save sequence, a runtime error occurs in any case, while a return to the interaction phase is still possible when using `COMMIT ENTITIES`.
|
||||
@@ -1200,9 +1208,9 @@ The default ABAP statements for RAP are `COMMIT ENTITIES` (triggers the RAP save
|
||||
- After a `COMMIT ENTITIES` statement and a failure in the late save phase, `sy-subrc` is set to 8.
|
||||
- A subsequent RAP operation may result in a runtime error. If the RAP BO consumer is to continue after an error in the late phase of the RAP save sequence, an explicit `ROLLBACK ENTITIES` is required.
|
||||
|
||||
**Allowed/Forbidden Operations in a Behavior Implementation in the RAP LUW**
|
||||
**Allowed/Forbidden Operations in a Behavior Implementation in a RAP Transaction**
|
||||
|
||||
The following restrictions apply to operations and/or statements in the individual phases of the RAP LUW in ABAP behavior implementations. Note that, depending on setting the strict mode in the BDEF, runtime errors may occur due to the use of forbidden statements, or static code checks may be applied. Note that most operations/statements refer to the use in the unrestricted ABAP language scope.
|
||||
The following restrictions apply to operations and/or statements in the individual phases of a RAP transaction in ABAP behavior implementations. Note that, depending on setting the strict mode in the BDEF, runtime errors may occur due to the use of forbidden statements, or static code checks may be applied. Note that most operations/statements refer to the use in the unrestricted ABAP language scope.
|
||||
|
||||
|Operations/Statements|Interaction phase|Early save phase|Late save phase|Notes|
|
||||
|---|---|---|---|---|
|
||||
|
||||
@@ -15,7 +15,7 @@ Core data services (CDS) are an infrastructure for defining and consuming semant
|
||||
|
||||
- [Feature Matrix: Data Modeling with ABAP Core Data Services](https://blogs.sap.com/2022/10/24/feature-matrix-data-modeling-with-abap-core-data-services/)
|
||||
- [ABAP CDS Cheat Sheet: Amounts and Quantities in ABAP CDS](https://blogs.sap.com/2022/07/07/abap-cds-cheat-sheet-amounts-and-quantities-in-abap-cds/)
|
||||
- [Section *ABAP - Core Data Services (ABAP CDS)* in the ABAP keyword Documentation](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencds.htm)
|
||||
- [Section *ABAP - Core Data Services (ABAP CDS)* in the ABAP Keyword Documentation](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencds.htm)
|
||||
|
||||
## Executable Example
|
||||
[zcl_demo_abap_cds_ve](./src/zcl_demo_abap_cds_ve.clas.abap)
|
||||
|
||||
@@ -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