diff --git a/01_Internal_Tables.md b/01_Internal_Tables.md
index 515cde1..e8be538 100644
--- a/01_Internal_Tables.md
+++ b/01_Internal_Tables.md
@@ -31,7 +31,7 @@ Internal Tables ...
- are used when a variable data set of a random data type needs to be processed in a structured way.
- allow access to individual table lines via a [table index](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abentable_index_glosry.htm) or a [table key](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abentable_key_glosry.htm).
-
).
ENDLOOP.
```
-(⬆️ back to top)
+⬆️ back to top
### Data References
@@ -607,7 +607,7 @@ reference variables are more powerful as far as their usage options are
concerned, and they better fit into the modern (object-oriented) ABAP
world. Recommended read: [Accessing Data Objects Dynamically (F1 docu for standard ABAP)](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abendyn_access_data_obj_guidl.htm "Guideline").
-(⬆️ back to top)
+⬆️ back to top
## Dynamic ABAP Statements
@@ -855,7 +855,7 @@ Note that dynamically specifying syntax elements has downsides, too. Consider so
"The addition EXCEPTION-TABLE for exceptions is not dealt with here.
```
-(⬆️ back to top)
+⬆️ back to top
## Runtime Type Services (RTTS)
@@ -905,7 +905,7 @@ F2 help information in
[ADT](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenadt_glosry.htm "Glossary Entry"),
for more details.
-(⬆️ back to top)
+⬆️ back to top
### Getting Type Information at Runtime
@@ -1102,7 +1102,7 @@ CREATE OBJECT oref4abs TYPE (abs_name_cl).
CREATE OBJECT oref4abs TYPE ('\CLASS=ZCL_DEMO_ABAP_DYNAMIC_PROG').
```
-(⬆️ back to top)
+⬆️ back to top
### Dynamically Creating Data Types at Runtime
You can create data types at program runtime using methods of the type description classes of RTTS.
@@ -1217,7 +1217,7 @@ DATA(tdo_ref_3) = cl_abap_refdescr=>get_by_name( 'T' ).
DATA(tdo_ref_4) = cl_abap_refdescr=>get_by_name( 'ZCL_DEMO_ABAP_DYNAMIC_PROG' ).
```
-(⬆️ back to top)
+⬆️ back to top
### Dynamically Creating Data Objects at Runtime
@@ -1262,7 +1262,7 @@ DATA(tdo_ref) = cl_abap_refdescr=>get( cl_abap_elemdescr=>get_t( ) ).
CREATE DATA dref_cr TYPE HANDLE tdo_ref.
```
-(⬆️ back to top)
+⬆️ back to top
## More Information
- It is recommended that you also consult section [Dynamic Programming Techniques (F1 docu for standard ABAP)](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abendynamic_prog_technique_gdl.htm) in the ABAP Keyword Documentation since it provides important aspects that should be considered when dealing with dynamic programming in general (e. g. security aspects or runtime error prevention).
diff --git a/07_String_Processing.md b/07_String_Processing.md
index 86db283..0576220 100644
--- a/07_String_Processing.md
+++ b/07_String_Processing.md
@@ -48,7 +48,7 @@ and built-in [string functions](https://help.sap.com/doc/abapdocu_cp_index_htm/C
corresponding ABAP statements, or even more. The return value of string functions
that return character strings is always of type `string`.
-(⬆️ back to top)
+⬆️ back to top
## Data Types for Character Strings
@@ -88,7 +88,7 @@ that must be a maximum of two characters, or for input fields in
forms that should not exceed a certain length. If limiting a string
is not relevant, text strings are a good choice.
-(⬆️ back to top)
+⬆️ back to top
## Declaring Character-Like Data Objects
@@ -145,7 +145,7 @@ DATA char(4) TYPE c.
DATA char_len_one TYPE c.
```
-(⬆️ back to top)
+⬆️ back to top
## Assigning Values
@@ -229,7 +229,7 @@ however, with [significant
differences](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenliteral_operator.htm)
to `&&`.
-(⬆️ back to top)
+⬆️ back to top
## String Templates
- Using string templates, you can construct strings very elegantly from
@@ -311,7 +311,7 @@ s1 = |{ CONV decfloat34( - 1 / 3 ) DECIMALS = 3 }|. "'-0.333'
> **💡 Note**
> Escape `\|{}` in string templates using `\`, i. e. `\\` means `\`.
-(⬆️ back to top)
+⬆️ back to top
## Determining the Length of Strings
@@ -333,7 +333,7 @@ len_c = numofchar( 'abc ' ). "3
len_str = numofchar( `abc ` ). "3
```
-(⬆️ back to top)
+⬆️ back to top
## Concatenating Strings
@@ -379,7 +379,7 @@ s1 = concat_lines_of( table = itab ). "Without separator
s1 = concat_lines_of( table = itab sep = ` ` ). "With separator
```
-(⬆️ back to top)
+⬆️ back to top
## Splitting Strings
@@ -420,7 +420,7 @@ SPLIT s1 AT ',' INTO TABLE itab. "Strings are added to itab in individual lines
s2 = segment( val = s1 index = 2 sep = `,` ). "world
```
-(⬆️ back to top)
+⬆️ back to top
## Modifying Strings
**Transforming to Lowercase and Uppercase**
@@ -609,7 +609,7 @@ OVERLAY txt1 WITH txt2 ONLY 'ab'.
"txt1: z.x.c.Z.x.c.A
```
-(⬆️ back to top)
+⬆️ back to top
## Processing Substrings
@@ -694,7 +694,7 @@ s2 = substring_from( val = s1 sub = `a3` ). "a3bb4
s2 = substring_to( val = s1 sub = `3b` ). "aa1bb2aa3b
```
-(⬆️ back to top)
+⬆️ back to top
## Searching and Replacing
@@ -715,7 +715,7 @@ on single characters only or more complex, pattern-based
operations on character sequences using [PCRE regular
expressions](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenpcre_regex_glosry.htm "Glossary Entry").
-(⬆️ back to top)
+⬆️ back to top
### Searching for Specific Characters
@@ -807,7 +807,7 @@ res = count_any_not_of( val = str sub = `Piecs ofak.` ). "0
```
-(⬆️ back to top)
+⬆️ back to top
### Replacing Specific Characters in Strings
@@ -841,7 +841,7 @@ s2 = translate( val = s1 from = `_` to = `##` ). "###abc#def#####ghi#
TRANSLATE s1 USING `_.a#g+`. "...#bc.def.....+hi.
```
-(⬆️ back to top)
+⬆️ back to top
### Searching for Substrings in Strings (and Tables)
@@ -1168,7 +1168,7 @@ TRY.
ENDTRY.
```
-(⬆️ back to top)
+⬆️ back to top
### Replacing Substrings in Strings (and Tables)
@@ -1415,7 +1415,7 @@ regular
expressions](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenposix_regex_glosry.htm "Glossary Entry")
anymore, they are obsolete.
-(⬆️ back to top)
+⬆️ back to top
### Simple Pattern-Based Searching Using Comparison Operators
@@ -1451,7 +1451,7 @@ IF s1 CP `*f#_*`. ... "true; sy-fdpos = 6
IF s1 NP `i+`. ... "true; sy-fdpos = 11 (length of searched string)
```
-(⬆️ back to top)
+⬆️ back to top
### Complex Searching and Replacing Using Regular Expressions
@@ -1517,7 +1517,7 @@ Anchors and Positions
| `\b` | Start or end of word | 1. `\ba.`
2. `\Dd\b`
3. `\b.d\b` | abcd a12d ed | 1. **ab**cd **a1**2d ed
2. ab**cd** a12d **ed**
3. abcd a12d **ed** | 1. ab**cd** a1**2d** ed
2. abcd a1**2d** ed
3. **abcd** **a12d** ed |
| `\B` | Negation of `\b`, not at the start or end of words | `\Be\B` | see an elefant | s**e**e an el**e**fant | s**ee** an **e**lefant |
-(⬆️ back to top)
+⬆️ back to top
#### Searching Using Regular Expressions
@@ -1575,7 +1575,7 @@ DATA(itab) = value string_table( ( `Cathy's black cat on the mat played with the
FIND FIRST OCCURRENCE OF PCRE `\bt.` IN TABLE itab
IGNORING CASE MATCH LINE DATA(d) MATCH OFFSET DATA(e) MATCH LENGTH DATA(f). "d: 1, e: 21, f: 2
```
-(⬆️ back to top)
+⬆️ back to top
##### Excursion: System Classes for Regular Expressions
@@ -1608,7 +1608,7 @@ DATA(res) = cl_abap_regex=>create_pcre( pattern = `\s\w` "any blank follow
ignore_case = abap_true )->create_matcher( text = str )->find_all( ).
```
-(⬆️ back to top)
+⬆️ back to top
#### Replacing Using Regular Expressions
@@ -1660,7 +1660,7 @@ s2 = replace( val = s1
REPLACE PCRE `(.*?)PP(.*)` IN s1 WITH `$2#$1` IGNORING CASE. "pc app#ab a
```
-(⬆️ back to top)
+⬆️ back to top
## Executable Example
[zcl_demo_abap_string_proc](./src/zcl_demo_abap_string_proc.clas.abap)
diff --git a/08_EML_ABAP_for_RAP.md b/08_EML_ABAP_for_RAP.md
index e19070f..054120e 100644
--- a/08_EML_ABAP_for_RAP.md
+++ b/08_EML_ABAP_for_RAP.md
@@ -193,7 +193,7 @@ that handles requests from outside the AS ABAP or, from inside AS ABAP,
an ABAP program using ABAP EML (which this cheat sheet and the examples
focus on).
-(⬆️ back to top)
+⬆️ back to top
## ABAP Behavior Pools (ABP)
@@ -234,7 +234,7 @@ sequence](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?f
methods](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabp_saver_method_glosry.htm "Glossary Entry")
to save data from the transactional buffer to the database).
-(⬆️ back to top)
+⬆️ back to top
### RAP Handler Classes and Methods
@@ -342,7 +342,7 @@ METHODS some_action FOR MODIFY
UI if something goes wrong to inform the user.
-(⬆️ back to top)
+⬆️ back to top
### RAP Saver Class and Saver Methods
@@ -403,7 +403,7 @@ CLASS lsc_bdef DEFINITION INHERITING FROM cl_abap_behavior_saver.
ENDCLASS.
```
-(⬆️ back to top)
+⬆️ back to top
## BDEF Derived Types
@@ -508,7 +508,7 @@ DATA rep TYPE RESPONSE FOR REPORTED entity.
> **💡 Note**
> Some of the derived types can only be created and accessed in implementation classes.
-(⬆️ back to top)
+⬆️ back to top
### Components of BDEF Derived Types
@@ -606,7 +606,7 @@ Bullet points on selected `%` components:
`if_abap_behv=>mk-off`, the values of these fields
are not returned in the result.
-(⬆️ back to top)
+⬆️ back to top
## EML Syntax
@@ -825,7 +825,7 @@ MODIFY ENTITIES OF root_ent
...
```
-(⬆️ back to top)
+⬆️ back to top
### EML Syntax for Reading Operations
@@ -886,7 +886,7 @@ READ ENTITIES OF root_ent
LINK DATA(links2).
...
```
-(⬆️ back to top)
+⬆️ back to top
#### Dynamic Forms of EML Statements
@@ -983,7 +983,7 @@ op_tab = VALUE #(
READ ENTITIES OPERATIONS op_tab.
```
-(⬆️ back to top)
+⬆️ back to top
### Persisting to the Database
@@ -1029,7 +1029,7 @@ IF sy-subrc <> 0.
ENDIF.
```
-(⬆️ back to top)
+⬆️ back to top
### EML Statements in ABAP Behavior Pools
@@ -1058,7 +1058,7 @@ MODIFY ENTITIES OF root_ent IN LOCAL MODE
...
```
-(⬆️ back to top)
+⬆️ back to top
## RAP Excursions
@@ -1351,7 +1351,7 @@ The following restrictions apply to operations and/or statements in the individu
-(⬆️ back to top)
+⬆️ back to top
## More Information
@@ -1366,7 +1366,7 @@ The following restrictions apply to operations and/or statements in the individu
consistency and reliability
-(⬆️ back to top)
+⬆️ back to top
## Executable Examples
This cheat sheet is supported by different executable examples demonstrating various scenarios:
diff --git a/10_ABAP_SQL_Hierarchies.md b/10_ABAP_SQL_Hierarchies.md
index fa3ebd6..ac12f4b 100644
--- a/10_ABAP_SQL_Hierarchies.md
+++ b/10_ABAP_SQL_Hierarchies.md
@@ -59,7 +59,7 @@ learn some additional syntax and then you can start right away.
> **💡 Note**
> The examples in this cheat sheet are only relevant for [standard ABAP](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenstandard_abap_glosry.htm), i. e. the unrestricted ABAP language scope. Find the artifacts used in the code snippets in your on-premise system.
-(⬆️ back to top)
+⬆️ back to top
## SQL Hierarchies
@@ -103,7 +103,7 @@ for each row. For creating a SQL hierarchy, you need the following:
The following topics show you step-by-step how SQL hierarchies can be
created and accessed.
-(⬆️ back to top)
+⬆️ back to top
## Creating SQL Hierarchies
@@ -258,7 +258,7 @@ From the ABAP language point of view, CDS hierarchies are the most
convenient way of using SQL hierarchies. Now let us turn to other ways,
involving more ABAP, until we do not use any CDS more in the end.
-(⬆️ back to top)
+⬆️ back to top
### ABAP SQL Hierarchy Generator HIERARCHY
The ABAP SQL [hierarchy
@@ -375,7 +375,7 @@ not least we will use CTEs as hierarchies themselves. You might skip the
following section and turn directly to the hierarchy navigators if you
are not too interested in this syntactic gimmicks.
-(⬆️ back to top)
+⬆️ back to top
### ABAP CTE Hierarchies
@@ -489,7 +489,7 @@ hierarchy association. Running
`CL_DEMO_SQL_HIERARCHIES` shows that all
assertions are fulfilled.
-(⬆️ back to top)
+⬆️ back to top
## Hierarchy Navigators
@@ -513,7 +513,7 @@ or a CTE hierarchy. Check the examples of the
[documentation](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenselect_hierarchy_navigators.htm),
where this is also shown.
-(⬆️ back to top)
+⬆️ back to top
### Hierarchy Node Navigator HIERARCHY_DESCENDANTS
@@ -550,7 +550,7 @@ distance to the respective start node. A further parameter
`DISTANCE` - not shown here - allows you to restrict the
distance to the respective start node.
-(⬆️ back to top)
+⬆️ back to top
### Hierarchy Node Navigator HIERARCHY_ANCESTORS
@@ -582,7 +582,7 @@ aggregate functions or evaluating the internal result table, you can now
easily extract further information like the number of ancestors and so
on.
-(⬆️ back to top)
+⬆️ back to top
### Hierarchy Node Navigator HIERARCHY_SIBLINGS
@@ -616,7 +616,7 @@ the respective start node. Running
`CL_DEMO_SQL_HIERARCHIES`, where we start with
a node that definitely has some siblings, shows the result.
-(⬆️ back to top)
+⬆️ back to top
### Hierarchy Aggregate Navigators
@@ -717,7 +717,7 @@ Running `CL_DEMO_SQL_HIERARCHIES` shows the
result. It also shows the result of the joined data source, where you
can check that the calculated values are correct.
-(⬆️ back to top)
+⬆️ back to top
## More Information
For the complete reference documentation about SQL hierarchies, see [`SELECT, FROM hierarchy_data`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenselect_hierarchy_data.htm).
diff --git a/11_ABAP_SQL_Grouping_Internal_Tables.md b/11_ABAP_SQL_Grouping_Internal_Tables.md
index e3c80d8..976a170 100644
--- a/11_ABAP_SQL_Grouping_Internal_Tables.md
+++ b/11_ABAP_SQL_Grouping_Internal_Tables.md
@@ -64,7 +64,7 @@ The member loop is executed using the group represented by `wa`
and its members are assigned to `member` and are available in
the member loop.
-(⬆️ back to top)
+⬆️ back to top
## Grouping by More than One Column
@@ -85,7 +85,7 @@ This is also a representative binding in which the work area
To access the members of the groups, the exact same member loop can be
inserted as when grouping by one column.
-(⬆️ back to top)
+⬆️ back to top
## Group Key Binding when Grouping by One Column
@@ -133,7 +133,7 @@ LOOP AT spfli_tab INTO wa
ENDLOOP.
```
-(⬆️ back to top)
+⬆️ back to top
## Group Key Binding when Grouping by More than One Column
Finally, the group key binding for structured group keys:
@@ -171,7 +171,7 @@ INDEX`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?fil
[`GROUP
SIZE`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaploop_at_itab_group_by_key.htm).
-(⬆️ back to top)
+⬆️ back to top
## Executable Example
[zcl_demo_abap_sql_group_by](./src/zcl_demo_abap_sql_group_by.clas.abap)
diff --git a/12_AMDP.md b/12_AMDP.md
index 932c4ac..91bd265 100644
--- a/12_AMDP.md
+++ b/12_AMDP.md
@@ -69,7 +69,7 @@ in the ABAP Keyword Documentation.
>- AMDP classes can only be edited with the [ABAP development tools for Eclipse
(ADT)](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenadt_glosry.htm "Glossary Entry").
-(⬆️ back to top)
+⬆️ back to top
## AMDP Classes
@@ -102,7 +102,7 @@ CLASS cl_some_amdp_class DEFINITION
ENDCLASS.
```
-(⬆️ back to top)
+⬆️ back to top
## AMDP Methods
@@ -136,7 +136,7 @@ PRIVATE SECTION.
...
```
-(⬆️ back to top)
+⬆️ back to top
## AMDP Procedures
@@ -226,7 +226,7 @@ Note:
and implementation parts. Check the ABAP Keyword Documentation for
more details as touched on further down.
-(⬆️ back to top)
+⬆️ back to top
## AMDP Functions
@@ -304,7 +304,7 @@ ENDMETHOD.
...
```
-(⬆️ back to top)
+⬆️ back to top
### CDS Table Functions
@@ -378,7 +378,7 @@ define table function some_ddl_source
You can then use the CDS table function as source for a
`SELECT` statement, for example: `SELECT * FROM some_ddl_source INTO ...`.
-(⬆️ back to top)
+⬆️ back to top
## More Information
@@ -436,7 +436,7 @@ input parameter for the client ID. See more information
The client handling is not dealt with in this cheat sheet and not
relevant in the executable example.
-(⬆️ back to top)
+⬆️ back to top
## Executable Example
[zcl_demo_abap_amdp](./src/zcl_demo_abap_amdp.clas.abap)
diff --git a/13_Program_Flow_Logic.md b/13_Program_Flow_Logic.md
index db5018b..0ca8f02 100644
--- a/13_Program_Flow_Logic.md
+++ b/13_Program_Flow_Logic.md
@@ -49,7 +49,7 @@ ELSE.
ENDIF.
```
-(⬆️ back to top)
+⬆️ back to top
## Expressions and Functions for Conditions
- So, such control structures are executed depending on conditions as specified above: `... num = 2 ...` - a [logical expression](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenlogical_expression_glosry.htm).
@@ -226,7 +226,7 @@ ENDIF.
> **💡 Note**
> Logical expressions and functions can also be used in other ABAP statements.
-(⬆️ back to top)
+⬆️ back to top
## Control Structures
@@ -295,7 +295,7 @@ ENDIF.
> sure - as implied in the example's `ELSE` statement above. However, an `ELSE` statement that is never executed might be a hint that
> logical expressions might partly be redundant.
-(⬆️ back to top)
+⬆️ back to top
#### Excursion: `COND` Operator
@@ -311,7 +311,7 @@ ENDIF.
ELSE resultn ) ...
```
-(⬆️ back to top)
+⬆️ back to top
### `CASE`: Case Distinctions
@@ -350,7 +350,7 @@ CASE TYPE OF oref.
ENDCASE.
```
-(⬆️ back to top)
+⬆️ back to top
#### Excursion: `SWITCH` Operator
@@ -365,7 +365,7 @@ The conditional operator [`SWITCH`](https://help.sap.com/doc/abapdocu_cp_index_h
ELSE resultn ) ...
```
-(⬆️ back to top)
+⬆️ back to top
### Loops
@@ -389,7 +389,7 @@ The conditional operator [`SWITCH`](https://help.sap.com/doc/abapdocu_cp_index_h
```
- The value of the system field `sy-index` within the statement block contains the number of previous loop passes including the current pass.
-(⬆️ back to top)
+⬆️ back to top
#### Interrupting and Exiting Loops
@@ -405,7 +405,7 @@ The following ABAP keywords are available for interrupting and exiting loops:
> - [`RETURN`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapreturn.htm) statements immediately terminate the current processing block. However, according to the [guidelines (F1 docu for standard ABAP)](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenexit_procedure_guidl.htm), `RETURN` should only be used to exit procedures like methods.
> - `EXIT` and `CHECK` might also be used for exiting procedures. However, their use inside loops is recommended.
-(⬆️ back to top)
+⬆️ back to top
#### `WHILE`: Conditional Loops
@@ -419,7 +419,7 @@ WHILE log_exp.
ENDWHILE.
```
-(⬆️ back to top)
+⬆️ back to top
#### Loops Across Tables
Further keywords for defining loops are as follows. They are not dealt with here since they are touched on in other ABAP cheat sheets.
@@ -429,7 +429,7 @@ Further keywords for defining loops are as follows. They are not dealt with here
- You can also realize loops using iteration expressions with `VALUE` and `REDUCE`. See the example class for the internal table cheat sheet.
- [`SELECT ... ENDSELECT`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapselect.htm) statements loop across the result set of a database access. See also the cheat sheet on ABAP SQL.
-(⬆️ back to top)
+⬆️ back to top
## Calling Procedures
@@ -440,7 +440,7 @@ However, ...
Regarding the exiting of procedures, note the hint mentioned above. The use of `RETURN` is recommended.
-(⬆️ back to top)
+⬆️ back to top
## Handling Exceptions
- [Exceptions](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenexception_glosry.htm) ...
@@ -561,7 +561,7 @@ Regarding the exiting of procedures, note the hint mentioned above. The use of `
>- For all exceptions that are raised by the ABAP runtime environment and that are not handled, there is a corresponding runtime error. For example, in the case of exception class `CX_SY_ZERODIVIDE`, it is the runtime error `COMPUTE_INT_ZERODIVIDE`. For self-defined exception classes, an exception that is not handled generally triggers the runtime error `UNCAUGHT_EXCEPTION`.
> - For `TRY` control structures, there are further additions available dealing with more advanced error handling, e. g. [resumable exceptions](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapresume.htm).
-(⬆️ back to top)
+⬆️ back to top
#### Notes on Exception Classes
- To distinguish exception classes from *regular* classes, use the naming convention `CX` as prefix and not `CL`.
@@ -607,7 +607,7 @@ Regarding the exiting of procedures, note the hint mentioned above. The use of `
> - Each exception has a an [exception text](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenexception_text_glosry.htm) that describes the error situation and that you can retrieve as outlined above. It helps you analyze the error. Plus, imagine using exceptions in the context of user interfaces. If a user faces an error situation, such exception texts may be displayed on the UI.
> - Find more information on exception texts [here](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenexception_texts.htm) in the ABAP Keyword Documentation.
-(⬆️ back to top)
+⬆️ back to top
### Raising Exceptions
@@ -630,7 +630,7 @@ RAISE EXCEPTION TYPE cx_sy_zerodivide.
ELSE THROW cx_some_error( ) ).
```
-(⬆️ back to top)
+⬆️ back to top
## Excursion: Runtime Errors and Terminating Programs
- Runtime errors are caused by uncatchable exceptions when a program is executed, when a catchable exception is not caught, or they can be forced by, for example, using [`ASSERT`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapassert.htm) statements.
@@ -652,7 +652,7 @@ ASSERT flag = abap_true.
> - Each runtime error is identified by a name and assigned to a specific error situation.
> - In ADT, you will see a message popping up and informing you about the runtime error. You can check the details by choosing the "Show" button in the pop-up. Furthermore, you can check the content of the "Feed Reader" tab in ADT. There, just expand your project and find the runtime errors caused by you.
-(⬆️ back to top)
+⬆️ back to top
## Executable Example
[zcl_demo_abap_prog_flow_logic](./src/zcl_demo_abap_prog_flow_logic.clas.abap)
diff --git a/14_ABAP_Unit_Tests.md b/14_ABAP_Unit_Tests.md
index 09f1db5..835a9e5 100644
--- a/14_ABAP_Unit_Tests.md
+++ b/14_ABAP_Unit_Tests.md
@@ -30,7 +30,7 @@ This cheat sheet contains basic information about [unit testing](https://help.sa
- In ABAP, developers have [ABAP Unit](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabap_unit_glosry.htm) - a test tool integrated into the ABAP runtime framework - at their disposal. It can be used to run individual or mass tests, and to evaluate test results. Note that comprehensive test runs can be performed using the [ABAP Test Cockpit](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabap_test_cockpit_glosry.htm)
- In ABAP programs, individual unit tests are implemented as [test methods](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abentest_method_glosry.htm) of local [test classes](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abentest_class_glosry.htm).
-(⬆️ back to top)
+⬆️ back to top
## High-Level Steps for ABAP Unit Tests
@@ -47,7 +47,7 @@ This cheat sheet contains basic information about [unit testing](https://help.sa
> **💡 Note**
> Of course, if there are no dependend-on components in your production code, you can skip the considerations of dependency isolation, test doubles and their injection into the production code.
-(⬆️ back to top)
+⬆️ back to top
## Creating Test Classes
@@ -174,7 +174,7 @@ CLASS ltd_test_double IMPLEMENTATION.
ENDCLASS.
```
-(⬆️ back to top)
+⬆️ back to top
## Creating and Implementing Test Methods
@@ -313,7 +313,7 @@ CLASS ltc_test_class IMPLEMENTATION.
ENDCLASS.
```
-(⬆️ back to top)
+⬆️ back to top
### Special Methods for Implementing the Test Fixture
- Special private methods for implementing the test [fixture](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenfixture_glosry.htm), which may include test data and test objects among others, can be included in the local test class.
@@ -395,7 +395,7 @@ ENDCLASS.
> **💡 Note**
> You can also specify helper methods, for example, for recurring tasks such as the assertions.
-(⬆️ back to top)
+⬆️ back to top
## Handling Dependencies
@@ -429,7 +429,7 @@ Among them, there are the following. They are demonstrated in the executable exa
- Parameter injection: The test double is passed as a parameter to the tested method (i.e. an optional importing parameter) in the class under test.
- Back door injection: A *back door* is created to inject a test double into the class under test. This *back door* is implemented by granting [friendship](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenfriend_glosry.htm) to the test class. This makes internal attributes of the class under test accessible from the test class.
-(⬆️ back to top)
+⬆️ back to top
### Test Seams
- Seams are sections of the production source code that can be dynamically included or replaced.
@@ -481,7 +481,7 @@ END-TEST-INJECTION.
...
```
-(⬆️ back to top)
+⬆️ back to top
## Running and Evaluating ABAP Unit Tests
There are many ways to run ABAP unit tests as described [here](https://help.sap.com/docs/ABAP_PLATFORM_NEW/c238d694b825421f940829321ffa326a/4ec4c6c66e391014adc9fffe4e204223.html?locale=en-US).
@@ -494,7 +494,7 @@ If you are interested in the test coverage, you can choose `Ctrl + Shift + F11`,
For more information about evaluating ABAP unit test results, see [here](https://help.sap.com/docs/ABAP_PLATFORM_NEW/c238d694b825421f940829321ffa326a/4ec49c5b6e391014adc9fffe4e204223.html?locale=en-US).
-(⬆️ back to top)
+⬆️ back to top
## More Information
@@ -507,7 +507,7 @@ For more information about evaluating ABAP unit test results, see [here](https:/
- [Testing repository objects](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abentest_relations.htm) (ABAP Keyword Documentation)
- [Development Guide for the ABAP RESTful Application Programming Model: Testing different artifacts of RAP business objects and related OData services](https://help.sap.com/docs/btp/sap-abap-restful-application-programming-model/test?locale=en-US)
-(⬆️ back to top)
+⬆️ back to top
## Executable Example
[zcl_demo_abap_unit_test](./src/zcl_demo_abap_unit_test.clas.abap)
diff --git a/16_Data_Types_and_Objects.md b/16_Data_Types_and_Objects.md
index 1c04f3c..d93ed00 100644
--- a/16_Data_Types_and_Objects.md
+++ b/16_Data_Types_and_Objects.md
@@ -52,7 +52,7 @@ Data objects:
> **💡 Note**
> There are several differentations that further distinguish and characterize data types and objects. See [here](#glossary-terms-in-a-nutshell).
-(⬆️ back to top)
+⬆️ back to top
## ABAP Data Types
@@ -88,7 +88,7 @@ For an overview, see the [ABAP Type Hierarchy](https://help.sap.com/doc/abapdocu
> - Although they are character-like, `t` and `d` can be used for calculations.
> - See the ABAP Keyword Documentation [here](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenbuilt_in_types.htm) for more information about the initial values of the data types, the standard length, and so on.
-(⬆️ back to top)
+⬆️ back to top
### Complex Data Types
@@ -104,7 +104,7 @@ For an overview, see the [ABAP Type Hierarchy](https://help.sap.com/doc/abapdocu
> **💡 Note**
> Structured and table types are used in this cheat sheet as examples for complex types. For more information, see the ABAP Keyword Documentation and the ABAP cheat sheets for structures and internal tables.
-(⬆️ back to top)
+⬆️ back to top
### Reference Types
- Describe data objects that contain [references](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenreference_glosry.htm) to other objects (data objects and instances of classes), which are known as [reference variables](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenreference_variable_glosry.htm).
@@ -116,7 +116,7 @@ For an overview, see the [ABAP Type Hierarchy](https://help.sap.com/doc/abapdocu
> There are [generic ABAP types](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abengeneric_abap_type_glosry.htm). Generic data types are types that do not define all of the properties of a data object. They can only be used for the typing of [formal parameters](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenformal_parameter_glosry.htm) and [field symbols](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenfield_symbol_glosry.htm).
The only generic types that can be used after `TYPE REF TO` are `data` for the generic typing of data references, and `object`, for the generic typing of object references.
-(⬆️ back to top)
+⬆️ back to top
### Declaring Data Types
@@ -301,7 +301,7 @@ DATA itab_str TYPE TABLE OF string.
TYPES tr_like_table_ref LIKE TABLE OF REF TO itab_str.
```
-(⬆️ back to top)
+⬆️ back to top
## Data Objects
@@ -469,7 +469,7 @@ DATA dref_tab_i TYPE TABLE OF REF TO i.
DATA dref_tab_str LIKE TABLE OF REF TO do_some_string.
```
-(⬆️ back to top)
+⬆️ back to top
### Assigning Values to Data Objects
@@ -573,7 +573,7 @@ str_a2 = |{ str_a1 } some more bla.|. "String templates. Note: Data objects are
str_a2 = some_itab[ 2 ]-carrname.
```
-(⬆️ back to top)
+⬆️ back to top
### Creating Data Objects Using Inline Declaration
@@ -682,7 +682,7 @@ SELECT * FROM zdemo_abap_carr INTO TABLE @DATA(itab_b3).
SELECT * FROM zdemo_abap_carr INTO TABLE NEW @DATA(itab_ref).
```
-(⬆️ back to top)
+⬆️ back to top
### Assigning References to Data Reference Variables
@@ -765,8 +765,7 @@ dref_1_i = CAST #( dref_3_data ).
"So, the downcast does not work.
TRY.
dref_2_str = CAST #( dref_3_data ).
- CATCH cx_sy_move_cast_error INTO DATA(e).
- output->display( input = e->get_text( ) name = `e->get_text( )` ).
+ CATCH cx_sy_move_cast_error INTO DATA(e).
ENDTRY.
"Old syntax using the ?= operator
@@ -777,7 +776,7 @@ dref_1_i ?= dref_3_data.
dref_1_i = CAST #( dref_6_i ).
```
-(⬆️ back to top)
+⬆️ back to top
### Creating Anonymous Data Objects
@@ -872,7 +871,7 @@ SELECT *
INTO TABLE NEW @DATA(dref_14_inline).
```
-(⬆️ back to top)
+⬆️ back to top
### Constants and Immutable Variables
@@ -912,7 +911,7 @@ ENDLOOP.
SELECT * FROM zdemo_abap_carr INTO TABLE @FINAL(itab_final_inl).
```
-(⬆️ back to top)
+⬆️ back to top
## Type Conversion
A value assignment means that the value of a data object is transferred to a target data object. If the data types of the source and target are compatible, the content is copied unchanged. If they are incompatible and a suitable [conversion rule](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenconversion_rule_glosry.htm) exists, the content is converted.
@@ -955,7 +954,7 @@ DATA(i2str) = CONV string( -10 ).
"Result: i2str: `10-`
```
-(⬆️ back to top)
+⬆️ back to top
## Terms Related to Data Types and Objects in a Nutshell
@@ -1144,7 +1143,7 @@ CONSTANTS con_b_str TYPE string VALUE `hi`.
"Unnamed data objects
"Literal that is output. It cannot be addressed via a dedicated name.
-output->display( `I'm a literal...` ).
+out->write( `I'm a literal...` ).
"Anonymous data object created using the NEW operator
"Can be addressed using reference variables or field symbols.
@@ -1192,7 +1191,7 @@ DATA itab_str TYPE string_table.
"some_number = itab_str.
```
-(⬆️ back to top)
+⬆️ back to top
## Notes on the Declaration Context
@@ -1211,7 +1210,7 @@ The declaration context of data types (and objects) determines the validity and
- The DDIC provides many options for defining types, including elementary data types (defined as data elements), reference types, complex types such as structured types and table types. Note that the name of a database table or a view can be used in type declarations to address the line type of these repository objects (for example, a structure: `DATA a TYPE some_db_table.`).
- Note the following trap: Local declarations hide global declarations of the same name.
-(⬆️ back to top)
+⬆️ back to top
## Excursions
### Enumerated Types and Objects
@@ -1269,7 +1268,7 @@ dobj_enum = a.
Find more information on enumerated types in the (commented code of the) cheat sheet example and [here](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenenumerated_types_usage.htm).
-(⬆️ back to top)
+⬆️ back to top
### Getting Type Information and Creating Types at Runtime
Using [Runtime Type Identification (RTTI)](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrun_time_type_identific_glosry.htm "Glossary Entry"), you can get type information on data objects, data types or [instances](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abeninstance_glosry.htm "Glossary Entry") at runtime ([Runtime Type Identification (RTTI)](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrun_time_type_identific_glosry.htm "Glossary Entry")).
diff --git a/17_SAP_LUW.md b/17_SAP_LUW.md
index c72f046..7336a49 100644
--- a/17_SAP_LUW.md
+++ b/17_SAP_LUW.md
@@ -16,7 +16,7 @@
⚠️ Most of the content of this cheat sheet is only relevant to [classic ABAP](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenclassic_abap_glosry.htm).
-This cheat sheet provides a high-level introduction to the [SAP LUW](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abensap_luw_glosry.htm) concept that deals with data consistency with a focus on SAP LUW-related statements, supported by an executable example to check the syntax in action.
+This cheat sheet provides a high-level overview of the [SAP LUW](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abensap_luw_glosry.htm) concept that deals with data consistency with a focus on SAP LUW-related statements, supported by an executable example to check the syntax in action.
When you run an application, you typically change data in a [transaction](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abentransaction_glosry.htm), which may be temporarily stored in transactional buffers.
This data may be temporarily inconsistent in the buffers, but it is important that the data be in a consistent state at the end of the transaction so that it can be saved to the database.
@@ -120,9 +120,9 @@ The following bundling techniques are available for classic ABAP. This means tha
- Are specially marked, i.e. the *update module* property is marked
- Can be given specific attributes to determine the priority with which they are processed in the update work process
- Usually contain database modification operations/statements
-- [CALL FUNCTION ... IN UPDATE TASK](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abapcall_function_update.htm) statements are used to register the update function modules for later execution; the actual execution is triggered by a `COMMIT WORK` statement
+- [`CALL FUNCTION ... IN UPDATE TASK`](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abapcall_function_update.htm) statements are used to register the update function modules for later execution; the actual execution is triggered by a `COMMIT WORK` statement
-- Example of a simple update function module that has an importing parameter (a structure that is used to modify a database table)
+- Example of a simple function module that has an importing parameter (a structure that is used to modify a database table). Example function modules in the repository are marked as update function modules.
```abap
FUNCTION zsome_update_fu_mod
IMPORTING
@@ -282,7 +282,7 @@ The limitations include the fact that the above bundling techniques are not avai
In fact, RAP is the transactional programming model for ABAP Cloud.
And RAP comes with a well-defined transactional model and follows the rules of the SAP LUW. At the end of an SAP LUW in RAP, database modification operations should be performed in a final step in the [RAP late save phase](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenlate_rap_save_phase_glosry.htm) by persisting the consistent data in the [RAP transactional buffer](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abentransactional_buffer_glosry.htm) to the database.
-There are RAP-specific, [ABAP EML](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap_eml_glosry.htm) statements for commit and rollback:
+There are RAP-specific [ABAP EML](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap_eml_glosry.htm) statements for commit and rollback:
- [`COMMIT ENTITIES`](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abapcommit_entities.htm) implicitly triggers `COMMIT WORK`. Furthermore, `COMMIT ENTITIES` provides RAP-specific functionality with various additions. These EML statements implicitly enforce local updates with `COMMIT WORK`, or `COMMIT WORK AND WAIT` if the local update fails. Therefore, the update is either a local update or a synchronous update, but never an asynchronous update.
- [`ROLLBACK ENTITIES`](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abaprollback_entities.htm): Resets all changes of the current transaction and clears the transactional buffer. The statement triggers `ROLLBACK WORK`.
@@ -294,4 +294,80 @@ There are RAP-specific, [ABAP EML](https://help.sap.com/doc/abapdocu_latest_inde
(⬆️ back to top)
## Executable Example
-Coming soon ...
\ No newline at end of file
+After importing, find the program in ADT using search: Press `CTRL+SHIFT+A` and enter `zdemo_abap_sap_luw`. Open the program and run it by pressing `F8`.
+
+> **💡 Note**
+> - The steps about how to import and run the code are outlined [here](README.md#-getting-started-with-the-examples).
+> - The SAP LUW is demonstrated using classic dynpros to provide a self-contained example (i.e., so as not to have more artifacts, service creation, etc.) that highlights the considerations regarding implicit database commits - without putting the spotlight on dynpros. Note that classic dynpros are outdated for application programs. New developments should use web-based UIs, such as SAPUI5 or Web Dynpro.
+> - Dynpros cannot be created in ABAP Cloud. As mentioned earlier, RAP is the transactional programming model for ABAP Cloud. It comes with a well-defined transactional model and follows the rules of the SAP LUW. See the links in the *More Information* section.
+> - The example ...
+> - does not claim to include meaningful dynpros with meaningful dynpro sequences and is not intended to be a role model for proper dynpro design.
+> - is not intended to solve concrete programming tasks. You should always work out your own solution for each individual case.
+> - is only intended to demonstrate a selection of keywords and visualize SAP LUW-related syntax in action on a high level.
+> - See notes on the executable example in the expandable section below.
+
+
+
+ Expand to see explanations of the executable example
+
+
+Th example demonstrates the SAP LUW using dynpros and bundling techniques with update function modules and subroutines. In the dynpros, you can select various options that determine how the program runs. It covers the following aspects:
+
+- Demonstrating synchronous update, asynchronous update, and local update triggered by `COMMIT WORK`, `COMMIT WORK AND WAIT`, and `SET UPDATE TASK LOCAL` using update function modules.
+- Demonstrating the statements `PERFORM ... ON COMMIT` and `PERFORM ... ON ROLLBACK` using subroutines.
+
+
+
+The selection options follow this pattern:
+
+**First dynpro**:
+- The SAP LUW is started.
+- The entries in a database table are displayed. There are four entries in total.
+- After you have selected an option to continue with either the update task, or the update task and perform a local update, or subroutines, an update function module or subroutine is registered to delete all entries from the database table.
+
+**Second dynpro**:
+- You can create a new database table entry by making entries in input fields displayed on the dynpro.
+- When the program continues, it registers an update function module or subroutine that inserts the new entry into the database table.
+
+**Third dynpro**:
+- The SAP LUW is ended. You have several options for ending the SAP LUW.
+- In addition to the `COMMIT WORK` and `COMMIT WORK AND WAIT` statements, you can use `ROLLBACK WORK` to roll back the changes.
+- Another option is to deliberately make the current SAP LUW fail. If a type A message is triggered, the SAP LUW is also terminated.
+
+During program execution, logs are collected and eventually written to a database table (also using an update function module or subroutine). These logs document the progress of the transaction with various pieces of information. These include work process information, SAP LUW key retrieval, and transaction state retrieval (using methods of the `CL_SYSTEM_TRANSACTION_STATE` class).
+
+If the program is not terminated immediately and the SAP LUW has ended, another program is called that displays a dynpro.
+
+**Fourth dynpro** (part of a new program that is started):
+- The database table entries and logs are displayed.
+- If the transaction was successful, a single entry (the one created during the execution of the previous program) should be displayed for the modified database table, as well as the entries of the log table.
+- Note that a helper class is available for this example. Methods perform various tasks, such as retrieving work process information.
+
+**Notes on the various options for checking out the SAP LUW:**
+ - **Asynchronous update** with `COMMIT WORK`: Immediately after the `COMMIT WORK` statement, a `SELECT` statement is executed, retrieving all the entries of the database table. In this case, the number of the retrieved entries should be the number of the original database table entries, i.e. 4 entries, and not 1, demonstrating the asynchronous update. The current number of records is displayed in a message. Result: The database table is deleted and a single new entry is added.
+The log shows the value 1 for the transaction state after the update task is executed and the update function modules are called.
+ - **Synchronous update** with `COMMIT WORK AND WAIT`: Immediately after the `COMMIT WORK AND WAIT` statement, a `SELECT` statement is executed to retrieve all the entries in the database table. In this case, there should be one entry instead of four to demonstrate the synchronous update. The current number of records is displayed in a message.
+ - **Local update** using a `SET UPDATE TASK LOCAL` statement: Once the local update is enabled, it does not matter whether you choose `COMMIT WORK` or `COMMIT WORK AND WAIT` in the next step. It will be a synchronous update, so the number of current database table entries displayed in the message will be 1 in both cases. The log will show the value 1 for the transaction state after the `SET UPDATE TASK LOCAL` statement has been executed.
+ - **Rolling back changes**: Although update function modules and subroutines are registered, none of them affect the database. All changes are rolled back. Result: The database table is not deleted, no new entry is created. The original content of the database table should be displayed.
+ - **Causing a failure in the current SAP LUW**: An update function module intentionally includes a statement that causes a runtime error if not caught (zero division). All changes are rolled back implicitly. If the local update is active, you should be informed of the problem directly. The program is terminated. In this case, you can check the database table entries that remain unchanged. You can also use transaction ST22 to display the runtime error that occurred. In the case of a non-local update, you should receive a mail in the Business Workplace informing you of the problem in the SAP LUW. The original content of the database table should be displayed on the next screen. In this case, you can also check transaction ST22 for the runtime error.
+ - **Terminating the program with an error message** of type A: This option only indicates that if such a message is generated, the program is terminated and all changes are implicitly rolled back. In this case, you may want to check the database table entries that remain unchanged.
+- **Using subroutines**:
+ - Note that subroutines are considered obsolete and should no longer be used. This is to demonstrate the effect as a bundling technique in an SAP LUW. Selecting this option triggers the registration of subroutines for commit (to delete the database table entry, insert a newly created entry, insert entries in the log table) and rollback (this subroutine does nothing specific; it is just to demonstrate that the subroutine is called in the event of a rollback).
+ - When you select the commit options, the subroutines registered with ON COMMIT are executed in the current work process.
+ - Choosing `COMMIT WORK` or `COMMIT WORK AND WAIT` has the same effect: When these statements are called and a `SELECT` statement follows, the number of database table entries is 1 in both cases.
+ - If the rollback option is selected, the subroutine registered with `ON ROLLBACK` is executed in the current work process.
+ - The transaction state in the log is 1 for `ON COMMIT` or `ON ROLLBACK` when the corresponding subroutines are called.
+ - Note that registered subroutines cannot have a parameter interface, so no parameters can be passed in this type of bundling. Therefore, data can only be passed through external interfaces, such as ABAP memory. In this example, the database table entry created is passed to and from ABAP memory using `EXPORT` and `IMPORT` statements. The subroutines themselves do not implement the writes themselves, but instead call methods of a class.
+- The following aspects are valid for all selected options regarding the logs:
+ - Before the commit is triggered (in the last PAI), the transaction state shows the value 0 for all retrieved transaction states.
+ - The work process information may change due to the fact that database commits are triggered when completing a dialog step. So you might expect different numbers there, but not necessarily. The new free work process can also be the same as the one before it was freed. However, there will be no different work process information for the update. The numbers will be the same because the update is performed in a single work process.
+ - Before calling the program that displays database entries and the log, the SAP LUW key is the same throughout the transaction. It does not change until a new SAP LUW is opened. See and compare the last entry for the SAP LUW key in the log that is retrieved for the program submitted.
+
+
+
+
+
+
+
+
+
diff --git a/18_Dynpro.md b/18_Dynpro.md
index a5caa34..0d8a163 100644
--- a/18_Dynpro.md
+++ b/18_Dynpro.md
@@ -35,13 +35,13 @@ In modern UI technologies, this can be achieved through [events](https://help.sa
In the early days of ABAP, classes, methods, and events did not exist. Program flow control had to be achieved in other ways.
This is where [dynpros](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abendynpro_glosry.htm) (dynamic programs) representing a classic ABAP UI technology come into play.
-This cheat sheet provides a high-level introduction to dynpro topics with a focus on dynpro-related statements, supported by an executable example to check the syntax in action.
+This cheat sheet provides a high-level overview of classic dynpro topics with a focus on dynpro-related statements, supported by an executable example to check the syntax in action.
> **💡 Note**
> - Classic dynpros are outdated for application programs. New developments should use web-based UIs, such as SAPUI5 or Web Dynpro.
> - Dynpros cannot be created in ABAP Cloud.
> - This cheat sheet ...
-> - is not intended to encourage you to start creating dynpros for programming new applications.
+> - is not intended to encourage you to start creating classic dynpros for programming new applications.
> - does not cover all facets, techniques, and keywords in great detail.
> - is intended to touch on a selection of dynpro-related topics and syntax that you may encounter in older ABAP code. If you need more information, always consult the ABAP Keyword Documentation.
> - Some of the statements described here - the ones used in the dynpro flow logic - are programmed in a special programming language. Although it looks like ABAP, it is not ABAP.
@@ -69,7 +69,7 @@ This cheat sheet provides a high-level introduction to dynpro topics with a focu
> **💡 Note**
> There are special dynpros ([selection screens](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenselection_screen_glosry.htm), [classic lists](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenclassic_list_glosry.htm)). They are created implicitly.
-
(⬆️ back to top)
+⬆️ back to top
## Dynpro Flow Logic
@@ -123,7 +123,7 @@ The following statements are among the non-ABAP statements in the dynpro flow lo
- `LOOP` and `ENDLOOP` for processing lines of a table control (similar to the ABAP statement `LOOP`)
- `CALL SUBSCREEN` for calling the flow logic of a subscreen
-(⬆️ back to top)
+⬆️ back to top
## Dialog Modules
@@ -164,7 +164,7 @@ MODULE pai_9000 INPUT.
ENDMODULE.
```
-(⬆️ back to top)
+⬆️ back to top
## Transporting Data between Dynpros and the ABAP Program
@@ -222,7 +222,7 @@ ENDCLASS.
- Notes on working with the *OK field*:
- As with the other dynpro fields, a data object must be created in the ABAP program.
- The system field `sy-ucomm` automatically receives the value of the function code. However, it is recommended that you work with the *OK field* instead of `sy-ucomm`. You have full control over the fields you declare. Also, the value of an ABAP system field should not be changed.
- - It is recommended that you store the function code in an auxiliary variable and initialize the*OK field* field in an ABAP program. This ensures that the function code of a dynpro is not filled with an unwanted value in the PBO event (for example, the next PAI event can be triggered with an empty function code). You can then read the function code from the auxiliary variable (for example, using a `CASE` structure) and control the program flow from there.
+ - It is recommended that you store the function code in an auxiliary variable and initialize the *OK field* field in an ABAP program. This ensures that the function code of a dynpro is not filled with an unwanted value in the PBO event (for example, the next PAI event can be triggered with an empty function code). You can then read the function code from the auxiliary variable (for example, using a `CASE` structure) and control the program flow from there.
- The *OK field* field can have a different name on each dynpro. However, it is recommended that you use the same name for the field in each dynpro of an ABAP program. This way, you only need one field with the same name in the ABAP program, in which the function code is placed and from which you can read it.
- In addition to screen elements, function codes can also be linked to various things in the dynpro, e.g. the definition of the menu bar takes place in the GUI status. They also trigger a PAI event.
@@ -267,7 +267,7 @@ ENDMODULE.
...
```
-(⬆️ back to top)
+⬆️ back to top
### Program-Controlled Data Transport
@@ -284,14 +284,14 @@ Example:
"See some of them below and more details in the ABAP Keyword Documentation.
PROCESS AFTER INPUT.
- MODULE pai_9000. "both field_a and field_b are not available
+ MODULE pai_9000. "neither field_a nor field_b are available
FIELD field_a.
MODULE module_a. "field_a is available, field_b is not
FIELD field_b.
MODULE module_b. "both field_a and field_b are available
```
-(⬆️ back to top)
+⬆️ back to top
### Calling Dialog Modules Conditionally
@@ -321,7 +321,7 @@ PROCESS AFTER INPUT.
ENDCHAIN.
```
-(⬆️ back to top)
+⬆️ back to top
## Input Checks
@@ -366,7 +366,7 @@ PROCESS AFTER INPUT.
- If a warning or error message is triggered in the `mod` dialog module, all fields listed in the processing chain are ready for input again. In this way, users can correct an input that consists of several closely related individual fields, and where it is not clear from the start which of the individual fields users must change in order to create a valid input as a whole.
-(⬆️ back to top)
+⬆️ back to top
## Field and Input Help
@@ -396,7 +396,7 @@ PROCESS AFTER INPUT.
- A special form that can be linked to an input field.
- When an input field is linked to a dropdown list box, the input value can only be selected from the list. Dropdown list boxes are therefore suitable for cases where the list of values is not too extensive and no other values than those in the list are allowed.
-(⬆️ back to top)
+⬆️ back to top
## Dnypro Sequence, Calling and Leaving Dynpros
@@ -416,7 +416,7 @@ PROCESS AFTER INPUT.
- The simplest dynpro sequence consists of a single dynpro with 0 as the next dynpro.
- When the current dynpro sequence is finished, the system returns to the previous dynpro sequence if the current dynpro sequence was nested.
-(⬆️ back to top)
+⬆️ back to top
### ABAP Statements for Calling and Leaving Dynpros
@@ -498,7 +498,7 @@ SET SCREEN 0.
LEAVE SCREEN.
```
-(⬆️ back to top)
+⬆️ back to top
## Modifying Static Attributes of Screen Elements
@@ -529,7 +529,7 @@ MODULE pbo_9000 OUTPUT.
ENDMODULE.
```
-(⬆️ back to top)
+⬆️ back to top
## Statements for the GUI Status and Title
@@ -589,7 +589,7 @@ ENDMODULE.
> **💡 Note**
> By separating the GUI status and title from the dynpro itself, the screen layout can remain constant when switching dynpros, and only the title and available functions can be changed.
-(⬆️ back to top)
+⬆️ back to top
## Controls
@@ -646,7 +646,7 @@ REFRESH CONTROL contr FROM SCREEN dynnr.
...
```
-(⬆️ back to top)
+⬆️ back to top
### Tabstrips Controls
- Allow tab pages to be displayed on dynpros
@@ -692,7 +692,7 @@ PROCESS AFTER INPUT.
```
-(⬆️ back to top)
+⬆️ back to top
### GUI Controls
- Are components of the presentation view of an AS ABAP.
@@ -707,7 +707,7 @@ PROCESS AFTER INPUT.
- Tree control: Are available in different versions (for example, `CL_GUI_SIMPLE_TREE`). They allow hierarchical relationships to be displayed in tree structures.
- ALV Grid control: Is the replacement for classic lists. It provides functions such as searching, sorting, and printing the content of the list. However, the associated class `CL_GUI_ALV_GRID` should no longer be used directly for new developments. Classes such as `CL_SALV_TABLE` encapsulate the use of the ALV Grid control and simplify the integration.
-(⬆️ back to top)
+⬆️ back to top
## More Information
- [SAP GUI User Dialogs](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap_screens.htm) in the ABAP Keyword Documentation as the entry topic for dynpro-related topics
@@ -716,4 +716,51 @@ PROCESS AFTER INPUT.
- In ADT, in your system, choose `CTRL+SHIFT+A` to open the search. Insert `demo_dynpro*` to get a list of dynpro examples of the ABAP Keyword Documentation.
## Example
-Coming soon ...
\ No newline at end of file
+
+After importing, find the program in ADT using the search: Press `CTRL+SHIFT+A` and enter `zdemo_abap_dynpro`. Open the program and run it by pressing `F8`.
+
+
+> **💡 Note**
+> - The steps about how to import and run the code are outlined [here](README.md#-getting-started-with-the-examples).
+> - The executable example ...
+> - does not claim to include meaningful dynpros with meaningful dynpro sequences (branching to new dynpro sequences occur through using appropriate statements).
+> - is not intended to be a role model for proper dynpro design.
+> - is not intended to solve concrete programming tasks. You should always work out your own solution for each individual case.
+> - is only intended to demonstrate a selection of keywords and visualize dynpro-related syntax in action on a high level.
+> - See notes on the executable example in the expandable section below.
+
+
+
+
+ Expand to see explanations of the executable example
+
+
+Th example demonstrates dynpro-related statements. In the dynpros, you can select various options for checking out the effect of the syntax.
+It covers the following aspects:
+
+- Dynpro flow logic and related statements (`MODULE`, `FIELD`, `CHAIN`/`ENDCHAIN`, `LOOP`/`ENDLOOP`, `CALL SUBSCREEN`)
+- ABAP statements for calling and leaving dynpros (`SET SCREEN`, `CALL SCREEN`, `LEAVE
+SCREEN`)
+- Modifying static attributes (`LOOP AT SCREEN`, `MODIFY SCREEN`),
+- Statements related to the GUI status and title (`GET`/`SET PF-STATUS`, `SET TITLEBAR`)
+- Controls (table and tabstrip controls)
+
+**First dynpro** (the "home page"):
+- Selection options for what can be explored in other dynpros
+- Choose the *Go* button to switch to another dynpro
+
+**Dynpro "Example of screen elements"**:
+- Demonstrates several screen elements
+- Pushbuttons, input field, boxes, checkboxes, radio buttons
+
+**Dynpro "Statements I"**:
+- Selection options for various dynpro-related ABAP statements
+- When you choose a radio button and *Go*, a message is displayed providing some information.
+
+**Dynpro "Statements II"**:
+- Covers statements in the flow logic
+- The option `MODULE ... AT EXIT-COMMAND` opens another dynpro. It demonstrates the exit command. The input field is required to be filled. This denies the processing after choosing the *Close 1* and *Cancel* buttons. This is not true for the *Close 2* button.
+
+**Dynpro "Controls"**:
+- Shows several controls: Table and tabstrip controls as well as an ALV Grid control as an example for a GUI control
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 2c59f82..c110d0a 100644
--- a/README.md
+++ b/README.md
@@ -29,19 +29,20 @@ ABAP cheat sheets[^1] ...
- provide a **collection of information on selected ABAP topics** in a nutshell for your reference.
- focus on **ABAP syntax**.
- include **code snippets**.
-- are supported by easy-to-consume **demonstration examples** that you can import into your [SAP BTP ABAP environment](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensap_btp_abap_env_glosry.htm) or on-premise ABAP system using [abapGit](https://abapgit.org/) to run and check out ABAP syntax in action in simple contexts.
+- are supported by easy-to-consume **demonstration examples** that you can import into your [SAP BTP ABAP environment](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensap_btp_abap_env_glosry.htm) (*main* branch) or on-premise ABAP system (other branches) using [abapGit](https://abapgit.org/) to run and check out ABAP syntax in action in simple contexts.
- are enriched by links to glossary entries and chapters of the **ABAP Keyword Documentation** (the *F1 help*) for you to deep dive into the respective ABAP topics and get more comprehensive information.
💡 Note
-- Since the ABAP cheat sheets provide information in a nutshell, they do not claim to be fully comprehensive as far as the described syntax and concepts are concerned. If you need more details, you can always consult the ABAP Keyword Documentation, for example, by choosing `F1` on a keyword in your code, or by searching directly using the online or the system-internal version.
-- Unless otherwise stated in the cheat sheets and examples, the content of this repository are relevant for these ABAP language versions:
- - [ABAP for Cloud Development](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap_for_sap_cloud_glosry.htm): Restricted ABAP language scope for developments in the [SAP BTP ABAP environment](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abensap_btp_abap_env_glosry.htm) → [Online version of the documentation](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm)
- - [Standard ABAP](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenstandard_abap_glosry.htm): Unrestricted ABAP language scope, for example, for developments in an on-premise ABAP system → [Online version of the documentation (latest version)](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap.htm)
+- Since the ABAP cheat sheets provide information in a nutshell, they do not claim to be fully comprehensive as far as the described syntax and concepts are concerned. If you need more details, you can always consult the ABAP Keyword Documentation, for example, by choosing *F1* on a keyword in your code, or by searching directly using the online or the system-internal version.
+- Unless otherwise stated in the cheat sheets, the content of this repository is relevant for these ABAP language versions:
+ - [ABAP for Cloud Development](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap_for_sap_cloud_glosry.htm): Restricted ABAP language scope for [ABAP Cloud](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabap_cloud_glosry.htm) → [Online version of the documentation](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm)
+ - [Standard ABAP](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenstandard_abap_glosry.htm): Unrestricted ABAP language scope, for example, for [classic ABAP](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenclassic_abap_glosry.htm) → [Online version of the documentation (latest version)](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap.htm)
- Check the [Known Issues](#-known-issues) and [Disclaimer](#%EF%B8%8F-disclaimer).
-- The cheat sheets provide links to glossary entries and topics in the ABAP Keyword Documentation. Note that in most cases, these links refer to the ABAP for Cloud Development version.
+- The cheat sheets provide links to glossary entries and topics in the ABAP Keyword Documentation. Note that unlike the classic ABAP-only cheat sheets, in most cases these links refer to ABAP for Cloud Development.
+- [Here](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrestricted_abap_elements.htm) is an overview of the different ABAP language elements in the different ABAP versions, i.e. what is allowed in ABAP Cloud and what is not. See also the released APIs [here](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenreleased_apis.htm).
@@ -49,7 +50,7 @@ ABAP cheat sheets[^1] ...
## 🏗️ How to Use
1. **ABAP syntax info**: Get info in a nutshell on ABAP syntax and concepts related to various ABAP topics in the [ABAP cheat sheets](#-abap-cheat-sheets-overview).
-2. **Demo examples**: Import the ABAP development objects of this repository into your system using [abapGit](https://abapgit.org/) as described [here](#-getting-started-with-the-examples) and run the demo classes by choosing `F9` in the [ABAP development tools for Eclipse (ADT)](https://tools.eu1.hana.ondemand.com/) for checking out the ABAP syntax in action.
+2. **Demo examples**: Import the ABAP development objects of this repository (Note: *main* branch for ABAP Cloud only) into your system using [abapGit](https://abapgit.org/) as described [here](#-getting-started-with-the-examples) and run the demo classes by choosing *F9* in the [ABAP development tools for Eclipse (ADT)](https://tools.eu1.hana.ondemand.com/) for checking out the ABAP syntax in action.
@@ -73,21 +74,22 @@ ABAP cheat sheets[^1] ...
|[Program Flow Logic](13_Program_Flow_Logic.md)|Deals with control structures (`IF`, `CASE`), loops (`DO`, `WHILE`) and exception handling|[zcl_demo_abap_prog_flow_logic](./src/zcl_demo_abap_prog_flow_logic.clas.abap)|
|[ABAP Unit Tests](14_ABAP_Unit_Tests.md)|Contains basic information about unit testing in ABAP|[zcl_demo_abap_unit_test](./src/zcl_demo_abap_unit_test.clas.abap)|
|[CDS View Entities](15_CDS_View_Entities.md)|Note that cheat sheet content is available in [this blog](https://blogs.sap.com/2022/10/24/feature-matrix-data-modeling-with-abap-core-data-services/). The focus here is on the example CDS artifacts and the [executable example class](./src/zcl_demo_abap_cds_ve.clas.abap), which include comments.|[zcl_demo_abap_cds_ve](./src/zcl_demo_abap_cds_ve.clas.abap)|
-|[SAP LUW](17_SAP_LUW.md)|Provides a high-level introduction to the [SAP LUW](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abensap_luw_glosry.htm) concept that deals with data consistency with a focus on SAP LUW-related statements
💡 The content of the cheat sheet is mostly relevant to [classic ABAP](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenclassic_abap_glosry.htm)|Coming soon|
-|[Dynpro](18_Dynpro.md)|Provides a high-level introduction to dynpro topics with a focus on dynpro-related statements
💡 Relevant to [classic ABAP](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenclassic_abap_glosry.htm)|Coming soon|
+|[SAP LUW](17_SAP_LUW.md)|Provides a high-level overview on the [SAP LUW](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abensap_luw_glosry.htm) concept that deals with data consistency with a focus on SAP LUW-related statements
💡 The content of the cheat sheet is mostly relevant to [classic ABAP](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenclassic_abap_glosry.htm)|Program `ZDEMO_ABAP_SAP_LUW`|
+|[Dynpro](18_Dynpro.md)|Provides a high-level overview of dynpro topics with a focus on dynpro-related statements
💡 Relevant to [classic ABAP](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenclassic_abap_glosry.htm)|Program `ZDEMO_ABAP_DYNPRO`|
## 🎬 Getting Started with the Examples
-The executable examples are designed to be imported into the SAP BTP ABAP environment, but they are basically suitable for both on-premise systems (ABAP release >= 7.56; especially the RAP examples) and the SAP BTP ABAP environment (hence there are no ABAP reports included). Therefore, check the information in the following collapsible sections for your system environment and perform the required steps.
+The main focus of the ABAP Cheat Sheets is ABAP Cloud. The examples in the *main* branch of the repository are designed to be imported into the SAP BTP ABAP environment.
+For classic ABAP, you can find examples in the other branches of the repository that you can import into your SAP system. Just select the appropriate version (*v757* stands for ABAP version 7.57). Check the information in the following collapsible sections for your system environment and perform the required steps.
1) General info
- Some **DDIC artifacts**, such as database tables, are part of the repository. They are used by the examples to ensure self-contained examples. All artifacts must be imported for all examples to work.
-- All examples are designed to **display some output in the ADT console**. Once successfully imported, you can **run** the examples in ADT by choosing `F9` to display the output in the ADT console.
+- Most examples are designed to **display some output in the ADT console**. Once successfully imported, you can **run** the examples in ADT by choosing *F9* to display the output in the ADT console. The programs included in the branches for classic ABAP can be executed with *F8*.
- The examples **include descriptions and comments** in the code to provide explanations and set the context.
@@ -103,14 +105,13 @@ The executable examples are designed to be imported into the SAP BTP ABAP enviro
- [x] You have installed the [abapGit](https://github.com/abapGit/eclipse.abapgit.org) plug-in for ADT from the [update site](http://eclipse.abapgit.org/updatesite/).
-
**Import Code**
Use the abapGit plug-in to install the ABAP Cheat Sheets by carrying out the following steps:
-1. In your ABAP cloud project, create a package, for example, `ZABAP_CHEAT_SHEETS` as the target package. It is recommended that you assign the package to a transport request that is suitable for demo content.
+1. In your ABAP cloud project, create a package, for example, *ZABAP_CHEAT_SHEETS* as the target package. It is recommended that you assign the package to a transport request that is suitable for demo content.
2. Add the package to the *Favorite Packages* in the *Project Explorer* view in ADT.
-3. To add the abapGit Repositories view to the ABAP perspective, choose `Window` → `Show View` → `Other...` from the menu bar and choose `abapGit Repositories`.
+3. To add the abapGit Repositories view to the ABAP perspective, choose *Window* → *Show View* → *Other...* from the menu bar and choose *abapGit Repositories*.
4. In the abapGit Repositories view, click the `+` icon in the upper right corner of the ADT tab to link a new abapGit repository.

@@ -120,19 +121,19 @@ Use the abapGit plug-in to install the ABAP Cheat Sheets by carrying ou
https://github.com/SAP-samples/abap-cheat-sheets.git
```
-6. Choose `Next`.
+6. Choose *Next*.
-7. On the *Branch and Package Selection* screen, enter the name of the created package (for example, `ZABAP_CHEAT_SHEETS`) in the `Package` field.
-8. Choose `Next`.
-9. On the *Select Transport Request* screen, select the created transport request that is suitable for the demo content and choose `Finish` to link the Git repository to your ABAP cloud project. If the created package is already assigned to a transport request for the demo content, and a message appears that an object is already locked in a transport request, choose `Finish`, too.
+7. On the *Branch and Package Selection* screen, enter the name of the created package (for example, *ZABAP_CHEAT_SHEETS*) in the *Package* field.
+8. Choose *Next*.
+9. On the *Select Transport Request* screen, select the created transport request that is suitable for the demo content and choose *Finish* to link the Git repository to your ABAP cloud project. If the created package is already assigned to a transport request for the demo content, and a message appears that an object is already locked in a transport request, choose *Finish*, too.
10. In the *abapGit Repositories* view, filter for your package. The repository appears in the *abapGit Repositories* view with the status Linked.
-11. Right-click on the new abapGit repository and choose `Pull...` to start the cloning of the repository contents.
-12. On the *Branch and Package Selection* screen, choose `Next`.
-13. If the *Locally Modified Object* screen is displayed, select the objects (for example, the package to automatically select all artifacts) from the list and choose `Next`.
-14. On the next screen, select a transport request and choose `Finish`. Same as above, if an *object already locked* message is displayed, choose `Finish` as well. The status in the *abapGit Repositories* view changes to Pull running.... Note that the pull run may take several minutes.
-15. Once the cloning is complete, the status changes to `Pulled Successfully`. You may need to refresh the `abapGit Repositories` view to see the progress of the import. To do this, choose the `Refresh` icon in the upper right corner of the view.
-16. Refresh your project tree. For example, in ADT, right-click the package and choose `Refresh` or `F5`. The package should contain all the artifacts from the GitHub repository.
-17. Make sure that all artifacts are active. To activate all inactive development objects, choose the `Activate all inactive ABAP development objects` button from the menu (or choose `CTRL+Shift+F3`).
+11. Right-click on the new abapGit repository and choose *Pull...* to start the cloning of the repository contents.
+12. On the *Branch and Package Selection* screen, choose *Next*.
+13. If the *Locally Modified Object* screen is displayed, select the objects (for example, the package to automatically select all artifacts) from the list and choose *Next*.
+14. On the next screen, select a transport request and choose *Finish*. Same as above, if an *object already locked* message is displayed, choose *Finish* as well. The status in the *abapGit Repositories* view changes to Pull running.... Note that the pull run may take several minutes.
+15. Once the cloning is complete, the status changes to *Pulled Successfully*. You may need to refresh the *abapGit Repositories* view to see the progress of the import. To do this, choose the *Refresh* icon in the upper right corner of the view.
+16. Refresh your project tree. For example, in ADT, right-click the package and choose *Refresh*. The package should contain all the artifacts from the GitHub repository.
+17. Make sure that all artifacts are active. To activate all inactive development objects, choose the *Activate all inactive ABAP development objects* button from the menu (or choose *CTRL+Shift+F3*).
@@ -140,33 +141,40 @@ https://github.com/SAP-samples/abap-cheat-sheets.git
**Prerequisites**
-- [x] It is assumed that you are running the latest [ABAP release](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abennews-75.htm). Note that the RAP examples, for example, require at least ABAP version 7.56.
-- [x] Before importing the code, you have performed a system-wide search for classes named `ZCL_DEMO_ABAP*`, for example, to avoid errors when you try to import the code. If someone has already imported the content into the system, you can simply check out that imported version and proceed to the step *3) Run the code*.
+- [x] You are running an [ABAP release](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abennews-75.htm) for which examples are available. See the different branches of the repository. For example, you can find out about your ABAP release by checking the value of `sy-saprl`:
+ ```abap
+ DATA rel LIKE sy-saprl.
+ rel = sy-saprl.
+ BREAK-POINT.
+ ```
+- [x] Before importing the code, you have performed a system-wide search for classes named *ZCL_DEMO_ABAP**, for example, to avoid errors when you try to import the code. If someone has already imported the content into the system, you can simply check out that imported version and proceed to the step *3) Run the code*.
- [x] You have downloaded and installed the ABAP development tools for Eclipse (ADT). Make sure that you are using the latest version, as indicated on the [installation page](https://tools.hana.ondemand.com/#abap).
- [x] You have created an ABAP project in ADT that allows you to access your application server as mentioned above. Your login language is English.
-- [x] You have downloaded and installed the standalone version of the abapGit report. Make sure you are using the latest version, as indicated on the [installation page](https://docs.abapgit.org/). You can create a report, for example, `zabapgit_standalone`, and copy and paste [this code](https://raw.githubusercontent.com/abapGit/build/main/zabapgit_standalone.prog.abap) into the program.
+- [x] You have downloaded and installed the standalone version of the abapGit report. Make sure you are using the latest version, as indicated on the [installation page](https://docs.abapgit.org/). You can create a report, for example, *zabapgit_standalone*, and copy and paste [this code](https://raw.githubusercontent.com/abapGit/build/main/zabapgit_standalone.prog.abap) into the program.
**Import Code**
Use the standalone version of the abapGit report to import the demo examples of the ABAP cheat sheets by performing the following steps:
-1. In your ABAP project, create a package, such as `TEST_ABAP_CHEAT_SHEETS` as a target package suitable for demo content (for example, by using `LOCAL` as the software component).
+1. In your ABAP project, create a package, such as *TEST_ABAP_CHEAT_SHEETS* as a target package suitable for demo content (for example, by using *LOCAL* as the software component).
2. Add the package to the *Favorite Packages* in the *Project Explorer* view in ADT.
3. Run the standalone version of the abapGit report.
-4. Choose the `New Online` button. If the button is not available, for example, if another repository is already open, choose the `Repository List` button.
+4. Choose the *New Online* button. If the button is not available, for example, if another repository is already open, choose the *Repository List* button.
5. On the *New Online Repository* screen, make the following entries:
- - `Git Repository URL`:
+ - ***Git Repository URL***:
```
https://github.com/SAP-samples/abap-cheat-sheets.git
```
- - `Package`: Your demo package, for example, `TEST_ABAP_CHEAT_SHEETS`
-6. Leave the other fields unchanged and choose `Create Online Repo`.
+ - ***Package***: Your demo package, for example, *TEST_ABAP_CHEAT_SHEETS*
+ - ***Branch***: Choose the button with the 3 dots to the right of the input field. In the pop-up window, select the appropriate branch, e.g. *v757* if your ABAP release is 7.57, and choose the *Continue* (✔️) button. **Note**: The examples in the *main* branch are for ABAP Cloud only.
+ - ***Folder Logic***: *Full*
+6. Choose *Create Online Repo*.
7. The *Repository* screen displays the available ABAP artifacts to be imported into your ABAP system.
-8. Choose the `Pull` button. The import of the artifacts is triggered. This may take several minutes.
-9. If the `Inactive Objects` popup is displayed, select all artifacts and choose `Continue` (✔️).
-10. When the cloning is complete, refresh your project tree. For example, in ADT, right-click on the package and choose `Refresh` or `F5`. The package should contain all artifacts from the GitHub repository.
-11. Make sure that all artifacts are active. To activate all inactive development objects, choose the `Activate all inactive ABAP development objects` button from the menu (or choose `CTRL+Shift+F3`).
+8. Choose the *Pull* button. The import of the artifacts is triggered. This may take a while.
+9. If the *Inactive Objects* popup is displayed, select all artifacts and choose *Continue* (✔️).
+10. When the cloning is complete, refresh your project tree. For example, in ADT, right-click on the package and choose *Refresh*. The package should contain all artifacts from the GitHub repository.
+11. Make sure that all artifacts are active. To activate all inactive development objects, choose the *Activate all inactive ABAP development objects* button from the menu (or choose *CTRL+Shift+F3*).
@@ -175,23 +183,28 @@ Use the standalone version of the abapGit report to import the demo examples of
- Open the package you created containing the imported ABAP artifacts in the ABAP development tools for Eclipse (ADT).
-- Open one of the ABAP cheat sheet example classes listed in the [ABAP Cheat Sheets Overview](#-abap-cheat-sheets-overview) section, for example, `zcl_demo_abap_string_proc`. The classes are located in the `Source Code Library` → `Classes` folder.
-- Choose `F9` to run the class. Alternatively, choose `Run` → `Run As` → `2 ABAP Application (Console)` from the menu.
-- Check the console output.
+- Classes:
+ - Open one of the ABAP cheat sheet example classes listed in the [ABAP Cheat Sheets Overview](#-abap-cheat-sheets-overview) section, for example, *zcl_demo_abap_string_proc*. The classes are located in the *Source Code Library* → *Classes* folder.
+ - Choose *F9* to run the class. Alternatively, choose *Run* → *Run As* → *2 ABAP Application (Console)* from the menu.
+ - Check the console output.
+ > **💡 Note**
+ >- Check the notes on the context and the ABAP syntax used that are included as comments in the class.
+ >- Due to the amount of output in the console, the examples include numbers (e.g. 1) ..., 2) ..., 3) ...) that represent the headers of each example code section. Also, in most cases, the variable name is displayed in the console. Therefore, to find the relevant output in the console more easily and quickly, simply search the console for the number (e.g. search for *3)* for the particular output) or variable name (*CTRL+F* in the console), or use breakpoints in the code to check variables in the debugger.
+ >- You may want to clear the console by right-clicking in the console and choosing *Clear* before running another demo class to avoid confusing the output of multiple classes.
+- Programs:
+ - The programs included in the repository can be executed with *F8* (or *Run* → *Run As* → *1 ABAP Application*).
+
-> **💡 Note**
->- Check the notes on the context and the ABAP syntax used that are included as comments in the class.
->- Due to the amount of output in the console, the examples include numbers (e.g. 1) ..., 2) ..., 3) ...) that represent the headers of each example code section. Also, in most cases, the variable name is displayed in the console. Therefore, to find the relevant output in the console more easily and quickly, simply search the console for the number (e.g. search for `3)` for the particular output) or variable name (`CTRL+F` in the console), or use breakpoints in the code to check variables in the debugger.
->- You may want to clear the console by right-clicking in the console and choosing `Clear` before running another demo class to avoid confusing the output of multiple classes.
## ⚡ Known Issues
-- Only one user on the system can import this repository because all object names must be globally unique. Before importing the code, you should perform a system-wide search for classes named `ZCL_DEMO_ABAP*`, for example. If someone has already imported the content into the system, you can simply check out that imported code.
-- Since the repository contains self-contained examples, i.e. some of them work with demo database tables included in the repository (note that these tables are populated during method executions), all demo artifacts must be imported for all examples to work.
-- When importing into an on-premise system, note the following: The demos cover ABAP syntax regardless of the ABAP release to avoid scattering information and to have the information in one go. Therefore and if you are not running the latest ABAP version, there may be syntax that is not yet available in the ABAP version of your on-premise system. In this case, you may want to comment out the affected code sections or ignore the affected artifacts if an activation fails. Note that the RAP examples in particular require at least ABAP version 7.56.
+- Only one user on the system can import this repository because all object names must be globally unique. Before importing the code, you should perform a system-wide search for classes named *ZCL_DEMO_ABAP**, for example. If someone has already imported the content into the system, you can simply check out that imported code.
- Regarding possible code check warnings, e.g. for the many strings in the code, not using an `ORDER BY` clause, or messages regarding using `SELECT *`, the code deliberately avoids [pragmas](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenpragma_glosry.htm) and [pseudo comments](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenpseudo_comment_glosry.htm) in order to focus on the available ABAP syntax. See also the [Disclaimer](#%EF%B8%8F-disclaimer).
+- Regarding the examples to be imported into on-premise systems, note the following: The cheat sheet documents cover ABAP syntax regardless of the ABAP release to avoid scattering information and to have the information in one place. Therefore, the lower the release, the fewer syntax options and examples are available. For example, the RAP examples in particular require at least ABAP version 7.56.
+
+
@@ -206,7 +219,7 @@ Use the standalone version of the abapGit report to import the demo examples of

-- [This blog](https://blogs.sap.com/2021/04/28/video-tutorials-on-how-to-use-the-abap-keyword-documentation-abap-f1-help/) features videos about the ABAP Keyword Documentation in the [SAP Help Portal](https://www.youtube.com/watch?v=a4ckF1XkfG8), [SAP GUI](https://www.youtube.com/watch?v=fsX-085MlD8), and [ADT](https://www.youtube.com/watch?v=hNGEYFpWwh0).
+- [This blog](https://blogs.sap.com/2021/04/28/video-tutorials-on-how-to-use-the-abap-keyword-documentation-abap-f1-help/) features videos about the ABAP Keyword Documentation in the [SAP Help Portal](https://www.youtube.com/watch?v=a4ckF1XkfG8), [SAP GUI](https://www.youtube.com/watch?v=fsX-085MlD8), and [ADT](https://www.youtube.com/watch?v=hNGEYFpWwh0).
diff --git a/src/package.devc.xml b/src/package.devc.xml
index e77fc01..f4825f9 100644
--- a/src/package.devc.xml
+++ b/src/package.devc.xml
@@ -4,7 +4,6 @@
ABAP Cheat Sheets
- X
diff --git a/src/zbp_demo_abap_rap_draft_m.clas.abap b/src/zbp_demo_abap_rap_draft_m.clas.abap
index 4614e93..1ad11b7 100644
--- a/src/zbp_demo_abap_rap_draft_m.clas.abap
+++ b/src/zbp_demo_abap_rap_draft_m.clas.abap
@@ -16,5 +16,5 @@ ENDCLASS.
-CLASS zbp_demo_abap_rap_draft_m IMPLEMENTATION.
+CLASS ZBP_DEMO_ABAP_RAP_DRAFT_M IMPLEMENTATION.
ENDCLASS.
diff --git a/src/zbp_demo_abap_rap_draft_m.clas.locals_imp.abap b/src/zbp_demo_abap_rap_draft_m.clas.locals_imp.abap
index 3cc1ca8..7f3815c 100644
--- a/src/zbp_demo_abap_rap_draft_m.clas.locals_imp.abap
+++ b/src/zbp_demo_abap_rap_draft_m.clas.locals_imp.abap
@@ -22,19 +22,19 @@
* 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
+* 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
-* intended to provide a better explanation and visualization of the
-* syntax and semantics of ABAP statements, not to solve concrete
-* programming tasks. For production application programs, you should
-* always work out your own solution for each individual case. There is
-* no guarantee for the correctness or completeness of the code.
-* Furthermore, there is no legal responsibility or liability for any
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
diff --git a/src/zbp_demo_abap_rap_draft_m.clas.xml b/src/zbp_demo_abap_rap_draft_m.clas.xml
index 02a0569..86c9a76 100644
--- a/src/zbp_demo_abap_rap_draft_m.clas.xml
+++ b/src/zbp_demo_abap_rap_draft_m.clas.xml
@@ -10,7 +10,7 @@
1
X
X
- 5
+ X
ZDEMO_ABAP_RAP_DRAFT_M
diff --git a/src/zbp_demo_abap_rap_ro_m.clas.abap b/src/zbp_demo_abap_rap_ro_m.clas.abap
index 332c226..8207782 100644
--- a/src/zbp_demo_abap_rap_ro_m.clas.abap
+++ b/src/zbp_demo_abap_rap_ro_m.clas.abap
@@ -16,5 +16,5 @@ ENDCLASS.
-CLASS zbp_demo_abap_rap_ro_m IMPLEMENTATION.
+CLASS ZBP_DEMO_ABAP_RAP_RO_M IMPLEMENTATION.
ENDCLASS.
diff --git a/src/zbp_demo_abap_rap_ro_m.clas.locals_imp.abap b/src/zbp_demo_abap_rap_ro_m.clas.locals_imp.abap
index 9a8af2b..0826a5c 100644
--- a/src/zbp_demo_abap_rap_ro_m.clas.locals_imp.abap
+++ b/src/zbp_demo_abap_rap_ro_m.clas.locals_imp.abap
@@ -21,13 +21,13 @@
*
* 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
-* intended to provide a better explanation and visualization of the
-* syntax and semantics of ABAP statements, not to solve concrete
-* programming tasks. For production application programs, you should
-* always work out your own solution for each individual case. There is
-* no guarantee for the correctness or completeness of the code.
-* Furthermore, there is no legal responsibility or liability for any
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
diff --git a/src/zbp_demo_abap_rap_ro_m.clas.xml b/src/zbp_demo_abap_rap_ro_m.clas.xml
index 5dde2e7..919f460 100644
--- a/src/zbp_demo_abap_rap_ro_m.clas.xml
+++ b/src/zbp_demo_abap_rap_ro_m.clas.xml
@@ -10,7 +10,7 @@
1
X
X
- 5
+ X
ZDEMO_ABAP_RAP_RO_M
diff --git a/src/zbp_demo_abap_rap_ro_u.clas.abap b/src/zbp_demo_abap_rap_ro_u.clas.abap
index b290a60..dc82b65 100644
--- a/src/zbp_demo_abap_rap_ro_u.clas.abap
+++ b/src/zbp_demo_abap_rap_ro_u.clas.abap
@@ -16,5 +16,5 @@ ENDCLASS.
-CLASS zbp_demo_abap_rap_ro_u IMPLEMENTATION.
+CLASS ZBP_DEMO_ABAP_RAP_RO_U IMPLEMENTATION.
ENDCLASS.
diff --git a/src/zbp_demo_abap_rap_ro_u.clas.locals_imp.abap b/src/zbp_demo_abap_rap_ro_u.clas.locals_imp.abap
index 9d52201..e1b4489 100644
--- a/src/zbp_demo_abap_rap_ro_u.clas.locals_imp.abap
+++ b/src/zbp_demo_abap_rap_ro_u.clas.locals_imp.abap
@@ -25,13 +25,13 @@
*
* 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
-* intended to provide a better explanation and visualization of the
-* syntax and semantics of ABAP statements, not to solve concrete
-* programming tasks. For production application programs, you should
-* always work out your own solution for each individual case. There is
-* no guarantee for the correctness or completeness of the code.
-* Furthermore, there is no legal responsibility or liability for any
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
diff --git a/src/zbp_demo_abap_rap_ro_u.clas.xml b/src/zbp_demo_abap_rap_ro_u.clas.xml
index 2f6c296..e3f8ebd 100644
--- a/src/zbp_demo_abap_rap_ro_u.clas.xml
+++ b/src/zbp_demo_abap_rap_ro_u.clas.xml
@@ -10,7 +10,7 @@
1
X
X
- 5
+ X
ZDEMO_ABAP_RAP_RO_U
diff --git a/src/zcl_demo_abap_amdp.clas.abap b/src/zcl_demo_abap_amdp.clas.abap
index 19bcaf2..58d4ea3 100644
--- a/src/zcl_demo_abap_amdp.clas.abap
+++ b/src/zcl_demo_abap_amdp.clas.abap
@@ -35,13 +35,13 @@
* ----------------------------- NOTE -----------------------------------
* 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
-* intended to provide a better explanation and visualization of the
-* syntax and semantics of ABAP statements, not to solve concrete
-* programming tasks. For production application programs, you should
-* always work out your own solution for each individual case. There is
-* no guarantee for the correctness or completeness of the code.
-* Furthermore, there is no legal responsibility or liability for any
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
@@ -113,30 +113,31 @@ CLASS zcl_demo_abap_amdp DEFINITION
"fill a demo database table to have data to work with in the example.
CLASS-METHODS class_constructor.
- "AMDP procedure
- "This method demonstrates the calling of an AMDP procedure from SQLScript.
- "In this example, the selection of data is 'delegated' to another AMDP method get_flights_amdp
- "in the same AMDP class. The method declaration includes the addition RAISING with an
- "exception class for AMDP-specific exceptions.
- CLASS-METHODS get_flights
- IMPORTING VALUE(carrid) TYPE zdemo_abap_fli-carrid
- EXPORTING VALUE(fli_tab) TYPE fli_tab
- RAISING cx_amdp_execution_error.
+ "AMDP procedure
+ "This method demonstrates the calling of an AMDP procedure from SQLScript.
+ "In this example, the selection of data is 'delegated' to another AMDP method get_flights_amdp
+ "in the same AMDP class. The method declaration includes the addition RAISING with an
+ "exception class for AMDP-specific exceptions.
+ CLASS-METHODS get_flights
+ IMPORTING VALUE(carrid) TYPE zdemo_abap_fli-carrid
+ EXPORTING VALUE(fli_tab) TYPE fli_tab
+ RAISING cx_amdp_execution_error.
- "AMDP Table Function for CDS Table Function
- "Note that, in this case, a static method declaration is required along with the special
- "syntax FOR TABLE FUNCTION. Plus, there are no parameters specified and the declaration
- "is made in the PUBLIC visibility section.
- CLASS-METHODS flight_analysis FOR TABLE FUNCTION zdemo_abap_table_function.
+ "AMDP Table Function for CDS Table Function
+ "Note that, in this case, a static method declaration is required along with the special
+ "syntax FOR TABLE FUNCTION. Plus, there are no parameters specified and the declaration
+ "is made in the PUBLIC visibility section.
+ CLASS-METHODS flight_analysis FOR TABLE FUNCTION zdemo_abap_table_function.
+ PROTECTED SECTION.
PRIVATE SECTION.
"AMDP procedure
"This method demonstrates the calling of an AMDP procedure from SQLScript as mentioned above.
CLASS-METHODS get_flights_amdp
- IMPORTING VALUE(carrid) TYPE zdemo_abap_fli-carrid
- EXPORTING VALUE(fli_tab) TYPE fli_tab
- RAISING cx_amdp_execution_error.
+ IMPORTING VALUE(carrid) TYPE zdemo_abap_fli-carrid
+ EXPORTING VALUE(fli_tab) TYPE fli_tab
+ RAISING cx_amdp_execution_error.
"AMDP table function
"AMDP table functions can only be called by other AMDP methods. In this example,
@@ -145,23 +146,119 @@ CLASS zcl_demo_abap_amdp DEFINITION
IMPORTING VALUE(carrid) TYPE zdemo_abap_flsch-carrid
RETURNING VALUE(carr_fli_tab) TYPE carr_fli_tab.
+ CONSTANTS nl TYPE string value cl_abap_char_utilities=>newline.
ENDCLASS.
+
+
CLASS zcl_demo_abap_amdp IMPLEMENTATION.
+
METHOD class_constructor.
"Filling demo database tables.
zcl_demo_abap_flight_tables=>fill_dbtabs( ).
ENDMETHOD.
+ METHOD flight_analysis
+ BY DATABASE FUNCTION
+ FOR HDB
+ LANGUAGE SQLSCRIPT
+ OPTIONS READ-ONLY
+ USING zdemo_abap_flsch "Two database tables are used and must both be specified here.
+ zdemo_abap_carr.
+* Reading data from two database tables
+ itab_cities =
+ select DISTINCT
+ zdemo_abap_flsch.mandt as client,
+ zdemo_abap_flsch.carrid as carrier_id,
+ zdemo_abap_flsch.airpfrom as airport_from,
+ zdemo_abap_flsch.airpto as airport_to,
+ zdemo_abap_flsch.fltime as flight_time,
+ zdemo_abap_flsch.distance as flight_distance,
+ zdemo_abap_flsch.distid as unit
+ from zdemo_abap_flsch;
+
+ itab_carrier_names =
+ select distinct
+ zdemo_abap_carr.mandt as client,
+ zdemo_abap_carr.carrid as carrier_id,
+ zdemo_abap_carr.carrname as carrier_name
+ from zdemo_abap_carr;
+
+* Returning joined data using an inner join
+ return
+ select fl.client, fl.carrier_id, ca.carrier_name,
+* Departure and destination airports are concatenated; then all results are joined by string aggregation
+ string_agg( concat(concat(fl.airport_from,' -> '),fl.airport_to), ', ' ORDER BY fl.airport_from) AS connections,
+* Retrieving the average flight time of all flights by carrier
+ AVG( fl.flight_time ) as avg_flight_time,
+* Retrieving the average flight distance of all flights by carrier; miles are converted to kilometers
+ avg( case 'MI'
+ when fl.unit then fl.flight_distance * 1.609
+ ELSE fl.flight_distance
+ END ) AS avg_distance
+ FROM :itab_cities AS fl
+ INNER JOIN :itab_carrier_names AS ca
+ ON ca.client = fl.client
+ AND ca.carrier_id = fl.carrier_id
+ WHERE fl.client = ca.client AND fl.carrier_id = ca.carrier_id
+ GROUP BY fl.client, ca.carrier_name, fl.carrier_id;
+ ENDMETHOD.
+
+
+ METHOD get_carr_fli
+ BY DATABASE FUNCTION
+ FOR HDB
+ LANGUAGE SQLSCRIPT
+ OPTIONS READ-ONLY
+ USING zdemo_abap_carr zdemo_abap_flsch.
+* AMDP table function to be called by other AMDP methods only.
+* In the example, joined data from two database table are returned.
+ RETURN
+ SELECT ca.carrname, fl.connid, fl.cityfrom, fl.cityto
+ FROM zdemo_abap_carr as ca
+ INNER JOIN zdemo_abap_flsch as fl
+ ON ca.carrid = fl.carrid
+ WHERE fl.carrid = :carrid
+ ORDER BY ca.mandt, ca.carrname, fl.connid;
+ ENDMETHOD.
+
+
+ METHOD get_flights
+ BY DATABASE PROCEDURE
+ FOR HDB
+ LANGUAGE SQLSCRIPT
+ OPTIONS READ-ONLY
+ USING zcl_demo_abap_amdp=>get_flights_amdp.
+* Another AMDP procedure is called from SQLScript
+ CALL "ZCL_DEMO_ABAP_AMDP=>GET_FLIGHTS_AMDP"(
+ carrid => :carrid,
+ fli_tab => :fli_tab );
+ ENDMETHOD.
+
+
+ METHOD get_flights_amdp
+ BY DATABASE PROCEDURE
+ FOR HDB
+ LANGUAGE SQLSCRIPT
+ OPTIONS READ-ONLY
+ USING zdemo_abap_fli.
+* Simple data selection
+ fli_tab = SELECT *
+ FROM "ZDEMO_ABAP_FLI"
+ WHERE carrid = :carrid
+ ORDER BY carrid;
+ ENDMETHOD.
+
+
METHOD if_oo_adt_classrun~main.
DATA(output) = NEW zcl_demo_abap_display( out ).
output->display( `ABAP Cheat Sheet Example: ABAP AMDP` ).
- output->display( `1. AMDP procedure` ).
+ output->display( `1) AMDP procedure` ).
"Declaring an internal table to store the data that are
"returned by the following method.
@@ -180,7 +277,7 @@ CLASS zcl_demo_abap_amdp IMPLEMENTATION.
**********************************************************************
- output->next_section( `2. Calling an AMDP Procedure from SQLScript` ).
+ output->next_section( `2) Calling an AMDP Procedure from SQLScript` ).
"As can be seen in the method implementation part, this AMDP procedure
"includes an AMDP procedure call from SQLScript.
@@ -203,7 +300,7 @@ CLASS zcl_demo_abap_amdp IMPLEMENTATION.
**********************************************************************
- output->next_section( `3. AMDP Table Function for AMDP Method` ).
+ output->next_section( `3) AMDP Table Function for AMDP Method` ).
"The AMDP procedure select_get_carr_fli calls the AMDP table function
"get_carr_fli in the implementation part. AMDP table functions can
@@ -229,20 +326,20 @@ CLASS zcl_demo_abap_amdp IMPLEMENTATION.
**********************************************************************
- output->next_section( `4. AMDP Table Function for CDS Table Function` ).
+ output->next_section( `4) AMDP Table Function for CDS Table Function` ).
- "The example demonstrates that a CDS table function can be used as a
- "data source of ABAP SQL read statements.
- "You might want to navigate to the DDL source after FROM by holding
- "CTRL and clicking the DDL source name in ADT to see the details.
- "Or, just check out the F2 help.
- "In this example, the CDS table function is implemented in a way to
- "return accumulated data.
- "In the method implementation for flight_analysis, first two kinds of
- "data sets from two database tables are gathered. These data sets are
- "joined using an inner join. There, some expressions are included
- "(strings are aggregated, average values are determined).
+ "The example demonstrates that a CDS table function can be used as a
+ "data source of ABAP SQL read statements.
+ "You might want to navigate to the DDL source after FROM by holding
+ "CTRL and clicking the DDL source name in ADT to see the details.
+ "Or, just check out the F2 help.
+ "In this example, the CDS table function is implemented in a way to
+ "return accumulated data.
+ "In the method implementation for flight_analysis, first two kinds of
+ "data sets from two database tables are gathered. These data sets are
+ "joined using an inner join. There, some expressions are included
+ "(strings are aggregated, average values are determined).
SELECT * FROM zdemo_abap_table_function
INTO TABLE @DATA(cds_tab_func).
@@ -251,7 +348,6 @@ CLASS zcl_demo_abap_amdp IMPLEMENTATION.
ENDMETHOD.
-**********************************************************************
METHOD select_carriers
BY DATABASE PROCEDURE
@@ -265,93 +361,6 @@ CLASS zcl_demo_abap_amdp IMPLEMENTATION.
ORDER BY carrid;
ENDMETHOD.
- METHOD get_flights
- BY DATABASE PROCEDURE
- FOR HDB
- LANGUAGE SQLSCRIPT
- OPTIONS READ-ONLY
- USING zcl_demo_abap_amdp=>get_flights_amdp.
-* Another AMDP procedure is called from SQLScript
- CALL "ZCL_DEMO_ABAP_AMDP=>GET_FLIGHTS_AMDP"(
- CARRID => :CARRID,
- FLI_TAB => :FLI_TAB );
- ENDMETHOD.
-
- METHOD get_flights_amdp
- BY DATABASE PROCEDURE
- FOR HDB
- LANGUAGE SQLSCRIPT
- OPTIONS READ-ONLY
- USING zdemo_abap_fli.
-* Simple data selection
- fli_tab = SELECT *
- FROM "ZDEMO_ABAP_FLI"
- WHERE carrid = :carrid
- ORDER BY carrid;
- ENDMETHOD.
-
- METHOD flight_analysis
- BY DATABASE FUNCTION
- FOR HDB
- LANGUAGE SQLSCRIPT
- OPTIONS READ-ONLY
- USING zdemo_abap_flsch "Two database tables are used and must both be specified here.
- zdemo_abap_carr.
-* Reading data from two database tables
- itab_cities =
- SELECT DISTINCT
- zdemo_abap_flsch.mandt as client,
- zdemo_abap_flsch.carrid as carrier_id,
- zdemo_abap_flsch.airpfrom as airport_from,
- zdemo_abap_flsch.airpto as airport_to,
- zdemo_abap_flsch.fltime as flight_time,
- zdemo_abap_flsch.distance as flight_distance,
- zdemo_abap_flsch.distid as unit
- FROM zdemo_abap_flsch;
-
- itab_carrier_names =
- SELECT DISTINCT
- zdemo_abap_carr.mandt as client,
- zdemo_abap_carr.carrid as carrier_id,
- zdemo_abap_carr.carrname as carrier_name
- FROM zdemo_abap_carr;
-
-* Returning joined data using an inner join
- RETURN
- SELECT fl.client, fl.carrier_id, ca.carrier_name,
-* Departure and destination airports are concatenated; then all results are joined by string aggregation
- STRING_AGG( CONCAT(CONCAT(fl.airport_from,' -> '),fl.airport_to), ', ' ORDER BY fl.airport_from) AS connections,
-* Retrieving the average flight time of all flights by carrier
- AVG( fl.flight_time ) as avg_flight_time,
-* Retrieving the average flight distance of all flights by carrier; miles are converted to kilometers
- AVG( CASE 'MI'
- WHEN fl.unit THEN fl.flight_distance * 1.609
- ELSE fl.flight_distance
- END ) AS avg_distance
- FROM :itab_cities AS fl
- INNER JOIN :itab_carrier_names AS ca
- ON ca.client = fl.client
- AND ca.carrier_id = fl.carrier_id
- WHERE fl.client = ca.client AND fl.carrier_id = ca.carrier_id
- GROUP BY fl.client, ca.carrier_name, fl.carrier_id;
- ENDMETHOD.
-
- METHOD get_carr_fli
- BY DATABASE FUNCTION
- FOR HDB
- LANGUAGE SQLSCRIPT
- OPTIONS READ-ONLY
- USING zdemo_abap_carr zdemo_abap_flsch.
-* AMDP table function to be called by other AMDP methods only.
-* In the example, joined data from two database table are returned.
- RETURN
- SELECT ca.carrname, fl.connid, fl.cityfrom, fl.cityto
- FROM zdemo_abap_carr as ca
- INNER JOIN zdemo_abap_flsch as fl
- ON ca.carrid = fl.carrid
- WHERE fl.carrid = :carrid
- ORDER BY ca.mandt, ca.carrname, fl.connid;
- ENDMETHOD.
METHOD select_get_carr_fli
BY DATABASE PROCEDURE
@@ -364,5 +373,4 @@ CLASS zcl_demo_abap_amdp IMPLEMENTATION.
FROM "ZCL_DEMO_ABAP_AMDP=>GET_CARR_FLI"(
carrid => :carrid );
ENDMETHOD.
-
ENDCLASS.
diff --git a/src/zcl_demo_abap_amdp.clas.xml b/src/zcl_demo_abap_amdp.clas.xml
index 596e556..f24acab 100644
--- a/src/zcl_demo_abap_amdp.clas.xml
+++ b/src/zcl_demo_abap_amdp.clas.xml
@@ -9,7 +9,7 @@
1
X
X
- 5
+ X
diff --git a/src/zcl_demo_abap_cds_ve.clas.abap b/src/zcl_demo_abap_cds_ve.clas.abap
index ac7dddb..bb5d15f 100644
--- a/src/zcl_demo_abap_cds_ve.clas.abap
+++ b/src/zcl_demo_abap_cds_ve.clas.abap
@@ -30,13 +30,13 @@
* ----------------------------- NOTE -----------------------------------
* 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
-* intended to provide a better explanation and visualization of the
-* syntax and semantics of ABAP statements, not to solve concrete
-* programming tasks. For production application programs, you should
-* always work out your own solution for each individual case. There is
-* no guarantee for the correctness or completeness of the code.
-* Furthermore, there is no legal responsibility or liability for any
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
@@ -53,11 +53,13 @@ CLASS zcl_demo_abap_cds_ve DEFINITION
if_oo_adt_classrun.
CLASS-METHODS class_constructor.
-
ENDCLASS.
+
+
CLASS zcl_demo_abap_cds_ve IMPLEMENTATION.
+
METHOD class_constructor.
"Filling demo database tables.
zcl_demo_abap_flight_tables=>fill_dbtabs( ).
@@ -91,9 +93,9 @@ CLASS zcl_demo_abap_cds_ve IMPLEMENTATION.
period = 0 ) ) ).
MODIFY zdemo_abap_fli FROM TABLE @( VALUE #( ( carrid = 'UA' ) ) ).
-
ENDMETHOD.
+
METHOD if_oo_adt_classrun~main.
DATA(output) = NEW zcl_demo_abap_display( out ).
@@ -101,7 +103,7 @@ CLASS zcl_demo_abap_cds_ve IMPLEMENTATION.
output->display( `ABAP Cheat Sheet Example: CDS view entities` ).
output->display( `1) Operands, expressions and built-in functions ` &&
- `in a CDS view entity` ).
+ `in a CDS view entity` ).
"The following ABAP SQL SELECT statement uses a CDS view entity as
"the data source. All data is retrieved. The sample CDS view entity
@@ -170,7 +172,7 @@ CLASS zcl_demo_abap_cds_ve IMPLEMENTATION.
" contain the coalesce function and CASE expressions similar to the
" CDS view entity.
- output->display( `----- Inner join -----` ).
+ output->display( `---------- Inner join ----------` ).
SELECT _carr~carrid,
_carr~carrname,
@@ -184,7 +186,7 @@ CLASS zcl_demo_abap_cds_ve IMPLEMENTATION.
output->display( input = sql_inner_join name = `sql_inner_join` ).
- output->display( `----- Left outer join -----` ).
+ output->display( `---------- Left outer join ----------` ).
SELECT _carr~carrid,
_carr~carrname,
@@ -198,7 +200,7 @@ CLASS zcl_demo_abap_cds_ve IMPLEMENTATION.
output->display( input = sql_left_outer_join name = `sql_left_outer_join` ).
- output->display( `----- Right outer join -----` ).
+ output->display( `---------- Right outer join ----------` ).
SELECT _carr~carrid,
_carr~carrname,
@@ -215,7 +217,7 @@ CLASS zcl_demo_abap_cds_ve IMPLEMENTATION.
output->display( input = sql_right_outer_join name = `sql_right_outer_join` ).
- output->display( `----- Cross join -----` ).
+ output->display( `---------- Cross join ----------` ).
SELECT _carr~carrid,
_carr~carrname,
@@ -255,7 +257,7 @@ CLASS zcl_demo_abap_cds_ve IMPLEMENTATION.
output->next_section( `Associations` ).
- output->display( `5) Selecting data from a CDS view that contains associations` ).
+ output->display( `5) Selecting data from a CDS view that contains associations` ).
"The following ABAP SQL SELECT statement uses a CDS view entity as
"the data source. All data is retrieved. The sample CDS view entity
@@ -281,7 +283,7 @@ CLASS zcl_demo_abap_cds_ve IMPLEMENTATION.
"The following examples use path expressions to access the association
"targets of exposed associations.
- output->display( `6) ... SELECT clause` ).
+ output->display( `6) ... SELECT clause` ).
"The following ABAP SQL SELECT statement uses a CDS view entity as
"the data source. The statement uses an exposed association.
@@ -359,7 +361,7 @@ CLASS zcl_demo_abap_cds_ve IMPLEMENTATION.
**********************************************************************
- output->next_section( `8) ... Specifying attributes ` ).
+ output->next_section( `8) ... Specifying attributes` ).
"The following ABAP SQL SELECT statement uses a CDS view entity as
"the data source. The statement uses an exposed association.
@@ -460,5 +462,4 @@ CLASS zcl_demo_abap_cds_ve IMPLEMENTATION.
output->display( input = assoc_exp_where name = `assoc_exp_where` ).
ENDMETHOD.
-
ENDCLASS.
diff --git a/src/zcl_demo_abap_cds_ve.clas.xml b/src/zcl_demo_abap_cds_ve.clas.xml
index 11c5b1f..b96cc18 100644
--- a/src/zcl_demo_abap_cds_ve.clas.xml
+++ b/src/zcl_demo_abap_cds_ve.clas.xml
@@ -9,7 +9,7 @@
1
X
X
- 5
+ X
diff --git a/src/zcl_demo_abap_constructor_expr.clas.abap b/src/zcl_demo_abap_constructor_expr.clas.abap
index f5fd895..e550065 100644
--- a/src/zcl_demo_abap_constructor_expr.clas.abap
+++ b/src/zcl_demo_abap_constructor_expr.clas.abap
@@ -25,13 +25,13 @@
* ----------------------------- NOTE -----------------------------------
* 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
-* intended to provide a better explanation and visualization of the
-* syntax and semantics of ABAP statements, not to solve concrete
-* programming tasks. For production application programs, you should
-* always work out your own solution for each individual case. There is
-* no guarantee for the correctness or completeness of the code.
-* Furthermore, there is no legal responsibility or liability for any
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
@@ -96,7 +96,8 @@ protected section.
tab1 TYPE TABLE OF s1_type WITH EMPTY KEY,
tab2 TYPE TABLE OF s2_type WITH EMPTY KEY,
tab3 TYPE TABLE OF s2_type WITH EMPTY KEY,
- tab4 TYPE SORTED TABLE OF s2_type WITH NON-UNIQUE KEY comp3.
+ tab4 TYPE SORTED TABLE OF s2_type WITH NON-UNIQUE KEY comp3,
+ nl TYPE string..
CLASS-METHODS:
fill_deep_structures,
@@ -105,15 +106,69 @@ protected section.
ENDCLASS.
+
CLASS zcl_demo_abap_constructor_expr IMPLEMENTATION.
+
+ METHOD fill_deep_structures.
+ "Clearing all contents of struc2
+ CLEAR struc2.
+ "Filling nested tables in deep structures
+ struc2-struc_nested = VALUE #( comp1 = `aaa`
+ comp2 = `bbb`
+ comp3 = `ccc` ).
+
+ struc1-itab = VALUE #(
+ ( col1 = 111 col2 = 222 )
+ ( col1 = 333 col2 = 444
+ ) ).
+
+ struc2-itab = VALUE #(
+ ( col2 = 1 col3 = 2 col4 = 3 )
+ ( col2 = 4 col3 = 5 col4 = 6 )
+ ( col2 = 7 col3 = 8 col4 = 9 )
+ ).
+
+ "Filling individual component that is not shared by both structures
+ struc2-comp4 = 999.
+ ENDMETHOD.
+
+
+ METHOD fill_struc_and_tab.
+ CLEAR: s1, s2, tab1, tab2, tab3.
+
+ s1 = VALUE #( comp1 = 'A' comp2 = `bbb` comp3 = 1 ).
+
+ s2 = VALUE #( comp1 = `ccc` comp2 = 'D' comp3 = 2 comp4 = 3 ).
+
+ tab1 = VALUE #(
+ ( comp1 = 'A' comp2 = `bbb` comp3 = 1 )
+ ( comp1 = 'B' comp2 = `ccc` comp3 = 2 )
+ ( comp1 = 'C' comp2 = `ddd` comp3 = 3 ) ).
+
+ tab2 = VALUE #(
+ ( comp1 = `eee` comp2 = 'F' comp3 = 4 comp4 = 5 )
+ ( comp1 = `ggg` comp2 = 'H' comp3 = 6 comp4 = 7 )
+ ( comp1 = `iii` comp2 = 'J' comp3 = 8 comp4 = 9 ) ).
+
+ tab3 = VALUE #(
+ ( comp1 = `aaa` comp2 = 'B' comp3 = 1 comp4 = 2 )
+ ( comp1 = `ccc` comp2 = 'D' comp3 = 3 comp4 = 4 )
+ ( comp1 = `eee` comp2 = 'F' comp3 = 5 comp4 = 6 )
+ ( comp1 = `ggg` comp2 = 'H' comp3 = 7 comp4 = 8 )
+ ( comp1 = `iii` comp2 = 'J' comp3 = 9 comp4 = 10 ) ).
+
+ tab4 = tab3.
+ ENDMETHOD.
+
+
METHOD if_oo_adt_classrun~main.
DATA(output) = NEW zcl_demo_abap_display( out ).
output->display( `ABAP Cheat Sheet Example: Constructor expressions` ).
- output->next_section( `VALUE` ).
+ output->display( `VALUE` ).
output->display( `1) Structures: Populating a flat structure` ).
"A flat structure is created based on a data type defined with a
@@ -147,7 +202,7 @@ CLASS zcl_demo_abap_constructor_expr IMPLEMENTATION.
"You can use the BASE addition to retain existing content
"Compare with the BASE example further down regarding internal tables: There are
- "no extra parentheses within the outer pair of parentheses.
+ "no extra parentheses within the outer pair of parentheses.
struc = VALUE #( BASE struc char2 = 'xyz' ).
output->display( input = struc name = `struc` ).
@@ -185,7 +240,7 @@ CLASS zcl_demo_abap_constructor_expr IMPLEMENTATION.
itab = VALUE #( ( num = 1 char1 = 'aaa' char2 = 'abc' )
( num = 2 char1 = 'bbb' char2 = 'def' )
- ( num = 3 char1 = 'ccc' ) ).
+ ( num = 3 char1 = 'ccc' ) ).
output->display( input = itab name = `itab` ).
@@ -312,7 +367,7 @@ CLASS zcl_demo_abap_constructor_expr IMPLEMENTATION.
carrname = 'Singapore Airlines'
currcode = 'SGD'
url = 'http://www.singaporeair.com' )
- ) ).
+ ) ).
"Retrieving table entries for display purposes
SELECT FROM zdemo_abap_carr
@@ -341,7 +396,7 @@ CLASS zcl_demo_abap_constructor_expr IMPLEMENTATION.
END OF substruc,
END OF deep_struc_ty.
- DATA(deep_struc) = VALUE deep_struc_ty( num = 1
+ DATA(deep_struc) = VALUE deep_struc_ty( num = 1
char1 = 'aaa'
substruc = VALUE #( int = 123 str = `hallo` ) ).
@@ -744,25 +799,25 @@ CLASS zcl_demo_abap_constructor_expr IMPLEMENTATION.
output->display( input = dec_num name = `dec_num` ).
"Declaring data objects
- DATA(txt) = VALUE abap_bool( ).
+ DATA(txt) = VALUE abap_bool( ).
DATA(str) = ` `.
"Comparing the data objects with and without conversion
- output->display( `Without conversion:` ).
+ output->display( `Without conversion:` ).
IF txt = str.
- output->display( `txt is equal to str.` ).
+ output->display( `txt is equal to str.` ).
ELSE.
- output->display( `txt is not equal to str.` ).
+ output->display( `txt is not equal to str.` ).
ENDIF.
- output->display( `With conversion:` ).
+ output->display( `With conversion:` ).
IF txt = CONV abap_bool( str ).
- output->display( `txt is equal to converted str.` ).
+ output->display( `txt is equal to converted str.` ).
ELSE.
- output->display( `txt is not equal to converted str.` ).
+ output->display( `txt is not equal to converted str.` ).
ENDIF.
**********************************************************************
@@ -806,13 +861,13 @@ CLASS zcl_demo_abap_constructor_expr IMPLEMENTATION.
DATA(conv_comp) = CONV numtext( '2 Apples + 5 Oranges' ).
IF ex1 IS INITIAL.
- output->display( |ex2: { ex2 }; { t1 }| ).
+ output->display( |ex2: { ex2 }; { t1 }| ).
ELSE.
output->display( ex1 ).
ENDIF.
IF ex3 IS INITIAL.
- output->display( |ex4: { ex4 }; { t2 }| ).
+ output->display( |ex4: { ex4 }; { t2 }| ).
ELSE.
output->display( input = ex3 name = `ex3` ).
ENDIF.
@@ -891,7 +946,7 @@ CLASS zcl_demo_abap_constructor_expr IMPLEMENTATION.
DATA(methods) =
CAST cl_abap_objectdescr(
cl_abap_objectdescr=>describe_by_name( 'LOCAL_CLASS' )
- )->methods.
+ )->methods.
"Excursion: Using the older cast operator ?=
"Retrieving structure components
@@ -940,7 +995,7 @@ CLASS zcl_demo_abap_constructor_expr IMPLEMENTATION.
THEN |It's { syst_time TIME = ISO }. | &&
|Good night, { sy-uname }.|
ELSE |Hallo, { sy-uname }.|
- ).
+ ).
output->display( input = greets name = `greets` ).
@@ -1173,7 +1228,7 @@ CLASS zcl_demo_abap_constructor_expr IMPLEMENTATION.
FOR wa3 IN tab3 WHERE ( comp3 < 4 )
( compX = wa1-comp1
compY = wa2-comp1
- compZ = wa3-comp3 ) ).
+ compZ = wa3-comp3 ) ).
output->display( input = for4 name = `for4` ).
@@ -1202,12 +1257,12 @@ CLASS zcl_demo_abap_constructor_expr IMPLEMENTATION.
"FOR ... WHILE ...
DATA(for5) = VALUE t_type4(
FOR x = 11 THEN x + 10 WHILE x < 40
- ( col1 = x col2 = x + 1 col3 = x + 2 ) ).
+ ( col1 = x col2 = x + 1 col3 = x + 2 ) ).
"FOR ... UNTIL ...
DATA(for6) = VALUE t_type4(
FOR y = 31 THEN y - 10 UNTIL y < 10
- ( col1 = y col2 = y + 1 col3 = y + 2 ) ).
+ ( col1 = y col2 = y + 1 col3 = y + 2 ) ).
output->display( input = for5 name = `for5` ).
output->display( input = for6 name = `for6` ).
@@ -1242,7 +1297,7 @@ CLASS zcl_demo_abap_constructor_expr IMPLEMENTATION.
DATA(a_word) =
REDUCE string( INIT text = ``
FOR word IN tab
- NEXT text = |{ text }{ word }| ).
+ NEXT text = |{ text }{ word }| ).
"Example 2
tab = VALUE #( ( `Some` ) ( `cool` ) ( `stuff` )
@@ -1335,7 +1390,7 @@ CLASS zcl_demo_abap_constructor_expr IMPLEMENTATION.
output->display( input = str_tab name = `str_tab` ).
-**********************************************************************
+**********************************************************************
output->next_section( `42) LET Expressions (2)` ).
@@ -1389,7 +1444,7 @@ CLASS zcl_demo_abap_constructor_expr IMPLEMENTATION.
LET = dates[ sy-index ]
separator = '-'
IN -year && separator && -month &&
- separator && -day ).
+ separator && -day ).
"Adding line to table
stringtab = VALUE #( BASE stringtab ( isodate ) ).
@@ -1398,55 +1453,4 @@ CLASS zcl_demo_abap_constructor_expr IMPLEMENTATION.
output->display( input = stringtab name = `stringtab` ).
ENDMETHOD.
-
- METHOD fill_deep_structures.
- "Clearing all contents of struc2
- CLEAR struc2.
- "Filling nested tables in deep structures
- struc2-struc_nested = VALUE #( comp1 = `aaa`
- comp2 = `bbb`
- comp3 = `ccc` ).
-
- struc1-itab = VALUE #(
- ( col1 = 111 col2 = 222 )
- ( col1 = 333 col2 = 444
- ) ).
-
- struc2-itab = VALUE #(
- ( col2 = 1 col3 = 2 col4 = 3 )
- ( col2 = 4 col3 = 5 col4 = 6 )
- ( col2 = 7 col3 = 8 col4 = 9 )
- ).
-
- "Filling individual component that is not shared by both structures
- struc2-comp4 = 999.
- ENDMETHOD.
-
- METHOD fill_struc_and_tab.
- CLEAR: s1, s2, tab1, tab2, tab3.
-
- s1 = VALUE #( comp1 = 'A' comp2 = `bbb` comp3 = 1 ).
-
- s2 = VALUE #( comp1 = `ccc` comp2 = 'D' comp3 = 2 comp4 = 3 ).
-
- tab1 = VALUE #(
- ( comp1 = 'A' comp2 = `bbb` comp3 = 1 )
- ( comp1 = 'B' comp2 = `ccc` comp3 = 2 )
- ( comp1 = 'C' comp2 = `ddd` comp3 = 3 ) ).
-
- tab2 = VALUE #(
- ( comp1 = `eee` comp2 = 'F' comp3 = 4 comp4 = 5 )
- ( comp1 = `ggg` comp2 = 'H' comp3 = 6 comp4 = 7 )
- ( comp1 = `iii` comp2 = 'J' comp3 = 8 comp4 = 9 ) ).
-
- tab3 = VALUE #(
- ( comp1 = `aaa` comp2 = 'B' comp3 = 1 comp4 = 2 )
- ( comp1 = `ccc` comp2 = 'D' comp3 = 3 comp4 = 4 )
- ( comp1 = `eee` comp2 = 'F' comp3 = 5 comp4 = 6 )
- ( comp1 = `ggg` comp2 = 'H' comp3 = 7 comp4 = 8 )
- ( comp1 = `iii` comp2 = 'J' comp3 = 9 comp4 = 10 ) ).
-
- tab4 = tab3.
- ENDMETHOD.
-
-ENDCLASS.
\ No newline at end of file
+ENDCLASS.
diff --git a/src/zcl_demo_abap_constructor_expr.clas.xml b/src/zcl_demo_abap_constructor_expr.clas.xml
index 26ce35e..45764df 100644
--- a/src/zcl_demo_abap_constructor_expr.clas.xml
+++ b/src/zcl_demo_abap_constructor_expr.clas.xml
@@ -9,7 +9,7 @@
1
X
X
- 5
+ X
diff --git a/src/zcl_demo_abap_display.clas.abap b/src/zcl_demo_abap_display.clas.abap
index 768a4ed..67ed4da 100644
--- a/src/zcl_demo_abap_display.clas.abap
+++ b/src/zcl_demo_abap_display.clas.abap
@@ -5,7 +5,7 @@
*
* -------------------------- NOTE -------------------------------------
* This helper class is only used to display complex types contained in
-* the example classes of the ABAP cheat sheets in older ABAP releases.
+* the example classes of the ABAP cheat sheets in older ABAP releases.
* In newer ABAP releases, this helper class is, in principle, not needed.
* You can use the write method of the classrun interface directly and
* display all types.
@@ -45,22 +45,25 @@ CLASS zcl_demo_abap_display DEFINITION
IMPORTING
heading TYPE string.
-protected section.
+ PROTECTED SECTION.
PRIVATE SECTION.
DATA:
mo_out TYPE REF TO if_oo_adt_classrun_out,
offset TYPE i.
+ CONSTANTS nl TYPE string VALUE cl_abap_char_utilities=>newline.
ENDCLASS.
-CLASS ZCL_DEMO_ABAP_DISPLAY IMPLEMENTATION.
+CLASS zcl_demo_abap_display IMPLEMENTATION.
+
METHOD constructor.
mo_out = io_out.
ENDMETHOD.
+
METHOD display.
"Checking data type
DATA(type_descr) = cl_abap_typedescr=>describe_by_data( input ).
@@ -97,7 +100,7 @@ CLASS ZCL_DEMO_ABAP_DISPLAY IMPLEMENTATION.
WHEN cl_abap_typedescr=>kind_intf.
to_be_serialized = abap_true.
WHEN cl_abap_typedescr=>kind_elem.
- display = mo_out->get( data = COND string( WHEN name IS INITIAL THEN input ELSE `"` && name && `":` && cl_abap_char_utilities=>newline && input ) ).
+ display = mo_out->get( data = COND string( WHEN name IS INITIAL THEN input ELSE `"` && name && `":` && nl && input ) ).
WHEN cl_abap_typedescr=>kind_ref.
"Checking for data references
IF type_descr->type_kind = cl_abap_typedescr=>typekind_dref.
@@ -105,7 +108,7 @@ CLASS ZCL_DEMO_ABAP_DISPLAY IMPLEMENTATION.
DATA(type_check_dref) = cl_abap_typedescr=>describe_by_data( input->* ).
"Processing (non-)elementary types
IF type_check_dref->kind = type_descr->kind_elem.
- display = mo_out->get( data = COND string( WHEN name IS INITIAL THEN input->* ELSE `"` && name && `":` && cl_abap_char_utilities=>newline && input->* ) ).
+ display = mo_out->get( data = COND string( WHEN name IS INITIAL THEN input->* ELSE `"` && name && `":` && nl && input->* ) ).
ELSE.
to_be_serialized = abap_true.
ENDIF.
@@ -127,29 +130,31 @@ CLASS ZCL_DEMO_ABAP_DISPLAY IMPLEMENTATION.
assoc_arrays_opt = abap_true ).
IF to_be_serialized = abap_true.
IF name IS INITIAL.
- REPLACE PCRE `^` IN display WITH json && cl_abap_char_utilities=>newline.
+ REPLACE PCRE `^` IN display WITH json && nl.
ELSE.
- REPLACE PCRE `^` IN display WITH `"` && name && `":` && cl_abap_char_utilities=>newline && json && cl_abap_char_utilities=>newline.
+ REPLACE PCRE `^` IN display WITH `"` && name && `":` && nl && json && nl.
ENDIF.
- "substring found
+ "substring found
ELSE.
IF name IS INITIAL.
- REPLACE SECTION OFFSET off LENGTH len OF display WITH json && cl_abap_char_utilities=>newline.
+ REPLACE SECTION OFFSET off LENGTH len OF display WITH json && nl.
ELSE.
- REPLACE SECTION OFFSET off LENGTH len OF display WITH `"` && name && `":` && cl_abap_char_utilities=>newline && json && cl_abap_char_utilities=>newline.
+ REPLACE SECTION OFFSET off LENGTH len OF display WITH `"` && name && `":` && nl && json && nl.
ENDIF.
ENDIF.
- mo_out->write( display ).
+ mo_out->write( display && nl ).
ELSE.
- mo_out->write( display ).
+ mo_out->write( display && nl ).
ENDIF.
ENDMETHOD.
+
METHOD next_section.
mo_out->write( `_________________________________________________________________________________`
- && cl_abap_char_utilities=>newline
- && cl_abap_char_utilities=>newline
+ && nl
+ && nl
&& heading
- && cl_abap_char_utilities=>newline ).
+ && nl
+ && nl ).
ENDMETHOD.
-ENDCLASS.
\ No newline at end of file
+ENDCLASS.
diff --git a/src/zcl_demo_abap_dtype_dobj.clas.abap b/src/zcl_demo_abap_dtype_dobj.clas.abap
index 75aec68..7062054 100644
--- a/src/zcl_demo_abap_dtype_dobj.clas.abap
+++ b/src/zcl_demo_abap_dtype_dobj.clas.abap
@@ -115,7 +115,147 @@ CLASS zcl_demo_abap_dtype_dobj DEFINITION
ENDCLASS.
-CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
+
+CLASS ZCL_DEMO_ABAP_DTYPE_DOBJ IMPLEMENTATION.
+
+
+ METHOD adapt_text.
+ DATA text TYPE t_pub_text_c30.
+
+ text = cl_text && comma && sy-uname && me->text.
+
+ str = text && |\n(Note: The value of me->text is "{ me->text }")|.
+ ENDMETHOD.
+
+
+ METHOD addition_with_generic_num.
+ result = num1 + num2.
+ ENDMETHOD.
+
+
+ METHOD class_constructor.
+ "Filling demo database tables.
+ zcl_demo_abap_flight_tables=>fill_dbtabs( ).
+ ENDMETHOD.
+
+
+ METHOD enum_meth_params.
+
+ CASE char.
+ WHEN a.
+ output = a.
+ WHEN b.
+ output = b.
+ WHEN OTHERS.
+ output = `Either c or d: ` && char.
+ ENDCASE.
+
+ ENDMETHOD.
+
+
+ METHOD enum_processing.
+
+ "Read and write positions of enumerated objects
+ "Enumerated objects can be used in all read positions in which the operand
+ "type is their enumerated type.
+ "Likewise, enumerated variables can only be used in write positions in which
+ "the operand type is the enumerated type and only the associated enumerated
+ "values can be written.
+ "So, assignments are possible only from one enumerated type to the same (with one
+ "exception -> assignment to character-like variables of the types c and string)
+ DATA do_enum TYPE t_enum.
+ do_enum = a.
+ APPEND |do_enum: { do_enum }| TO output.
+
+ DATA do_enum_2 LIKE do_enum.
+ do_enum_2 = do_enum.
+ APPEND |do_enum_2: { do_enum_2 }| TO output.
+
+ "Assignment to character-like variables of the types c and string.
+ "In this case, the target field is assigned the name of the enumerated constant or
+ "the component of the enumerated structure under which the enumerated value of the
+ "source field is defined in the enumerated type.
+ DATA do_a_string TYPE string.
+ do_a_string = do_enum.
+ APPEND |do_a_string: { do_a_string }| TO output.
+
+ "Or using the CONV operator as follows
+ DATA(do_next_string) = CONV string( do_enum ).
+ APPEND |do_next_string: { do_next_string }| TO output.
+
+ "Enumerated constants are converted implicitly to the type string
+ "before the concatenation in the string template.
+ DATA(str_from_enum) = |{ a }{ b }{ c }{ d }|.
+ APPEND |str_from_enum: { str_from_enum }| TO output.
+
+ "Note that only the enumerated type itself is relevant. Usually, the content
+ "of an enumerated object is not of interest.
+ "The enumerated value in the base type can be accessed using the constructor
+ "operators CONV and EXACT only. The base type is i in this case.
+ DATA(conv_value) = CONV i( do_enum ).
+ APPEND |conv_value: { conv_value }| TO output.
+
+ "Converting the other way round.
+ DATA(another_conv) = CONV t_enum( 3 ).
+ APPEND |another_conv: { another_conv }| TO output.
+
+ "If known statically, an attempt to assign a value other than a valid enumerated value
+ "to an enumerated variable produces a syntax error.
+ "If not known statically, an exception is raised.
+ "The following produces a syntax error
+ "do_enum = f.
+
+ "The following example shows raising an exception.
+ DATA dobj TYPE t_enum.
+
+ TYPES t_int_tab TYPE TABLE OF i WITH EMPTY KEY.
+ DATA(int_tab) = VALUE t_int_tab( ( 0 ) ( 1 ) ( 2 ) ( 3 ) ( 4 ) ).
+
+ DATA str_tab TYPE TABLE OF string.
+ LOOP AT int_tab INTO DATA(wa_en).
+ TRY.
+ dobj = CONV t_enum( wa_en ).
+ APPEND dobj TO str_tab.
+ CATCH cx_sy_conversion_no_enum_value INTO DATA(error_enum).
+ APPEND error_enum->get_text( ) TO str_tab.
+ ENDTRY.
+ ENDLOOP.
+
+ APPEND `------------- START: Output for str_tab -------------` TO output.
+ APPEND LINES OF str_tab TO output.
+ APPEND `^^^^^^^^^^^^^ END: Output for str_tab ^^^^^^^^^^^^^` TO output.
+
+ "An enumerated variable can be set to the initial value of its base type
+ "using CLEAR.
+ CLEAR do_enum.
+ APPEND |do_enum: { do_enum }| TO output.
+
+ "Enumerated structures
+ DATA do_enum_s TYPE t_enum_struc.
+
+ "The enumerated structure en_struc was decalred in the public section.
+ "Using the addition LIKE, a second structure is created referring to the enumerated structure.
+ "Note that the second structure is not a constant structure.
+ "The components of the constant structure contain the enumerated values of the enumerated type.
+ "All the components of the variable structure declared by LIKE contain the initial values.
+ DATA do_s LIKE en_struc.
+ APPEND |do_s: { do_s-j } / { do_s-k } / { do_s-l } / { do_s-m }| TO output.
+
+ DATA(do_en) = en_struc.
+ APPEND |do_en: { do_en-j } / { do_en-k } / { do_en-l } / { do_en-m }| TO output.
+
+ "Accessing structure components using the component selector
+ DATA(do_en_k) = en_struc-k.
+ APPEND |do_en_k: { do_en_k }| TO output.
+
+ DATA(do_s_m) = do_s-m.
+ APPEND |do_s_m: { do_s_m }| TO output.
+ "Assigning enumerated constants to the variable structure
+ do_s = en_struc.
+ APPEND |do_s: { do_s-j } / { do_s-k } / { do_s-l } / { do_s-m }| TO output.
+
+ ENDMETHOD.
+
METHOD if_oo_adt_classrun~main.
@@ -232,7 +372,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `2) Declaring data types based on complex types` ).
+ output->next_section( `2) Declaring data types based on complex types` ).
"Structure and internal table types as examples for complex types
@@ -302,7 +442,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `3) Declaring reference types` ).
+ output->next_section( `3) Declaring reference types` ).
"Declaring reference types with static types
TYPES tr_i TYPE REF TO i.
@@ -339,7 +479,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `Declaring data objects` ).
+ output->next_section( `Declaring data objects` ).
"The following examples deal with the declaration of data ojects.
"They show how data objects can be declared locally in an ABAP program.
@@ -437,7 +577,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `5) Declaring structures and internal tables as examples for complex types` ).
+ output->next_section( `5) Declaring structures and internal tables as examples for complex types` ).
"Note: See more details and examples in the ABAP Keyword Documentations and in the
"respective ABAP cheat sheets.
@@ -498,7 +638,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `6) Declaring data reference variables` ).
+ output->next_section( `6) Declaring data reference variables` ).
"Declaring data reference variables types with static types
DATA dref_int TYPE REF TO i.
@@ -531,7 +671,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `7) Assigning values to data objects` ).
+ output->next_section( `7) Assigning values to data objects` ).
"An assignment passes the content of a source to a target data object.
"Note:
@@ -635,13 +775,13 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `8) Creating data objects by inline declaration` ).
+ output->next_section( `8) Creating data objects by inline declaration` ).
"The declaration operator DATA can be specified in any designated declaration position.
"The data type of the variable is determined by the operand type. It must be possible
"to derive this type completely statically.
"Note:
- "- In newer ABAP releases, the FINAL declaration operator is available for creating
+ "- The FINAL declaration operator is available for creating
" immutable variables as shon below.
"- As shown in the previous section, there are many options for what can be placed on
" the right side.
@@ -749,7 +889,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `9) Assigning references to data reference variables` ).
+ output->next_section( `9) Assigning references to data reference variables` ).
"Note:
"- As is true for other data object and types, there are special assignment rules
@@ -851,7 +991,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `10) Creating anonymous data objects` ).
+ output->next_section( `10) Creating anonymous data objects` ).
"Anonymous data objects are a topic related to data reference variables.
"These data objects are unnamed data objects.
@@ -956,7 +1096,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `Excursions: Elementary types and type conversions` ).
+ output->next_section( `Excursions: Elementary types and type conversions` ).
output->display( `11) Implicit and explicit conversion` ).
@@ -1029,7 +1169,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `12) Character strings and text field strings` ).
+ output->next_section( `12) Character strings and text field strings` ).
"The following example shows the difference between text field strings
"of type c and character strings of type string when it comes to trailing
@@ -1046,7 +1186,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `13) Floating point numbers` ).
+ output->next_section( `13) Floating point numbers` ).
"The following example shows the difference between binary and decimal
"floating point numbers.
@@ -1061,7 +1201,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `14) Byte-like types` ).
+ output->next_section( `14) Byte-like types` ).
"The following example shows byte-like types x and xstring.
@@ -1115,11 +1255,11 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `15) Date and time` ).
+ output->next_section( `15) Date and time` ).
- "In the example, date and time fields are assigned the current values
- "using the cl_abap_context_info class. Calculations follow. The date of next
- "day and the next hour are calculated.
+ "In the example, a date field is assigned the current values
+ "using the cl_abap_context_info class. A calculation follows. The date of next
+ "day is calculated.
"Note: The data types behave like numeric values in the context of calculations.
"In assignments and in the output, they behave like character-like types.
"The second example shows an undesired result for a conversion of type i to d.
@@ -1128,18 +1268,12 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
"In such a case, the date field is assigned the invalid value '00000000'.
DATA: today TYPE d,
- tomorrow TYPE d,
- now TYPE t,
- next_hour TYPE t.
- today = cl_abap_context_info=>get_system_date( ).
- now = cl_abap_context_info=>get_system_time( ).
- tomorrow = today + 1.
- next_hour = ( now + 3600 ) / 3600 * 3600.
+ tomorrow TYPE d.
+ today = cl_abap_context_info=>get_system_date( ).
+ tomorrow = today + 1.
output->display(
- |Today: { today }\n| &&
- |Now: { now }\n\n| &&
- |Tommorow: { tomorrow }\n| &&
- |Next Hour: { next_hour }| ).
+ |Today: { today }\n| &&
+ |Tommorow: { tomorrow }| ).
DATA date TYPE d.
date = '20240101'.
@@ -1150,7 +1284,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `16) Type conversion rules` ).
+ output->next_section( `16) Type conversion rules` ).
"The purpose of this example is to emphasize the conversion rules
"that should be noted when performing conversions. The example
@@ -1305,7 +1439,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `17) Excursion: RTTI` ).
+ output->next_section( `17) Excursion: RTTI` ).
"Using RTTI to check type compatibility
"In the following example the applies_to_data method of the RTTI class
@@ -1371,7 +1505,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `18) Constants and immutable variables` ).
+ output->next_section( `18) Constants and immutable variables` ).
"As mentioned above, constants cannot be changed at runtime.
CONSTANTS con_str TYPE string VALUE `hallo`.
@@ -1381,29 +1515,28 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
DATA str_w_con_as_start_value TYPE string VALUE con_underscores.
"Immutable variables
- "In newer ABAP releases, comment the code in.
-* FINAL(do_final_inl) = 1.
-* DATA(do_data_inl) = 1 + do_final_inl.
-* "not possible
-* "do_final_inl = 2.
-*
-* SELECT * FROM zdemo_abap_carr INTO TABLE @DATA(itab_data_inl).
-*
-* DATA itab_like_inline LIKE itab_data_inl.
-*
-* "Using an inline declaration as target of a LOOP statement
-* "A value is assigned multiple times, but it cannot be changed in any other
-* "write positions.
-* LOOP AT itab_data_inl INTO FINAL(wa_final).
-*
-* "The following is not possible
-* "wa_final-carrid = 'd'.
-* "only read access
-* APPEND wa_final TO itab_like_inline.
-* ENDLOOP.
-*
-* "SELECT statement with a an immutable target table declared inline
-* SELECT * FROM zdemo_abap_carr INTO TABLE @FINAL(itab_final_inl).
+ FINAL(do_final_inl) = 1.
+ DATA(do_data_inl) = 1 + do_final_inl.
+ "not possible
+ "do_final_inl = 2.
+
+ SELECT * FROM zdemo_abap_carr INTO TABLE @DATA(itab_data_inl).
+
+ DATA itab_like_inline LIKE itab_data_inl.
+
+ "Using an inline declaration as target of a LOOP statement
+ "A value is assigned multiple times, but it cannot be changed in any other
+ "write positions.
+ LOOP AT itab_data_inl INTO FINAL(wa_final).
+
+ "The following is not possible
+ "wa_final-carrid = 'd'.
+ "only read access
+ APPEND wa_final TO itab_like_inline.
+ ENDLOOP.
+
+ "SELECT statement with a an immutable target table declared inline
+ SELECT * FROM zdemo_abap_carr INTO TABLE @FINAL(itab_final_inl).
output->display( `No output for this section. Check out the code, `
&& `for example, when running the class in the debugger after setting `
@@ -1411,7 +1544,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `19) Various ABAP glossary terms on data types and objects in a nutshell` ).
+ output->next_section( `19) Various ABAP glossary terms on data types and objects in a nutshell` ).
"Standalone and bound data types
"Standalone: Data type that is defined using the statement TYPES in an ABAP program, as
@@ -1639,7 +1772,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `20) Generic ABAP types for formal parameters of methods` ).
+ output->next_section( `20) Generic ABAP types for formal parameters of methods` ).
"Generic data types have already been covered above.
"A generic data type is an incomplete type specification that covers multiple
@@ -1681,7 +1814,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `21) Built-in data objects` ).
+ output->next_section( `21) Built-in data objects` ).
"This example demonstrates the availability of built-in data objects in ABAP.
@@ -1760,7 +1893,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `22) Declaration context` ).
+ output->next_section( `22) Declaration context` ).
"The purpose of this example is to emphasize the importance of where
"data objects are decalred. The example deals with local declarations
@@ -1806,7 +1939,7 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
**********************************************************************
- output->display( `23) Enumerated Types and Objects` ).
+ output->next_section( `23) Enumerated Types and Objects` ).
"Examples for enumerated types and objects are contained in
"separate methods. Check the comments there.
@@ -1841,138 +1974,6 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
ENDMETHOD.
- METHOD adapt_text.
- DATA text TYPE t_pub_text_c30.
-
- text = cl_text && comma && sy-uname && me->text.
-
- str = text && |\n(Note: The value of me->text is "{ me->text }")|.
- ENDMETHOD.
-
- METHOD class_constructor.
- "Filling demo database tables.
- zcl_demo_abap_flight_tables=>fill_dbtabs( ).
- ENDMETHOD.
-
- METHOD addition_with_generic_num.
- result = num1 + num2.
- ENDMETHOD.
-
- METHOD enum_meth_params.
-
- CASE char.
- WHEN a.
- output = a.
- WHEN b.
- output = b.
- WHEN OTHERS.
- output = `Either c or d: ` && char.
- ENDCASE.
-
- ENDMETHOD.
-
- METHOD enum_processing.
-
- "Read and write positions of enumerated objects
- "Enumerated objects can be used in all read positions in which the operand
- "type is their enumerated type.
- "Likewise, enumerated variables can only be used in write positions in which
- "the operand type is the enumerated type and only the associated enumerated
- "values can be written.
- "So, assignments are possible only from one enumerated type to the same (with one
- "exception -> assignment to character-like variables of the types c and string)
- DATA do_enum TYPE t_enum.
- do_enum = a.
- APPEND |do_enum: { do_enum }| TO output.
-
- DATA do_enum_2 LIKE do_enum.
- do_enum_2 = do_enum.
- APPEND |do_enum_2: { do_enum_2 }| TO output.
-
- "Assignment to character-like variables of the types c and string.
- "In this case, the target field is assigned the name of the enumerated constant or
- "the component of the enumerated structure under which the enumerated value of the
- "source field is defined in the enumerated type.
- DATA do_a_string TYPE string.
- do_a_string = do_enum.
- APPEND |do_a_string: { do_a_string }| TO output.
-
- "Or using the CONV operator as follows
- DATA(do_next_string) = CONV string( do_enum ).
- APPEND |do_next_string: { do_next_string }| TO output.
-
- "Enumerated constants are converted implicitly to the type string
- "before the concatenation in the string template.
- DATA(str_from_enum) = |{ a }{ b }{ c }{ d }|.
- APPEND |str_from_enum: { str_from_enum }| TO output.
-
- "Note that only the enumerated type itself is relevant. Usually, the content
- "of an enumerated object is not of interest.
- "The enumerated value in the base type can be accessed using the constructor
- "operators CONV and EXACT only. The base type is i in this case.
- DATA(conv_value) = CONV i( do_enum ).
- APPEND |conv_value: { conv_value }| TO output.
-
- "Converting the other way round.
- DATA(another_conv) = CONV t_enum( 3 ).
- APPEND |another_conv: { another_conv }| TO output.
-
- "If known statically, an attempt to assign a value other than a valid enumerated value
- "to an enumerated variable produces a syntax error.
- "If not known statically, an exception is raised.
- "The following produces a syntax error
- "do_enum = f.
-
- "The following example shows raising an exception.
- DATA dobj TYPE t_enum.
-
- TYPES t_int_tab TYPE TABLE OF i WITH EMPTY KEY.
- DATA(int_tab) = VALUE t_int_tab( ( 0 ) ( 1 ) ( 2 ) ( 3 ) ( 4 ) ).
-
- DATA str_tab TYPE TABLE OF string.
- LOOP AT int_tab INTO DATA(wa_en).
- TRY.
- dobj = CONV t_enum( wa_en ).
- APPEND dobj TO str_tab.
- CATCH cx_sy_conversion_no_enum_value INTO DATA(error_enum).
- APPEND error_enum->get_text( ) TO str_tab.
- ENDTRY.
- ENDLOOP.
-
- APPEND `------------- START: Output for str_tab -------------` TO output.
- APPEND LINES OF str_tab TO output.
- APPEND `^^^^^^^^^^^^^ END: Output for str_tab ^^^^^^^^^^^^^` TO output.
-
- "An enumerated variable can be set to the initial value of its base type
- "using CLEAR.
- CLEAR do_enum.
- APPEND |do_enum: { do_enum }| TO output.
-
- "Enumerated structures
- DATA do_enum_s TYPE t_enum_struc.
-
- "The enumerated structure en_struc was decalred in the public section.
- "Using the addition LIKE, a second structure is created referring to the enumerated structure.
- "Note that the second structure is not a constant structure.
- "The components of the constant structure contain the enumerated values of the enumerated type.
- "All the components of the variable structure declared by LIKE contain the initial values.
- DATA do_s LIKE en_struc.
- APPEND |do_s: { do_s-j } / { do_s-k } / { do_s-l } / { do_s-m }| TO output.
-
- DATA(do_en) = en_struc.
- APPEND |do_en: { do_en-j } / { do_en-k } / { do_en-l } / { do_en-m }| TO output.
-
- "Accessing structure components using the component selector
- DATA(do_en_k) = en_struc-k.
- APPEND |do_en_k: { do_en_k }| TO output.
-
- DATA(do_s_m) = do_s-m.
- APPEND |do_s_m: { do_s_m }| TO output.
- "Assigning enumerated constants to the variable structure
- do_s = en_struc.
- APPEND |do_s: { do_s-j } / { do_s-k } / { do_s-l } / { do_s-m }| TO output.
-
- ENDMETHOD.
METHOD rtti_enum.
@@ -2022,5 +2023,4 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
REPLACE FIRST OCCURRENCE OF PCRE `/\s` IN mem_string WITH ``.
APPEND ` members:` && mem_string TO output.
ENDMETHOD.
-
-ENDCLASS.
\ No newline at end of file
+ENDCLASS.
diff --git a/src/zcl_demo_abap_dtype_dobj.clas.xml b/src/zcl_demo_abap_dtype_dobj.clas.xml
index 5b80867..cf0dbff 100644
--- a/src/zcl_demo_abap_dtype_dobj.clas.xml
+++ b/src/zcl_demo_abap_dtype_dobj.clas.xml
@@ -9,7 +9,7 @@
1
X
X
- 5
+ X
diff --git a/src/zcl_demo_abap_dynamic_prog.clas.abap b/src/zcl_demo_abap_dynamic_prog.clas.abap
index 267b3ee..4dcdaec 100644
--- a/src/zcl_demo_abap_dynamic_prog.clas.abap
+++ b/src/zcl_demo_abap_dynamic_prog.clas.abap
@@ -31,10 +31,6 @@
* or use the debugger.
*
* ----------------------------- NOTE -----------------------------------
-* Some code sections are commented out. The syntax is only available in
-* newer ABAP releases. Comment them in if you are running a newer
-* ABAP release, for example, in the SAP BTP environment.
-*
* 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
@@ -60,19 +56,19 @@ CLASS zcl_demo_abap_dynamic_prog DEFINITION
CLASS-METHODS:
class_constructor.
-
- PROTECTED SECTION.
- PRIVATE SECTION.
-
ENDCLASS.
+
+
CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
+
METHOD class_constructor.
"Filling demo database tables.
zcl_demo_abap_flight_tables=>fill_dbtabs( ).
ENDMETHOD.
+
METHOD if_oo_adt_classrun~main.
DATA(output) = NEW zcl_demo_abap_display( out ).
@@ -463,12 +459,11 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
DO.
"sy-index represents the position of a structure component
- "NOTE: The following statement is replaced by the newer syntax that is
- "commented out below. Therefore, it is recommended that you use this
- "syntax in newer ABAP releases.
- ASSIGN COMPONENT sy-index OF STRUCTURE TO .
- "ASSIGN -(sy-index) to .
+ ASSIGN -(sy-index) to .
+
+ "Old syntax
+ "ASSIGN COMPONENT sy-index OF STRUCTURE TO .
IF sy-subrc <> 0.
"If all components are processed, the loop is exited.
@@ -959,38 +954,34 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
output->display( input = name = `` ).
**********************************************************************
- "Note: Comment in the following example in newer ABAP releases and in the SAP BTP environment.
-* output->next_section( `21) Dynamic Specifications in ASSIGN Statements (2) - Setting sy-subrc/ELSE UNASSIGN` ).
-*
-* "In dynamic assignments, the statement ASSIGN sets the return code sy-subrc.
-* "If ELSE UNASSIGN is specified, no memory area is assigned to the field symbol. It has the state unassigned after the ASSIGN statement.
-*
-* DATA(attr) = VALUE string_table( ( `another_string` ) ( `public_string` ) ( `this_will_fail` ) ).
-*
-* LOOP AT attr INTO DATA(attribute).
-*
-* ASSIGN cl_ref->(attribute) TO FIELD-SYMBOL() ELSE UNASSIGN.
-* IF sy-subrc = 0.
-* output->display( |Successful assignment for attribute "{ attribute }". sy-subrc = { sy-subrc }. | ).
-* output->display( input = name = `` ).
-* ELSE.
-* output->display( |Assignment not successful for attribute "{ attribute }". sy-subrc = { sy-subrc }. | ).
-* ENDIF.
-*
-* IF IS ASSIGNED.
-* output->display( `The field symbol is assigned.` ).
-* output->display( `--------------------` ).
-* ELSE.
-* output->display( `The field symbol is not assigned.` ).
-* ENDIF.
-*
-* ENDLOOP.
+ output->next_section( `21) Dynamic Specifications in ASSIGN Statements (2) - Setting sy-subrc/ELSE UNASSIGN` ).
+
+ "In dynamic assignments, the statement ASSIGN sets the return code sy-subrc.
+ "If ELSE UNASSIGN is specified, no memory area is assigned to the field symbol. It has the state unassigned after the ASSIGN statement.
+
+ DATA(attr) = VALUE string_table( ( `another_string` ) ( `public_string` ) ( `this_will_fail` ) ).
+
+ LOOP AT attr INTO DATA(attribute).
+
+ ASSIGN cl_ref->(attribute) TO FIELD-SYMBOL() ELSE UNASSIGN.
+ IF sy-subrc = 0.
+ output->display( |Successful assignment for attribute "{ attribute }". sy-subrc = { sy-subrc }. | ).
+ output->display( input = name = `` ).
+ ELSE.
+ output->display( |Assignment not successful for attribute "{ attribute }". sy-subrc = { sy-subrc }. | ).
+ ENDIF.
+
+ IF IS ASSIGNED.
+ output->display( `The field symbol is assigned.` ).
+ output->display( `--------------------` ).
+ ELSE.
+ output->display( `The field symbol is not assigned.` ).
+ ENDIF.
+
+ ENDLOOP.
**********************************************************************
- "Note: The following code contains syntax that is only available in
- "newer ABAP releases and in the SAP BTP environment. In these contexts,
- "you can comment in the code.
output->next_section( `22) Dynamic Specifications in ASSIGN Statements (3) - Structure Components` ).
@@ -1002,29 +993,29 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
DATA(comp_name) = lcl_det_at_runtime=>get_dyn_field( ).
-* ASSIGN wa-(comp_name) TO FIELD-SYMBOL().
-*
-* ASSIGN wa-('CARRNAME') TO FIELD-SYMBOL().
-*
-* IF sy-subrc = 0.
-* DATA(subrc1) = sy-subrc.
-* ENDIF.
-*
-* "No exception occurs in case of an unsuccessful assignment.
-* ASSIGN wa-('CRRNM') TO FIELD-SYMBOL().
-*
-* IF sy-subrc <> 0.
-* DATA(subrc2) = sy-subrc.
-* ENDIF.
-*
-* "Numeric expressions are possible. Its value is interpreted as the position
-* "of the component in the structure.
-* ASSIGN wa-(4) TO FIELD-SYMBOL().
-*
-* "If the value is 0, the memory area of the entire structure is assigned to the field symbol.
-* ASSIGN wa-(0) TO FIELD-SYMBOL().
+ ASSIGN wa-(comp_name) TO FIELD-SYMBOL().
- "The above statements replace the following syntax
+ ASSIGN wa-('CARRNAME') TO FIELD-SYMBOL().
+
+ IF sy-subrc = 0.
+ DATA(subrc1) = sy-subrc.
+ ENDIF.
+
+ "No exception occurs in case of an unsuccessful assignment.
+ ASSIGN wa-('CRRNM') TO FIELD-SYMBOL().
+
+ IF sy-subrc <> 0.
+ DATA(subrc2) = sy-subrc.
+ ENDIF.
+
+ "Numeric expressions are possible. Its value is interpreted as the position
+ "of the component in the structure.
+ ASSIGN wa-(4) TO FIELD-SYMBOL().
+
+ "If the value is 0, the memory area of the entire structure is assigned to the field symbol.
+ ASSIGN wa-(0) TO FIELD-SYMBOL().
+
+ "Old syntax
ASSIGN COMPONENT 'CARRID' OF STRUCTURE wa TO FIELD-SYMBOL().
ASSIGN COMPONENT 5 OF STRUCTURE wa TO FIELD-SYMBOL().
@@ -1034,12 +1025,12 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
ASSIGN ref_m->('CARRNAME') TO FIELD-SYMBOL().
-* output->display( input = name = `` ).
-* output->display( input = name = `` ).
-* output->display( input = subrc1 name = `subrc1` ).
-* output->display( input = subrc2 name = `subrc2` ).
-* output->display( input = name = `` ).
-* output->display( input = name = `` ).
+ output->display( input = name = `` ).
+ output->display( input = name = `` ).
+ output->display( input = subrc1 name = `subrc1` ).
+ output->display( input = subrc2 name = `subrc2` ).
+ output->display( input = name = `` ).
+ output->display( input = name = `` ).
output->display( input = name = `` ).
output->display( input = name = `` ).
output->display( input = name = `` ).
@@ -2111,4 +2102,4 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
output->display( input = ref_tab->* name = `ref_tab->*` ).
ENDMETHOD.
-ENDCLASS.
\ No newline at end of file
+ENDCLASS.
diff --git a/src/zcl_demo_abap_dynamic_prog.clas.locals_imp.abap b/src/zcl_demo_abap_dynamic_prog.clas.locals_imp.abap
index 4339a32..0dc37f4 100644
--- a/src/zcl_demo_abap_dynamic_prog.clas.locals_imp.abap
+++ b/src/zcl_demo_abap_dynamic_prog.clas.locals_imp.abap
@@ -40,7 +40,7 @@ CLASS lcl_det_at_runtime DEFINITION.
get_dyn_class_meth EXPORTING cl TYPE string
meth TYPE string
ptab TYPE abap_parmbind_tab,
- get_dyn_syntax_elements RETURNING VALUE(syntax_elements) TYPE struc_dyn,
+ get_dyn_syntax_elements RETURNING VALUE(syntax_elements) TYPE struc_dyn,
fill_string.
PROTECTED SECTION.
diff --git a/src/zcl_demo_abap_dynamic_prog.clas.xml b/src/zcl_demo_abap_dynamic_prog.clas.xml
index 3d26a6a..397ccf8 100644
--- a/src/zcl_demo_abap_dynamic_prog.clas.xml
+++ b/src/zcl_demo_abap_dynamic_prog.clas.xml
@@ -9,7 +9,7 @@
1
X
X
- 5
+ X
diff --git a/src/zcl_demo_abap_flight_tables.clas.abap b/src/zcl_demo_abap_flight_tables.clas.abap
index b679b35..b656210 100644
--- a/src/zcl_demo_abap_flight_tables.clas.abap
+++ b/src/zcl_demo_abap_flight_tables.clas.abap
@@ -35,7 +35,7 @@ ENDCLASS.
-CLASS zcl_demo_abap_flight_tables IMPLEMENTATION.
+CLASS ZCL_DEMO_ABAP_FLIGHT_TABLES IMPLEMENTATION.
METHOD clear_dbtabs.
diff --git a/src/zcl_demo_abap_flight_tables.clas.xml b/src/zcl_demo_abap_flight_tables.clas.xml
index 3f100b8..84a3247 100644
--- a/src/zcl_demo_abap_flight_tables.clas.xml
+++ b/src/zcl_demo_abap_flight_tables.clas.xml
@@ -9,7 +9,7 @@
1
X
X
- 5
+ X
diff --git a/src/zcl_demo_abap_internal_tables.clas.abap b/src/zcl_demo_abap_internal_tables.clas.abap
index ffbf294..babc887 100644
--- a/src/zcl_demo_abap_internal_tables.clas.abap
+++ b/src/zcl_demo_abap_internal_tables.clas.abap
@@ -12,26 +12,26 @@
* - Open the class with the ABAP development tools for Eclipse (ADT).
* - Choose F9 to run the class.
* - Check the console output.
-* - To understand the context and the ABAP syntax used, refer to the
-* notes included in the class as comments or refer to the respective
+* - To understand the context and the ABAP syntax used, refer to the
+* notes included in the class as comments or refer to the respective
* topic in the ABAP Keyword Documentation.
-* - Due to the amount of console output, the examples contain numbers
-* (e.g. 1) ..., 2) ..., 3) ...) for the individual example sections.
-* Also, the variable name is displayed in most cases. So to find
-* the relevant output in the console easier and faster, just search
-* for the number/variable name in the console (CTRL+F in the console)
+* - Due to the amount of console output, the examples contain numbers
+* (e.g. 1) ..., 2) ..., 3) ...) for the individual example sections.
+* Also, the variable name is displayed in most cases. So to find
+* the relevant output in the console easier and faster, just search
+* for the number/variable name in the console (CTRL+F in the console)
* or use the debugger.
*
* ----------------------------- NOTE -----------------------------------
* 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
-* intended to provide a better explanation and visualization of the
-* syntax and semantics of ABAP statements, not to solve concrete
-* programming tasks. For production application programs, you should
-* always work out your own solution for each individual case. There is
-* no guarantee for the correctness or completeness of the code.
-* Furthermore, there is no legal responsibility or liability for any
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
@@ -110,12 +110,16 @@ 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
@@ -137,6 +141,7 @@ 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' ) ).
@@ -177,6 +182,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
ENDMETHOD.
+
METHOD if_oo_adt_classrun~main.
DATA(output) = NEW zcl_demo_abap_display( out ).
@@ -227,7 +233,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
output->display( input = it_so name = `it_so` ).
**********************************************************************
-
+
output->next_section( `3) Adding mutliple lines of an internal table to` &&
` another one` ).
@@ -263,7 +269,7 @@ 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` ).
@@ -425,6 +431,10 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
output->display( input = tab1 name = `tab1` ).
+**********************************************************************
+
+ output->next_section( `11g) ... excluding components and using MAPPING` ).
+
"EXCEPT * means that all components remain initial not specified
"for mapping
tab1 = CORRESPONDING #( tab2 MAPPING d = f EXCEPT * ).
@@ -1691,7 +1701,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
"the internal table.
DATA(it_str) = VALUE string_table( ( `a` ) ( `b` ) ( `c` ) ).
- it_str = VALUE #( ).
+ it_str = VALUE #( ).
output->display( input = it_st name = `it_st` ).
output->display( input = it_st2 name = `it_st2` ).
diff --git a/src/zcl_demo_abap_internal_tables.clas.xml b/src/zcl_demo_abap_internal_tables.clas.xml
index 97a9e95..5448460 100644
--- a/src/zcl_demo_abap_internal_tables.clas.xml
+++ b/src/zcl_demo_abap_internal_tables.clas.xml
@@ -9,7 +9,7 @@
1
X
X
- 5
+ X
diff --git a/src/zcl_demo_abap_objects.clas.abap b/src/zcl_demo_abap_objects.clas.abap
index 5ed1478..4a5f636 100644
--- a/src/zcl_demo_abap_objects.clas.abap
+++ b/src/zcl_demo_abap_objects.clas.abap
@@ -20,26 +20,26 @@
* - Open the class with the ABAP development tools for Eclipse (ADT).
* - Choose F9 to run the class.
* - Check the console output.
-* - To understand the context and the ABAP syntax used, refer to the
-* notes included in the class as comments or refer to the respective
+* - To understand the context and the ABAP syntax used, refer to the
+* notes included in the class as comments or refer to the respective
* topic in the ABAP Keyword Documentation.
-* - Due to the amount of console output, the examples contain numbers
-* (e.g. 1) ..., 2) ..., 3) ...) for the individual example sections.
-* Also, the variable name is displayed in most cases. So to find
-* the relevant output in the console easier and faster, just search
-* for the number/variable name in the console (CTRL+F in the console)
+* - Due to the amount of console output, the examples contain numbers
+* (e.g. 1) ..., 2) ..., 3) ...) for the individual example sections.
+* Also, the variable name is displayed in most cases. So to find
+* the relevant output in the console easier and faster, just search
+* for the number/variable name in the console (CTRL+F in the console)
* or use the debugger.
*
* ----------------------------- NOTE -----------------------------------
* 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
-* intended to provide a better explanation and visualization of the
-* syntax and semantics of ABAP statements, not to solve concrete
-* programming tasks. For production application programs, you should
-* always work out your own solution for each individual case. There is
-* no guarantee for the correctness or completeness of the code.
-* Furthermore, there is no legal responsibility or liability for any
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
@@ -81,18 +81,21 @@ ENDCLASS.
-CLASS zcl_demo_abap_objects IMPLEMENTATION.
+CLASS ZCL_DEMO_ABAP_OBJECTS IMPLEMENTATION.
+
METHOD hallo_instance_method.
string = |Hallo { sy-uname }. | &&
|I'm an instance method of class zcl_demo_abap_objects.|.
ENDMETHOD.
+
METHOD hallo_static_method.
string = |Hallo { sy-uname }. | &&
|I'm a static method of class zcl_demo_abap_objects.|.
ENDMETHOD.
+
METHOD if_oo_adt_classrun~main.
DATA(output) = NEW zcl_demo_abap_display( out ).
@@ -126,7 +129,7 @@ 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` ).
@@ -157,7 +160,7 @@ 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` ).
@@ -177,7 +180,7 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
ELSE.
output->display( `ref3b has not been assigned to ref3a.` ).
ENDIF.
-
+
**********************************************************************
output->next_section( `4) Overwriting object references` ).
@@ -197,7 +200,7 @@ 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` ).
@@ -219,7 +222,7 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
ENDDO.
output->display( input = itab5 name = `itab5` ).
-
+
**********************************************************************
output->next_section( `6) Clearing object references` ).
@@ -241,7 +244,7 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
ELSE.
output->display( `ref6 is not initial.` ).
ENDIF.
-
+
**********************************************************************
output->next_section( `7) Accessing and using attributes` ).
@@ -271,7 +274,7 @@ 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` ).
@@ -307,7 +310,7 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
hallo_static_method( ).
output->display( input = string name = `string` ).
-
+
**********************************************************************
output->next_section( `9) Calling methods: Examples` &&
@@ -353,7 +356,7 @@ 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 ` &&
@@ -381,7 +384,7 @@ 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` ).
@@ -395,7 +398,7 @@ 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` ).
@@ -459,7 +462,7 @@ 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` ).
@@ -501,7 +504,7 @@ CLASS zcl_demo_abap_objects IMPLEMENTATION.
ENDTRY.
output->display( input = greets name = `greets` ).
-
+
**********************************************************************
output->next_section( `14) Constructors` ).
@@ -553,7 +556,7 @@ 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` ).
@@ -593,7 +596,7 @@ 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` ).
@@ -624,7 +627,7 @@ 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` ).
@@ -875,7 +878,7 @@ 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` ).
@@ -923,7 +926,7 @@ 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` ).
@@ -958,7 +961,7 @@ 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` ).
@@ -977,7 +980,7 @@ 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` ).
@@ -997,7 +1000,7 @@ 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` ).
diff --git a/src/zcl_demo_abap_objects.clas.xml b/src/zcl_demo_abap_objects.clas.xml
index 6ba11a9..e770ca1 100644
--- a/src/zcl_demo_abap_objects.clas.xml
+++ b/src/zcl_demo_abap_objects.clas.xml
@@ -9,7 +9,7 @@
1
X
X
- 5
+ X
diff --git a/src/zcl_demo_abap_objects_friend.clas.abap b/src/zcl_demo_abap_objects_friend.clas.abap
index 562cc8d..ca0d49b 100644
--- a/src/zcl_demo_abap_objects_friend.clas.abap
+++ b/src/zcl_demo_abap_objects_friend.clas.abap
@@ -5,13 +5,13 @@
* ----------------------------- NOTE -----------------------------------
* 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
-* intended to provide a better explanation and visualization of the
-* syntax and semantics of ABAP statements, not to solve concrete
-* programming tasks. For production application programs, you should
-* always work out your own solution for each individual case. There is
-* no guarantee for the correctness or completeness of the code.
-* Furthermore, there is no legal responsibility or liability for any
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
@@ -23,11 +23,15 @@
PUBLIC SECTION.
CLASS-METHODS get_strings RETURNING VALUE(res_string) TYPE string_table.
+protected section.
+private section.
ENDCLASS.
+
CLASS ZCL_DEMO_ABAP_OBJECTS_FRIEND IMPLEMENTATION.
+
METHOD get_strings.
"Getting the strings and adding them to the string table.
"Accessing an attribute in a public visibility section.
@@ -39,5 +43,4 @@ CLASS ZCL_DEMO_ABAP_OBJECTS_FRIEND IMPLEMENTATION.
"Accessing an attribute in a private visibility section.
APPEND zcl_demo_abap_objects=>private_string TO res_string.
ENDMETHOD.
-
ENDCLASS.
diff --git a/src/zcl_demo_abap_objects_friend.clas.xml b/src/zcl_demo_abap_objects_friend.clas.xml
index 3cb0296..f0de8f5 100644
--- a/src/zcl_demo_abap_objects_friend.clas.xml
+++ b/src/zcl_demo_abap_objects_friend.clas.xml
@@ -9,7 +9,7 @@
1
X
X
- 5
+ X
diff --git a/src/zcl_demo_abap_prog_flow_logic.clas.abap b/src/zcl_demo_abap_prog_flow_logic.clas.abap
index 736a89e..29be1a7 100644
--- a/src/zcl_demo_abap_prog_flow_logic.clas.abap
+++ b/src/zcl_demo_abap_prog_flow_logic.clas.abap
@@ -16,26 +16,26 @@
* - Open the class with the ABAP development tools for Eclipse (ADT).
* - Choose F9 to run the class.
* - Check the console output.
-* - To understand the context and the ABAP syntax used, refer to the
-* notes included in the class as comments or refer to the respective
+* - To understand the context and the ABAP syntax used, refer to the
+* notes included in the class as comments or refer to the respective
* topic in the ABAP Keyword Documentation.
-* - Due to the amount of console output, the examples contain numbers
-* (e.g. 1) ..., 2) ..., 3) ...) for the individual example sections.
-* Also, the variable name is displayed in most cases. So to find
-* the relevant output in the console easier and faster, just search
-* for the number/variable name in the console (CTRL+F in the console)
+* - Due to the amount of console output, the examples contain numbers
+* (e.g. 1) ..., 2) ..., 3) ...) for the individual example sections.
+* Also, the variable name is displayed in most cases. So to find
+* the relevant output in the console easier and faster, just search
+* for the number/variable name in the console (CTRL+F in the console)
* or use the debugger.
*
* ----------------------------- NOTE -----------------------------------
* 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
-* intended to provide a better explanation and visualization of the
-* syntax and semantics of ABAP statements, not to solve concrete
-* programming tasks. For production application programs, you should
-* always work out your own solution for each individual case. There is
-* no guarantee for the correctness or completeness of the code.
-* Furthermore, there is no legal responsibility or liability for any
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
@@ -50,6 +50,7 @@ CLASS zcl_demo_abap_prog_flow_logic DEFINITION
PUBLIC SECTION.
INTERFACES: if_oo_adt_classrun.
+protected section.
PRIVATE SECTION.
"Structured type for calculation example
@@ -98,7 +99,118 @@ CLASS zcl_demo_abap_prog_flow_logic DEFINITION
ENDCLASS.
-CLASS zcl_demo_abap_prog_flow_logic IMPLEMENTATION.
+
+
+CLASS ZCL_DEMO_ABAP_PROG_FLOW_LOGIC IMPLEMENTATION.
+
+
+ METHOD addition.
+ res = num1 + num2.
+ ENDMETHOD.
+
+
+ METHOD calc.
+
+ DATA calc_if TYPE string.
+ DATA calc_case TYPE string.
+ DATA calc_cond TYPE string.
+ DATA calc_switch TYPE string.
+
+ "IF statements
+
+ IF operator = `+`.
+ calc_if = num1 + num2.
+ ELSEIF operator = `-`.
+ calc_if = num1 - num2.
+ ELSEIF operator = `*`.
+ calc_if = num1 * num2.
+ ELSEIF operator = `/`.
+
+ IF num2 = 0.
+ calc_if = `Division by 0`.
+ ELSE.
+ calc_if = num1 / num2.
+ ENDIF.
+ ELSE.
+ calc_if = |Check the operator { operator }.|.
+ ENDIF.
+
+ prep_calc_result( CHANGING res = calc_if ).
+
+ "CASE
+
+ CASE operator.
+ WHEN '+'.
+ calc_case = num1 + num2.
+ WHEN '-'.
+ calc_case = num1 - num2.
+ WHEN '*'.
+ calc_case = num1 * num2.
+ WHEN '/'.
+
+ CASE num2.
+ WHEN 0.
+ calc_case = `Division by 0`.
+ WHEN OTHERS.
+ calc_case = num1 / num2.
+ ENDCASE.
+
+ WHEN OTHERS.
+ calc_case = |Check the operator { operator }.|.
+ ENDCASE.
+
+ prep_calc_result( CHANGING res = calc_case ).
+
+ "COND
+
+ calc_cond = COND #( WHEN operator = '+'
+ THEN num1 + num2
+ WHEN operator = '-'
+ THEN num1 - num2
+ WHEN operator = '*'
+ THEN num1 * num2
+ WHEN operator = '/' AND num2 = 0 THEN `Division by 0`
+ WHEN operator = '/' AND num2 <> 0 THEN num1 / num2
+ ELSE |Check the operator { operator }.|
+ ).
+
+ prep_calc_result( CHANGING res = calc_cond ).
+
+ "SWITCH
+
+ calc_switch = SWITCH #( operator
+ WHEN '+' THEN num1 + num2
+ WHEN '-' THEN num1 - num2
+ WHEN '*' THEN num1 * num2
+ WHEN '/' THEN SWITCH #( num2 WHEN 0 THEN `Division by 0` ELSE num1 / num2 )
+ ELSE |Check the operator { operator }.| ).
+
+ prep_calc_result( CHANGING res = calc_switch ).
+
+ res = VALUE #( calculation = |{ num1 } { operator } { num2 }|
+ res_if = calc_if
+ res_case = calc_case
+ res_cond = calc_cond
+ res_switch = calc_switch
+ ).
+
+ ENDMETHOD.
+
+
+ METHOD check_is_supplied.
+ IF num1 IS SUPPLIED.
+ APPEND `num1 is supplied` TO res.
+ ELSE.
+ APPEND `num1 is not supplied` TO res.
+ ENDIF.
+
+ IF num2 IS NOT SUPPLIED.
+ APPEND `num2 is not supplied` TO res.
+ ELSE.
+ APPEND `num2 is supplied` TO res.
+ ENDIF.
+ ENDMETHOD.
+
METHOD if_oo_adt_classrun~main.
@@ -113,7 +225,7 @@ CLASS zcl_demo_abap_prog_flow_logic IMPLEMENTATION.
"Simple control structure realized by an IF ... ELSEIF ... ELSE ... ENDIF.
"statement. Multiple statement blocks can be included, of which only 1 is
"executed at most and depending on conditions.
-
+
"Determining some operators for a calculation
DATA(operators) = VALUE string_table( ( `+` ) ( `-` ) ( `?` ) ).
@@ -1223,111 +1335,6 @@ CLASS zcl_demo_abap_prog_flow_logic IMPLEMENTATION.
ENDMETHOD.
- METHOD check_is_supplied.
- IF num1 IS SUPPLIED.
- APPEND `num1 is supplied` TO res.
- ELSE.
- APPEND `num1 is not supplied` TO res.
- ENDIF.
-
- IF num2 IS NOT SUPPLIED.
- APPEND `num2 is not supplied` TO res.
- ELSE.
- APPEND `num2 is supplied` TO res.
- ENDIF.
- ENDMETHOD.
-
- METHOD addition.
- res = num1 + num2.
- ENDMETHOD.
-
- METHOD calc.
-
- DATA calc_if TYPE string.
- DATA calc_case TYPE string.
- DATA calc_cond TYPE string.
- DATA calc_switch TYPE string.
-
- "IF statements
-
- IF operator = `+`.
- calc_if = num1 + num2.
- ELSEIF operator = `-`.
- calc_if = num1 - num2.
- ELSEIF operator = `*`.
- calc_if = num1 * num2.
- ELSEIF operator = `/`.
-
- IF num2 = 0.
- calc_if = `Division by 0`.
- ELSE.
- calc_if = num1 / num2.
- ENDIF.
- ELSE.
- calc_if = |Check the operator { operator }.|.
- ENDIF.
-
- prep_calc_result( CHANGING res = calc_if ).
-
- "CASE
-
- CASE operator.
- WHEN '+'.
- calc_case = num1 + num2.
- WHEN '-'.
- calc_case = num1 - num2.
- WHEN '*'.
- calc_case = num1 * num2.
- WHEN '/'.
-
- CASE num2.
- WHEN 0.
- calc_case = `Division by 0`.
- WHEN OTHERS.
- calc_case = num1 / num2.
- ENDCASE.
-
- WHEN OTHERS.
- calc_case = |Check the operator { operator }.|.
- ENDCASE.
-
- prep_calc_result( CHANGING res = calc_case ).
-
- "COND
-
- calc_cond = COND #( WHEN operator = '+'
- THEN num1 + num2
- WHEN operator = '-'
- THEN num1 - num2
- WHEN operator = '*'
- THEN num1 * num2
- WHEN operator = '/' AND num2 = 0 THEN `Division by 0`
- WHEN operator = '/' AND num2 <> 0 THEN num1 / num2
- ELSE |Check the operator { operator }.|
- ).
-
- prep_calc_result( CHANGING res = calc_cond ).
-
- "SWITCH
-
- calc_switch = SWITCH #( operator
- WHEN '+' THEN num1 + num2
- WHEN '-' THEN num1 - num2
- WHEN '*' THEN num1 * num2
- WHEN '/' THEN SWITCH #( num2 WHEN 0 THEN `Division by 0` ELSE num1 / num2 )
- ELSE |Check the operator { operator }.| ).
-
- prep_calc_result( CHANGING res = calc_switch ).
-
- res = VALUE #( calculation = |{ num1 } { operator } { num2 }|
- res_if = calc_if
- res_case = calc_case
- res_cond = calc_cond
- res_switch = calc_switch
- ).
-
- ENDMETHOD.
-
METHOD meth_with_return.
@@ -1341,6 +1348,36 @@ CLASS zcl_demo_abap_prog_flow_logic IMPLEMENTATION.
ENDMETHOD.
+
+ METHOD power2_and_sqrt.
+
+ result = |Calculation result:\n{ num } powered by 2 = { ipow( base = num exp = 2 ) }\nSquare root of { num } = { sqrt( num ) }|.
+
+ ENDMETHOD.
+
+
+ METHOD prep_calc_result.
+
+ FIND PCRE `-$` IN res. "trailing minus
+
+ IF sy-subrc = 0.
+ SHIFT res BY 1 PLACES RIGHT CIRCULAR.
+ ENDIF.
+
+ "trailing .0
+ IF res CP `*.0*`.
+ SHIFT res RIGHT DELETING TRAILING ` `.
+ SHIFT res LEFT DELETING LEADING ` `.
+ FIND PCRE `\.0$` IN res.
+
+ IF sy-subrc = 0.
+ REPLACE `.0` IN res WITH ``.
+ ENDIF.
+ ENDIF.
+
+ ENDMETHOD.
+
+
METHOD validate_email.
IF matches( val = email
@@ -1363,32 +1400,4 @@ CLASS zcl_demo_abap_prog_flow_logic IMPLEMENTATION.
ENDIF.
ENDMETHOD.
-
- METHOD power2_and_sqrt.
-
- result = |Calculation result:\n{ num } powered by 2 = { ipow( base = num exp = 2 ) }\nSquare root of { num } = { sqrt( num ) }|.
-
- ENDMETHOD.
-
- METHOD prep_calc_result.
-
- FIND PCRE `-$` IN res. "trailing minus
-
- IF sy-subrc = 0.
- SHIFT res BY 1 PLACES RIGHT CIRCULAR.
- ENDIF.
-
- "trailing .0
- IF res CP `*.0*`.
- SHIFT res RIGHT DELETING TRAILING ` `.
- SHIFT res LEFT DELETING LEADING ` `.
- FIND PCRE `\.0$` IN res.
-
- IF sy-subrc = 0.
- REPLACE `.0` IN res WITH ``.
- ENDIF.
- ENDIF.
-
- ENDMETHOD.
-
ENDCLASS.
diff --git a/src/zcl_demo_abap_prog_flow_logic.clas.xml b/src/zcl_demo_abap_prog_flow_logic.clas.xml
index a78892a..ba289e0 100644
--- a/src/zcl_demo_abap_prog_flow_logic.clas.xml
+++ b/src/zcl_demo_abap_prog_flow_logic.clas.xml
@@ -9,7 +9,7 @@
1
X
X
- 5
+ X
diff --git a/src/zcl_demo_abap_rap_draft_ln_m.clas.abap b/src/zcl_demo_abap_rap_draft_ln_m.clas.abap
index 0666bec..f9f13d5 100644
--- a/src/zcl_demo_abap_rap_draft_ln_m.clas.abap
+++ b/src/zcl_demo_abap_rap_draft_ln_m.clas.abap
@@ -85,13 +85,13 @@
*
* 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
-* intended to provide a better explanation and visualization of the
-* syntax and semantics of ABAP statements, not to solve concrete
-* programming tasks. For production application programs, you should
-* always work out your own solution for each individual case. There is
-* no guarantee for the correctness or completeness of the code.
-* Furthermore, there is no legal responsibility or liability for any
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
diff --git a/src/zcl_demo_abap_rap_draft_ln_m.clas.xml b/src/zcl_demo_abap_rap_draft_ln_m.clas.xml
index d5e920b..9cacfbe 100644
--- a/src/zcl_demo_abap_rap_draft_ln_m.clas.xml
+++ b/src/zcl_demo_abap_rap_draft_ln_m.clas.xml
@@ -9,7 +9,7 @@
1
X
X
- 5
+ X
diff --git a/src/zcl_demo_abap_rap_ext_num_m.clas.abap b/src/zcl_demo_abap_rap_ext_num_m.clas.abap
index 829b28d..70b7835 100644
--- a/src/zcl_demo_abap_rap_ext_num_m.clas.abap
+++ b/src/zcl_demo_abap_rap_ext_num_m.clas.abap
@@ -45,13 +45,13 @@
*
* 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
-* intended to provide a better explanation and visualization of the
-* syntax and semantics of ABAP statements, not to solve concrete
-* programming tasks. For production application programs, you should
-* always work out your own solution for each individual case. There is
-* no guarantee for the correctness or completeness of the code.
-* Furthermore, there is no legal responsibility or liability for any
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
@@ -903,65 +903,65 @@ CLASS ZCL_DEMO_ABAP_RAP_EXT_NUM_M IMPLEMENTATION.
*
**********************************************************************
-* output->next_section( `11) Excursion: Read and read-by-association ` &&
-* `operations using dynamic EML` ).
-* DATA:
-* op_tab TYPE abp_behv_retrievals_tab,
-* read_dyn TYPE TABLE FOR READ IMPORT zdemo_abap_rap_ro_m,
-* read_dyn_result TYPE TABLE FOR READ RESULT zdemo_abap_rap_ro_m,
-* rba_dyn TYPE TABLE FOR READ IMPORT
-* zdemo_abap_rap_ro_m\_child,
-* rba_dyn_result TYPE TABLE FOR READ RESULT
-* zdemo_abap_rap_ro_m\_child,
-* rba_dyn_link TYPE TABLE FOR READ LINK zdemo_abap_rap_ro_m\_child.
-*
-* read_dyn = VALUE #(
-* ( %key-key_field = 1
-* %control = VALUE #(
-* field1 = if_abap_behv=>mk-on
-* field2 = if_abap_behv=>mk-on
-* field3 = if_abap_behv=>mk-on
-* field4 = if_abap_behv=>mk-on ) )
-* ( %key-key_field = 2
-* %control = VALUE #(
-* field1 = if_abap_behv=>mk-on
-* field2 = if_abap_behv=>mk-on
-* field3 = if_abap_behv=>mk-on
-* field4 = if_abap_behv=>mk-on ) ) ).
-*
-* rba_dyn = VALUE #(
-* ( %key-key_field = 1
-* %control = VALUE #(
-* key_ch = if_abap_behv=>mk-on
-* field_ch1 = if_abap_behv=>mk-on
-* field_ch2 = if_abap_behv=>mk-on ) )
-* ( %key-key_field = 2
-* %control = VALUE #(
-* key_ch = if_abap_behv=>mk-on
-* field_ch1 = if_abap_behv=>mk-on
-* field_ch2 = if_abap_behv=>mk-on ) ) ).
-*
-* op_tab = VALUE #(
-* ( op = if_abap_behv=>op-r-read
-* entity_name = 'ZDEMO_ABAP_RAP_RO_M'
-* instances = REF #( read_dyn )
-* results = REF #( read_dyn_result ) )
-* ( op = if_abap_behv=>op-r-read_ba
-* entity_name = 'ZDEMO_ABAP_RAP_RO_M'
-* sub_name = '_CHILD'
-* full = abap_true
-* instances = REF #( rba_dyn )
-* results = REF #( rba_dyn_result )
-* links = REF #( rba_dyn_link ) ) ).
-*
-* READ ENTITIES OPERATIONS op_tab.
-*
-* output->display( `Read result (root)` ).
-* output->display( input = read_dyn_result name = `read_dyn_result` ).
-* output->display( `Read result (read-by-association)` ).
-* output->display( input = rba_dyn_result name = `rba_dyn_result` ).
-* output->display( `Links` ).
-* output->display( input = rba_dyn_link name = `rba_dyn_link` ).
+ output->next_section( `11) Excursion: Read and read-by-association ` &&
+ `operations using dynamic EML` ).
+ DATA:
+ op_tab TYPE abp_behv_retrievals_tab,
+ read_dyn TYPE TABLE FOR READ IMPORT zdemo_abap_rap_ro_m,
+ read_dyn_result TYPE TABLE FOR READ RESULT zdemo_abap_rap_ro_m,
+ rba_dyn TYPE TABLE FOR READ IMPORT
+ zdemo_abap_rap_ro_m\_child,
+ rba_dyn_result TYPE TABLE FOR READ RESULT
+ zdemo_abap_rap_ro_m\_child,
+ rba_dyn_link TYPE TABLE FOR READ LINK zdemo_abap_rap_ro_m\_child.
+
+ read_dyn = VALUE #(
+ ( %key-key_field = 1
+ %control = VALUE #(
+ field1 = if_abap_behv=>mk-on
+ field2 = if_abap_behv=>mk-on
+ field3 = if_abap_behv=>mk-on
+ field4 = if_abap_behv=>mk-on ) )
+ ( %key-key_field = 2
+ %control = VALUE #(
+ field1 = if_abap_behv=>mk-on
+ field2 = if_abap_behv=>mk-on
+ field3 = if_abap_behv=>mk-on
+ field4 = if_abap_behv=>mk-on ) ) ).
+
+ rba_dyn = VALUE #(
+ ( %key-key_field = 1
+ %control = VALUE #(
+ key_ch = if_abap_behv=>mk-on
+ field_ch1 = if_abap_behv=>mk-on
+ field_ch2 = if_abap_behv=>mk-on ) )
+ ( %key-key_field = 2
+ %control = VALUE #(
+ key_ch = if_abap_behv=>mk-on
+ field_ch1 = if_abap_behv=>mk-on
+ field_ch2 = if_abap_behv=>mk-on ) ) ).
+
+ op_tab = VALUE #(
+ ( op = if_abap_behv=>op-r-read
+ entity_name = 'ZDEMO_ABAP_RAP_RO_M'
+ instances = REF #( read_dyn )
+ results = REF #( read_dyn_result ) )
+ ( op = if_abap_behv=>op-r-read_ba
+ entity_name = 'ZDEMO_ABAP_RAP_RO_M'
+ sub_name = '_CHILD'
+ full = abap_true
+ instances = REF #( rba_dyn )
+ results = REF #( rba_dyn_result )
+ links = REF #( rba_dyn_link ) ) ).
+
+ READ ENTITIES OPERATIONS op_tab.
+
+ output->display( `Read result (root)` ).
+ output->display( input = read_dyn_result name = `read_dyn_result` ).
+ output->display( `Read result (read-by-association)` ).
+ output->display( input = rba_dyn_result name = `rba_dyn_result` ).
+ output->display( `Links` ).
+ output->display( input = rba_dyn_link name = `rba_dyn_link` ).
ENDMETHOD.
diff --git a/src/zcl_demo_abap_rap_ext_num_m.clas.xml b/src/zcl_demo_abap_rap_ext_num_m.clas.xml
index ae4818b..a85fa73 100644
--- a/src/zcl_demo_abap_rap_ext_num_m.clas.xml
+++ b/src/zcl_demo_abap_rap_ext_num_m.clas.xml
@@ -9,7 +9,7 @@
1
X
X
- 5
+ X
diff --git a/src/zcl_demo_abap_rap_ext_num_u.clas.abap b/src/zcl_demo_abap_rap_ext_num_u.clas.abap
index b7a7cea..c277626 100644
--- a/src/zcl_demo_abap_rap_ext_num_u.clas.abap
+++ b/src/zcl_demo_abap_rap_ext_num_u.clas.abap
@@ -49,13 +49,13 @@
*
* 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
-* intended to provide a better explanation and visualization of the
-* syntax and semantics of ABAP statements, not to solve concrete
-* programming tasks. For production application programs, you should
-* always work out your own solution for each individual case. There is
-* no guarantee for the correctness or completeness of the code.
-* Furthermore, there is no legal responsibility or liability for any
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
@@ -90,12 +90,16 @@ protected section.
ENDCLASS.
-CLASS zcl_demo_abap_rap_ext_num_u IMPLEMENTATION.
+
+
+CLASS ZCL_DEMO_ABAP_RAP_EXT_NUM_U IMPLEMENTATION.
+
METHOD class_constructor.
initialize_dbtabs( ).
ENDMETHOD.
+
METHOD extract_from_failed.
CLEAR errors.
@@ -983,95 +987,93 @@ CLASS zcl_demo_abap_rap_ext_num_u IMPLEMENTATION.
* Excursion: Read and read-by-association operation using dynamic
* EML statements
*
-* Notes:
-* - If the parameter for FULL is not flagged, only the association
-* links are returned. The parameter for RESULT will be empty.
-* - Remove the commented out section if you are at least on ABAP
-* version 756 in your on-premise system.
+* Note:
+* If the parameter for FULL is not flagged, only the association
+* links are returned. The parameter for RESULT will be empty.
**********************************************************************
-* output->next_section( `12) Excursion: Read and read-by-association ` &&
-* `operations using dynamic EML` ).
-*
-* DATA:
-* op_tab TYPE abp_behv_retrievals_tab,
-* read_dyn TYPE TABLE FOR READ IMPORT zdemo_abap_rap_ro_u,
-* read_dyn_result TYPE TABLE FOR READ RESULT zdemo_abap_rap_ro_u,
-* rba_dyn TYPE TABLE FOR READ IMPORT
-* zdemo_abap_rap_ro_u\_child,
-* rba_dyn_result TYPE TABLE FOR READ RESULT
-* zdemo_abap_rap_ro_u\_child,
-* rba_dyn_link TYPE TABLE FOR READ LINK zdemo_abap_rap_ro_u\_child.
-*
-* read_dyn = VALUE #(
-* ( %key-key_field = 1
-* %control = VALUE #(
-* field1 = if_abap_behv=>mk-on
-* field2 = if_abap_behv=>mk-on
-* field3 = if_abap_behv=>mk-on
-* field4 = if_abap_behv=>mk-on ) )
-* ( %key-key_field = 2
-* %control = VALUE #(
-* field1 = if_abap_behv=>mk-on
-* field2 = if_abap_behv=>mk-on
-* field3 = if_abap_behv=>mk-on
-* field4 = if_abap_behv=>mk-on ) ) ).
-*
-* rba_dyn = VALUE #(
-* ( %key-key_field = 1
-* %control = VALUE #(
-* key_ch = if_abap_behv=>mk-on
-* field_ch1 = if_abap_behv=>mk-on
-* field_ch2 = if_abap_behv=>mk-on ) )
-* ( %key-key_field = 2
-* %control = VALUE #(
-* key_ch = if_abap_behv=>mk-on
-* field_ch1 = if_abap_behv=>mk-on
-* field_ch2 = if_abap_behv=>mk-on ) ) ).
-*
-* output->display( `Result if FULL parameter is ` &&
-* `not flagged for RBA` ).
-*
-* op_tab = VALUE #(
-* ( op = if_abap_behv=>op-r-read
-* entity_name = 'ZDEMO_ABAP_RAP_RO_U'
-* instances = REF #( read_dyn )
-* results = REF #( read_dyn_result ) )
-* ( op = if_abap_behv=>op-r-read_ba
-* entity_name = 'ZDEMO_ABAP_RAP_RO_U'
-* sub_name = '_CHILD'
-* full = abap_false
-* instances = REF #( rba_dyn )
-* results = REF #( rba_dyn_result )
-* links = REF #( rba_dyn_link ) ) ).
-*
-* READ ENTITIES OPERATIONS op_tab.
-*
-* output->display( input = read_dyn_result name = `read_dyn_result` ).
-* output->display( input = rba_dyn_result name = `rba_dyn_result` ).
-* output->display( input = rba_dyn_link name = `rba_dyn_link` ).
-*
-* output->display( `Result if FULL parameter is ` &&
-* `flagged for RBA` ).
-*
-* op_tab = VALUE #(
-* ( op = if_abap_behv=>op-r-read
-* entity_name = 'ZDEMO_ABAP_RAP_RO_U'
-* instances = REF #( read_dyn )
-* results = REF #( read_dyn_result ) )
-* ( op = if_abap_behv=>op-r-read_ba
-* entity_name = 'ZDEMO_ABAP_RAP_RO_U'
-* sub_name = '_CHILD'
-* full = abap_true
-* instances = REF #( rba_dyn )
-* results = REF #( rba_dyn_result )
-* links = REF #( rba_dyn_link ) ) ).
-*
-* READ ENTITIES OPERATIONS op_tab.
-*
-* output->display( input = read_dyn_result name = `read_dyn_result` ).
-* output->display( input = rba_dyn_result name = `rba_dyn_result` ).
-* output->display( input = rba_dyn_link name = `rba_dyn_link` ).
+ output->next_section( `12) Excursion: Read and read-by-association ` &&
+ `operations using dynamic EML` ).
+
+ DATA:
+ op_tab TYPE abp_behv_retrievals_tab,
+ read_dyn TYPE TABLE FOR READ IMPORT zdemo_abap_rap_ro_u,
+ read_dyn_result TYPE TABLE FOR READ RESULT zdemo_abap_rap_ro_u,
+ rba_dyn TYPE TABLE FOR READ IMPORT
+ zdemo_abap_rap_ro_u\_child,
+ rba_dyn_result TYPE TABLE FOR READ RESULT
+ zdemo_abap_rap_ro_u\_child,
+ rba_dyn_link TYPE TABLE FOR READ LINK zdemo_abap_rap_ro_u\_child.
+
+ read_dyn = VALUE #(
+ ( %key-key_field = 1
+ %control = VALUE #(
+ field1 = if_abap_behv=>mk-on
+ field2 = if_abap_behv=>mk-on
+ field3 = if_abap_behv=>mk-on
+ field4 = if_abap_behv=>mk-on ) )
+ ( %key-key_field = 2
+ %control = VALUE #(
+ field1 = if_abap_behv=>mk-on
+ field2 = if_abap_behv=>mk-on
+ field3 = if_abap_behv=>mk-on
+ field4 = if_abap_behv=>mk-on ) ) ).
+
+ rba_dyn = VALUE #(
+ ( %key-key_field = 1
+ %control = VALUE #(
+ key_ch = if_abap_behv=>mk-on
+ field_ch1 = if_abap_behv=>mk-on
+ field_ch2 = if_abap_behv=>mk-on ) )
+ ( %key-key_field = 2
+ %control = VALUE #(
+ key_ch = if_abap_behv=>mk-on
+ field_ch1 = if_abap_behv=>mk-on
+ field_ch2 = if_abap_behv=>mk-on ) ) ).
+
+ output->display( `Result if FULL parameter is ` &&
+ `not flagged for RBA` ).
+
+ op_tab = VALUE #(
+ ( op = if_abap_behv=>op-r-read
+ entity_name = 'ZDEMO_ABAP_RAP_RO_U'
+ instances = REF #( read_dyn )
+ results = REF #( read_dyn_result ) )
+ ( op = if_abap_behv=>op-r-read_ba
+ entity_name = 'ZDEMO_ABAP_RAP_RO_U'
+ sub_name = '_CHILD'
+ full = abap_false
+ instances = REF #( rba_dyn )
+ results = REF #( rba_dyn_result )
+ links = REF #( rba_dyn_link ) ) ).
+
+ READ ENTITIES OPERATIONS op_tab.
+
+ output->display( input = read_dyn_result name = `read_dyn_result` ).
+ output->display( input = rba_dyn_result name = `rba_dyn_result` ).
+ output->display( input = rba_dyn_link name = `rba_dyn_link` ).
+
+ output->display( `Result if FULL parameter is ` &&
+ `flagged for RBA` ).
+
+ op_tab = VALUE #(
+ ( op = if_abap_behv=>op-r-read
+ entity_name = 'ZDEMO_ABAP_RAP_RO_U'
+ instances = REF #( read_dyn )
+ results = REF #( read_dyn_result ) )
+ ( op = if_abap_behv=>op-r-read_ba
+ entity_name = 'ZDEMO_ABAP_RAP_RO_U'
+ sub_name = '_CHILD'
+ full = abap_true
+ instances = REF #( rba_dyn )
+ results = REF #( rba_dyn_result )
+ links = REF #( rba_dyn_link ) ) ).
+
+ READ ENTITIES OPERATIONS op_tab.
+
+ output->display( input = read_dyn_result name = `read_dyn_result` ).
+ output->display( input = rba_dyn_result name = `rba_dyn_result` ).
+ output->display( input = rba_dyn_link name = `rba_dyn_link` ).
ENDMETHOD.
diff --git a/src/zcl_demo_abap_rap_ext_num_u.clas.xml b/src/zcl_demo_abap_rap_ext_num_u.clas.xml
index 1ee048d..8a82b32 100644
--- a/src/zcl_demo_abap_rap_ext_num_u.clas.xml
+++ b/src/zcl_demo_abap_rap_ext_num_u.clas.xml
@@ -9,7 +9,7 @@
1
X
X
- 5
+ X
diff --git a/src/zcl_demo_abap_sql.clas.abap b/src/zcl_demo_abap_sql.clas.abap
index 1266779..d613e61 100644
--- a/src/zcl_demo_abap_sql.clas.abap
+++ b/src/zcl_demo_abap_sql.clas.abap
@@ -12,26 +12,26 @@
* - Open the class with the ABAP development tools for Eclipse (ADT).
* - Choose F9 to run the class.
* - Check the console output.
-* - To understand the context and the ABAP syntax used, refer to the
-* notes included in the class as comments or refer to the respective
+* - To understand the context and the ABAP syntax used, refer to the
+* notes included in the class as comments or refer to the respective
* topic in the ABAP Keyword Documentation.
-* - Due to the amount of console output, the examples contain numbers
-* (e.g. 1) ..., 2) ..., 3) ...) for the individual example sections.
-* Also, the variable name is displayed in most cases. So to find
-* the relevant output in the console easier and faster, just search
-* for the number/variable name in the console (CTRL+F in the console)
+* - Due to the amount of console output, the examples contain numbers
+* (e.g. 1) ..., 2) ..., 3) ...) for the individual example sections.
+* Also, the variable name is displayed in most cases. So to find
+* the relevant output in the console easier and faster, just search
+* for the number/variable name in the console (CTRL+F in the console)
* or use the debugger.
*
* ----------------------------- NOTE -----------------------------------
* 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
-* intended to provide a better explanation and visualization of the
-* syntax and semantics of ABAP statements, not to solve concrete
-* programming tasks. For production application programs, you should
-* always work out your own solution for each individual case. There is
-* no guarantee for the correctness or completeness of the code.
-* Furthermore, there is no legal responsibility or liability for any
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
@@ -61,13 +61,15 @@ ENDCLASS.
-CLASS zcl_demo_abap_sql IMPLEMENTATION.
+CLASS ZCL_DEMO_ABAP_SQL IMPLEMENTATION.
+
METHOD class_constructor.
"Filling demo database tables.
zcl_demo_abap_flight_tables=>fill_dbtabs( ).
ENDMETHOD.
+
METHOD if_oo_adt_classrun~main.
DATA(output) = NEW zcl_demo_abap_display( out ).
@@ -1588,6 +1590,7 @@ CLASS zcl_demo_abap_sql IMPLEMENTATION.
ENDMETHOD.
+
METHOD select_from_dbtab.
SELECT *
FROM zdemo_abap_carr
diff --git a/src/zcl_demo_abap_sql.clas.xml b/src/zcl_demo_abap_sql.clas.xml
index 0ef0a1f..dddcc88 100644
--- a/src/zcl_demo_abap_sql.clas.xml
+++ b/src/zcl_demo_abap_sql.clas.xml
@@ -9,7 +9,7 @@
1
X
X
- 5
+ X
diff --git a/src/zcl_demo_abap_sql_group_by.clas.abap b/src/zcl_demo_abap_sql_group_by.clas.abap
index 5834caf..e92cd5f 100644
--- a/src/zcl_demo_abap_sql_group_by.clas.abap
+++ b/src/zcl_demo_abap_sql_group_by.clas.abap
@@ -9,26 +9,26 @@
* - Open the class with the ABAP development tools for Eclipse (ADT).
* - Choose F9 to run the class.
* - Check the console output.
-* - To understand the context and the ABAP syntax used, refer to the
-* notes included in the class as comments or refer to the respective
+* - To understand the context and the ABAP syntax used, refer to the
+* notes included in the class as comments or refer to the respective
* topic in the ABAP Keyword Documentation.
-* - Due to the amount of console output, the examples contain numbers
-* (e.g. 1) ..., 2) ..., 3) ...) for the individual example sections.
-* Also, the variable name is displayed in most cases. So to find
-* the relevant output in the console easier and faster, just search
-* for the number/variable name in the console (CTRL+F in the console)
+* - Due to the amount of console output, the examples contain numbers
+* (e.g. 1) ..., 2) ..., 3) ...) for the individual example sections.
+* Also, the variable name is displayed in most cases. So to find
+* the relevant output in the console easier and faster, just search
+* for the number/variable name in the console (CTRL+F in the console)
* or use the debugger.
*
* ----------------------------- NOTE -----------------------------------
* 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
-* intended to provide a better explanation and visualization of the
-* syntax and semantics of ABAP statements, not to solve concrete
-* programming tasks. For production application programs, you should
-* always work out your own solution for each individual case. There is
-* no guarantee for the correctness or completeness of the code.
-* Furthermore, there is no legal responsibility or liability for any
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
@@ -56,7 +56,7 @@ ENDCLASS.
-CLASS zcl_demo_abap_sql_group_by IMPLEMENTATION.
+CLASS ZCL_DEMO_ABAP_SQL_GROUP_BY IMPLEMENTATION.
METHOD class_constructor.
@@ -75,7 +75,7 @@ CLASS zcl_demo_abap_sql_group_by IMPLEMENTATION.
FROM zdemo_abap_flsch
INTO TABLE @DATA(fli_tab).
- output->next_section( `1) Representative Binding` ).
+ output->display( `1) Representative Binding` ).
output->display( `1a) Grouping by one column` ).
LOOP AT fli_tab INTO wa
diff --git a/src/zcl_demo_abap_sql_group_by.clas.xml b/src/zcl_demo_abap_sql_group_by.clas.xml
index b05f99b..697073e 100644
--- a/src/zcl_demo_abap_sql_group_by.clas.xml
+++ b/src/zcl_demo_abap_sql_group_by.clas.xml
@@ -9,7 +9,7 @@
1
X
X
- 5
+ X
diff --git a/src/zcl_demo_abap_string_proc.clas.abap b/src/zcl_demo_abap_string_proc.clas.abap
index b8c8f80..d18fe54 100644
--- a/src/zcl_demo_abap_string_proc.clas.abap
+++ b/src/zcl_demo_abap_string_proc.clas.abap
@@ -13,26 +13,26 @@
* - Open the class with the ABAP development tools for Eclipse (ADT).
* - Choose F9 to run the class.
* - Check the console output.
-* - To understand the context and the ABAP syntax used, refer to the
-* notes included in the class as comments or refer to the respective
+* - To understand the context and the ABAP syntax used, refer to the
+* notes included in the class as comments or refer to the respective
* topic in the ABAP Keyword Documentation.
-* - Due to the amount of console output, the examples contain numbers
-* (e.g. 1) ..., 2) ..., 3) ...) for the individual example sections.
-* Also, the variable name is displayed in most cases. So to find
-* the relevant output in the console easier and faster, just search
-* for the number/variable name in the console (CTRL+F in the console)
+* - Due to the amount of console output, the examples contain numbers
+* (e.g. 1) ..., 2) ..., 3) ...) for the individual example sections.
+* Also, the variable name is displayed in most cases. So to find
+* the relevant output in the console easier and faster, just search
+* for the number/variable name in the console (CTRL+F in the console)
* or use the debugger.
*
* ----------------------------- NOTE -----------------------------------
* 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
-* intended to provide a better explanation and visualization of the
-* syntax and semantics of ABAP statements, not to solve concrete
-* programming tasks. For production application programs, you should
-* always work out your own solution for each individual case. There is
-* no guarantee for the correctness or completeness of the code.
-* Furthermore, there is no legal responsibility or liability for any
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
@@ -51,7 +51,10 @@ CLASS zcl_demo_abap_string_proc DEFINITION
PRIVATE SECTION.
ENDCLASS.
-CLASS zcl_demo_abap_string_proc IMPLEMENTATION.
+
+
+CLASS ZCL_DEMO_ABAP_STRING_PROC IMPLEMENTATION.
+
METHOD if_oo_adt_classrun~main.
@@ -142,12 +145,14 @@ CLASS zcl_demo_abap_string_proc IMPLEMENTATION.
"The expression must be convertible to a string. A blank (not
"within the curly brackets) means a blank in the resulting string.
- DATA(str_c1) = `Hallo`. "String created with backquotes
- DATA(str_c2) = `how`. "Strings created with pipes
+ DATA(str_c1) = `Hallo`.
+ DATA(str_c2) = `how`.
DATA(str_c3) = `are`.
DATA(str_c4) = |{ str_c1 } { sy-uname }, | &&
|{ str_c2 } { str_c3 } you?|.
+ output->display( input = str_c4 name = `str_c4` ).
+
**********************************************************************
output->next_section( `3b) String Templates (2): Control Characters` ).
@@ -157,7 +162,6 @@ CLASS zcl_demo_abap_string_proc IMPLEMENTATION.
DATA(str_c5) = |{ str_c1 }\n{ sy-uname },| &&
|\n{ str_c2 }\n{ str_c3 }\nyou?|.
- 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.
@@ -175,7 +179,7 @@ CLASS zcl_demo_abap_string_proc IMPLEMENTATION.
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->display( input = str_c9 name = `str_c9` ).
**********************************************************************
@@ -1752,4 +1756,4 @@ CLASS zcl_demo_abap_string_proc IMPLEMENTATION.
output->display( input = str_tab_reg_find name = `str_tab_reg_find` ).
ENDMETHOD.
-ENDCLASS.
\ No newline at end of file
+ENDCLASS.
diff --git a/src/zcl_demo_abap_string_proc.clas.xml b/src/zcl_demo_abap_string_proc.clas.xml
index a80a51e..03dfe51 100644
--- a/src/zcl_demo_abap_string_proc.clas.xml
+++ b/src/zcl_demo_abap_string_proc.clas.xml
@@ -9,7 +9,7 @@
1
X
X
- 5
+ X
diff --git a/src/zcl_demo_abap_structures.clas.abap b/src/zcl_demo_abap_structures.clas.abap
index 762a6d2..b95b611 100644
--- a/src/zcl_demo_abap_structures.clas.abap
+++ b/src/zcl_demo_abap_structures.clas.abap
@@ -13,26 +13,26 @@
* - Open the class with the ABAP development tools for Eclipse (ADT).
* - Choose F9 to run the class.
* - Check the console output.
-* - To understand the context and the ABAP syntax used, refer to the
-* notes included in the class as comments or refer to the respective
+* - To understand the context and the ABAP syntax used, refer to the
+* notes included in the class as comments or refer to the respective
* topic in the ABAP Keyword Documentation.
-* - Due to the amount of console output, the examples contain numbers
-* (e.g. 1) ..., 2) ..., 3) ...) for the individual example sections.
-* Also, the variable name is displayed in most cases. So to find
-* the relevant output in the console easier and faster, just search
-* for the number/variable name in the console (CTRL+F in the console)
+* - Due to the amount of console output, the examples contain numbers
+* (e.g. 1) ..., 2) ..., 3) ...) for the individual example sections.
+* Also, the variable name is displayed in most cases. So to find
+* the relevant output in the console easier and faster, just search
+* for the number/variable name in the console (CTRL+F in the console)
* or use the debugger.
*
* ----------------------------- NOTE -----------------------------------
* 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
-* intended to provide a better explanation and visualization of the
-* syntax and semantics of ABAP statements, not to solve concrete
-* programming tasks. For production application programs, you should
-* always work out your own solution for each individual case. There is
-* no guarantee for the correctness or completeness of the code.
-* Furthermore, there is no legal responsibility or liability for any
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
@@ -108,7 +108,41 @@ protected section.
ENDCLASS.
-CLASS zcl_demo_abap_structures IMPLEMENTATION.
+
+CLASS ZCL_DEMO_ABAP_STRUCTURES IMPLEMENTATION.
+
+
+ METHOD class_constructor.
+ initialize_dbtabs( ).
+ fill_deep_structures( ).
+ "Filling demo database tables.
+ zcl_demo_abap_flight_tables=>fill_dbtabs( ).
+ ENDMETHOD.
+
+
+ METHOD fill_deep_structures.
+ "Clearing all content of gs_deep2
+ CLEAR gs_deep2.
+ "Filling nested tables in deep structures
+ gs_deep2-substruc = VALUE #( comp1 = `aaa`
+ comp2 = `bbb`
+ comp3 = `ccc` ).
+
+ gs_deep1-itab = VALUE #(
+ ( col1 = 111 col2 = 222 )
+ ( col1 = 333 col2 = 444
+ ) ).
+
+ gs_deep2-itab = VALUE #(
+ ( col2 = 1 col3 = 2 col4 = 3 )
+ ( col2 = 4 col3 = 5 col4 = 6 )
+ ( col2 = 7 col3 = 8 col4 = 9 )
+ ).
+
+ "Filling individual component that is not shared by both structures
+ gs_deep2-comp4 = 999.
+ ENDMETHOD.
+
METHOD if_oo_adt_classrun~main.
@@ -1116,40 +1150,12 @@ CLASS zcl_demo_abap_structures IMPLEMENTATION.
ENDMETHOD.
- METHOD class_constructor.
- initialize_dbtabs( ).
- fill_deep_structures( ).
- "Filling demo database tables.
- zcl_demo_abap_flight_tables=>fill_dbtabs( ).
- ENDMETHOD.
-
- METHOD fill_deep_structures.
- "Clearing all content of gs_deep2
- CLEAR gs_deep2.
- "Filling nested tables in deep structures
- gs_deep2-substruc = VALUE #( comp1 = `aaa`
- comp2 = `bbb`
- comp3 = `ccc` ).
-
- gs_deep1-itab = VALUE #(
- ( col1 = 111 col2 = 222 )
- ( col1 = 333 col2 = 444
- ) ).
-
- gs_deep2-itab = VALUE #(
- ( col2 = 1 col3 = 2 col4 = 3 )
- ( col2 = 4 col3 = 5 col4 = 6 )
- ( col2 = 7 col3 = 8 col4 = 9 )
- ).
-
- "Filling individual component that is not shared by both structures
- gs_deep2-comp4 = 999.
- ENDMETHOD.
METHOD initialize_dbtabs.
DELETE FROM zdemo_abap_tab1.
ENDMETHOD.
+
METHOD select_from_dbtab.
SELECT FROM zdemo_abap_tab1
@@ -1159,4 +1165,4 @@ CLASS zcl_demo_abap_structures IMPLEMENTATION.
INTO TABLE @gt_tab.
ENDMETHOD.
-ENDCLASS.
\ No newline at end of file
+ENDCLASS.
diff --git a/src/zcl_demo_abap_structures.clas.xml b/src/zcl_demo_abap_structures.clas.xml
index f62b1e1..4e720ff 100644
--- a/src/zcl_demo_abap_structures.clas.xml
+++ b/src/zcl_demo_abap_structures.clas.xml
@@ -9,7 +9,7 @@
1
X
X
- 5
+ X
diff --git a/src/zcl_demo_abap_unit_test.clas.abap b/src/zcl_demo_abap_unit_test.clas.abap
index 94fb722..543fb10 100644
--- a/src/zcl_demo_abap_unit_test.clas.abap
+++ b/src/zcl_demo_abap_unit_test.clas.abap
@@ -17,7 +17,7 @@
* and can be evaluated. The Failure Trace section provides information
* on errors found.
* - If you are interested in test coverage, you can choose
-* Ctrl/Cmd + Shift + F11, or make a right-click, choose Run as ->
+* Ctrl/Cmd + Shift + F11, or make a right-click, choose Run as ->
* ABAP Unit Test With..., select the Coverage checkbox and choose
* Execute. You can then check the results in the ABAP Coverage tab,
* what code is tested and what not.
@@ -39,13 +39,13 @@
* ----------------------------- NOTE -----------------------------------
* 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
-* intended to provide a better explanation and visualization of the
-* syntax and semantics of ABAP statements, not to solve concrete
-* programming tasks. For production application programs, you should
-* always work out your own solution for each individual case. There is
-* no guarantee for the correctness or completeness of the code.
-* Furthermore, there is no legal responsibility or liability for any
+* environment. The code examples in the ABAP cheat sheets are primarily
+* intended to provide a better explanation and visualization of the
+* syntax and semantics of ABAP statements, not to solve concrete
+* programming tasks. For production application programs, you should
+* always work out your own solution for each individual case. There is
+* no guarantee for the correctness or completeness of the code.
+* Furthermore, there is no legal responsibility or liability for any
* errors or their consequences that may occur when using the the example
* code.
*
@@ -165,7 +165,338 @@ PRIVATE SECTION.
ENDCLASS.
-CLASS zcl_demo_abap_unit_test IMPLEMENTATION.
+
+
+CLASS ZCL_DEMO_ABAP_UNIT_TEST IMPLEMENTATION.
+
+
+METHOD class_constructor.
+ "Filling demo database tables.
+ zcl_demo_abap_flight_tables=>fill_dbtabs( ).
+
+ "Preparing a demo database table for this example (get_sum method)
+ DELETE FROM zdemo_abap_tab1.
+ INSERT zdemo_abap_tab1 FROM @(
+ VALUE #( key_field = 1 char1 = 'aaa' char2 = 'bbb' num1 = 25 num2 = 75 ) ).
+ENDMETHOD.
+
+
+METHOD constructor.
+
+ "For demonstrating the back door injection
+ data_provider_local_itf = NEW lcl_data_prov_local_itf( ).
+
+ "For demonstrating the constructor injection
+ IF iref_data_prov IS BOUND.
+ "Note: The parameter is only bound when you run the unit test.
+ "When you run the unit test and you debug, you will see that iref_data_prov
+ "has a type reference to LTD_TEST_DATA_GLOBAL_INTF.
+
+ data_provider_global_itf = iref_data_prov.
+
+ ELSE.
+
+ data_provider_global_itf = NEW lcl_data_prov_glo_itf( ).
+
+ ENDIF.
+
+ "Object creation for the method call in the get_occ_rate_setter_inj method
+ data_provider_setter_inj = NEW lcl_data_prov_glo_itf( ).
+
+ENDMETHOD.
+
+
+METHOD get_common_div_and_gcd.
+ "Calculates the common divisors and the greatest common divisor of two numbers
+
+ CLEAR: common_divisors, gcd.
+
+ CHECK a >= 1.
+ CHECK b >= 1.
+
+ IF a >= b.
+ DATA(greater_num) = a.
+ DATA(lower_num) = b.
+ ELSE.
+ greater_num = b.
+ lower_num = a.
+ ENDIF.
+
+ "Getting common divisors
+ DATA(div) = 1.
+
+ WHILE div <= lower_num.
+ IF lower_num MOD div = 0.
+ DATA(divisor) = lower_num / div.
+ INSERT divisor INTO TABLE common_divisors.
+ ENDIF.
+
+ div += 1.
+ ENDWHILE.
+
+ LOOP AT common_divisors ASSIGNING FIELD-SYMBOL().
+
+ IF greater_num MOD <> 0.
+ DELETE common_divisors WHERE table_line = .
+ ENDIF.
+
+ ENDLOOP.
+
+ "Extracting the greatest common divisor from the list of common divisors
+ gcd = common_divisors[ lines( common_divisors ) ].
+
+ENDMETHOD.
+
+
+METHOD get_digit_sum.
+ "Calculates the digit sum of a number
+
+ CLEAR digit_sum.
+
+ CHECK num >= 0.
+
+ DATA(converted_int) = CONV string( num ).
+ DATA(len) = strlen( converted_int ).
+
+ DO len TIMES.
+ DATA(idx) = sy-index - 1.
+ digit_sum = digit_sum + converted_int+idx(1).
+ ENDDO.
+
+ENDMETHOD.
+
+
+METHOD get_occ_rate_global_itf.
+ "Method to demonstrate test double injection using constructor injection
+ "and a global interface
+
+ DATA total_seatsmax_global_itf TYPE i.
+ DATA total_seatsocc_global_itf TYPE i.
+
+ "Assumption: The original code in this method was as follows (the line commented out).
+ "It was identified as DOC (reading data from a database table).
+
+ "DATA(flight_data) = select_flight_data( carrier = carrier_id ).
+
+ "Instead of a method call like above and for a proper unit testing, a global interface
+ "is provided.
+ "In the example, an interface method is implemented in a local class in the local types
+ "tab (CCIMP include): lcl_data_prov_glo_itf
+
+ "When the class is executed using F9, the object used here refers to type lcl_data_prov_glo_itf.
+ "When the unit test is executed, the object used here refers to type ltd_test_data_global_intf,
+ "i.e. the local test double is injected.
+ DATA(flight_data) = data_provider_global_itf->select_flight_data( carrier = carrier_id ).
+
+ LOOP AT flight_data ASSIGNING FIELD-SYMBOL().
+
+ total_seatsmax_global_itf = total_seatsmax_global_itf + -seatsmax.
+ total_seatsocc_global_itf = total_seatsocc_global_itf + -seatsocc.
+
+ ENDLOOP.
+
+ occupancy_rate = total_seatsocc_global_itf / total_seatsmax_global_itf * 100.
+
+ENDMETHOD.
+
+
+METHOD get_occ_rate_local_itf.
+ "Method to demonstrate test double injection using back door
+ "injection and a local interface
+
+ DATA total_seatsmax_local_itf TYPE i.
+ DATA total_seatsocc_local_itf TYPE i.
+
+ "Assumption: The original code in this method was as follows (the line commented out).
+ "It was identified as DOC (reading data from a database table).
+
+ "DATA(flight_data) = select_flight_data( carrier = carrier_id ).
+
+ "Instead of a method call like above and for a proper unit testing - a global interface
+ "is not available - a local interface is created, and
+ "an interface method is implemented. In this example, the local interface is
+ "created in the local types tab (CCIMP include): lif_get_data
+ "A local class (lcl_data_prov_local_itf) is also created in the CCIMP include. It
+ "implements the local interface.
+
+ "When the class is executed using F9, the object used here refers to type lcl_data_prov_local_itf.
+ "When the unit test is executed, the object used here refers to type ltd_test_data_local_itf,
+ "i.e. the local test double is injected.
+ DATA(flight_data) = data_provider_local_itf->select_flight_data( carrier = carrier_id ).
+
+ LOOP AT flight_data ASSIGNING FIELD-SYMBOL().
+
+ total_seatsmax_local_itf = total_seatsmax_local_itf + -seatsmax.
+ total_seatsocc_local_itf = total_seatsocc_local_itf + -seatsocc.
+
+ ENDLOOP.
+
+ occupancy_rate = total_seatsocc_local_itf / total_seatsmax_local_itf * 100.
+
+ENDMETHOD.
+
+
+METHOD get_occ_rate_param_inj.
+ "This method demonstrates test double injection using parameter injection.
+
+ DATA total_seatsmax_param_inj TYPE i.
+ DATA total_seatsocc_param_inj TYPE i.
+
+ "Assumption: The original code in this method was as follows (the line commented out).
+ "It was identified as DOC (reading data from a database table).
+
+ "DATA(flight_data) = select_flight_data( carrier = carrier_id ).
+
+ "Instead of a method call like above and for a proper unit testing, a global interface
+ "is provided.
+ "In the example, an interface method is implemented in a local class in the local types
+ "tab (CCIMP include): lcl_data_prov_glo_itf
+
+ "The method has an optional importing parameter. When the unit test is executed,
+ "the parameter is bound. An object of the test double class is passed in that case.
+ "Otherwise, when the class is executed using F9, an object of the actual data provider
+ "is created.
+ IF data_prov IS BOUND.
+ data_provider_param_inj = data_prov.
+ ELSE.
+ data_provider_param_inj = NEW lcl_data_prov_glo_itf( ).
+ ENDIF.
+
+ DATA(flight_data) = data_provider_param_inj->select_flight_data( carrier = carrier_id ).
+
+ LOOP AT flight_data ASSIGNING FIELD-SYMBOL().
+
+ total_seatsmax_param_inj = total_seatsmax_param_inj + -seatsmax.
+ total_seatsocc_param_inj = total_seatsocc_param_inj + -seatsocc.
+
+ ENDLOOP.
+
+ occupancy_rate = total_seatsocc_param_inj / total_seatsmax_param_inj * 100.
+
+ENDMETHOD.
+
+
+METHOD get_occ_rate_setter_inj.
+ "This method demonstrates test double injection using setting injection.
+ "See the setter_meth method.
+
+ DATA total_seatsmax_setter_inj TYPE i.
+ DATA total_seatsocc_setter_inj TYPE i.
+
+ "Assumption: The original code in this method was as follows (the line commented out).
+ "It was identified as DOC (reading data from a database table).
+
+ "DATA(flight_data) = select_flight_data( carrier = carrier_id ).
+
+ "Instead of a method call like above and for a proper unit testing, a global interface
+ "is provided.
+ "In the example, an interface method is implemented in a local class in the local types
+ "tab (CCIMP include): lcl_data_prov_glo_itf
+
+ "See the comment in the setter_meth method
+ DATA(flight_data) = data_provider_setter_inj->select_flight_data( carrier = carrier_id ).
+
+ LOOP AT flight_data ASSIGNING FIELD-SYMBOL().
+
+ total_seatsmax_setter_inj = total_seatsmax_setter_inj + -seatsmax.
+ total_seatsocc_setter_inj = total_seatsocc_setter_inj + -seatsocc.
+
+ ENDLOOP.
+
+ occupancy_rate = total_seatsocc_setter_inj / total_seatsmax_setter_inj * 100.
+
+ENDMETHOD.
+
+
+METHOD get_occ_rate_test_seam.
+"Method to demonstrate test double injection using test seams
+"Note: The code is just for demonstration purposes. Of course, the result can be
+"achieved more elegantly using SQL expressions, for example.
+
+ TEST-SEAM select_flights.
+ "DOC
+ SELECT seatsmax, seatsocc
+ FROM zdemo_abap_fli
+ WHERE carrid = @carrier_id
+ INTO CORRESPONDING FIELDS OF TABLE @seats_table.
+ END-TEST-SEAM.
+
+ DATA total_seatsmax_tm TYPE i.
+ DATA total_seatsocc_tm TYPE i.
+
+ LOOP AT seats_table ASSIGNING FIELD-SYMBOL().
+
+ total_seatsmax_tm = total_seatsmax_tm + -seatsmax.
+ total_seatsocc_tm = total_seatsocc_tm + -seatsocc.
+
+ ENDLOOP.
+
+ occupancy_rate = total_seatsocc_tm / total_seatsmax_tm * 100.
+
+ "Further examples for test seams
+ DATA(var) = 0.
+
+ "Empty test seam; code is injected during unit test
+ "Check the output when running the class using F9 and
+ "the test results when running the unit test.
+ TEST-SEAM num1.
+ END-TEST-SEAM.
+
+ IF var = 0.
+ num1 = 1.
+ ELSE.
+ num1 = 999.
+ ENDIF.
+
+ num2 = 0.
+
+ "Empty injection
+ "See the test class: The code that is included in the test
+ "seam should be excluded from the test. Therefore, the
+ "test injection block in the test class is empty.
+ "Check the output when running the class using F9 and
+ "the test results when running the unit test.
+ TEST-SEAM num2.
+ num2 = 123.
+ END-TEST-SEAM.
+
+ENDMETHOD.
+
+
+METHOD get_occ_rate_using_meth.
+ "This method demonstrates test double injection using inheritance and method redefinition.
+
+ DATA total_seatsmax_no TYPE i.
+ DATA total_seatsocc_no TYPE i.
+
+ "During the unit test, the redefined method in the test class is called.
+ DATA(flight_data) = select_flight_data( carrier = carrier_id ).
+
+ LOOP AT flight_data ASSIGNING FIELD-SYMBOL().
+
+ total_seatsmax_no = total_seatsmax_no + -seatsmax.
+ total_seatsocc_no = total_seatsocc_no + -seatsocc.
+
+ ENDLOOP.
+
+ occupancy_rate = total_seatsocc_no / total_seatsmax_no * 100.
+
+ENDMETHOD.
+
+
+METHOD get_sum.
+ "The method selects a record from a database table and sums the values
+ "of two fields, both are of type i.
+
+ SELECT SINGLE
+ FROM zdemo_abap_tab1
+ FIELDS num1 + num2 AS sum
+ WHERE key_field = @key
+ AND char1 = @char
+ INTO @sum.
+
+ENDMETHOD.
+
METHOD if_oo_adt_classrun~main.
"Note: The example includes a couple of implementations for the methods
@@ -179,6 +510,11 @@ METHOD if_oo_adt_classrun~main.
DATA(output) = NEW zcl_demo_abap_display( out ).
output->display( `ABAP Cheat Sheet Example: ABAP Unit Tests` ).
+
+ output->display( `************************************************************************` ).
+ output->display( `---> Choose Ctrl/Cmd + Shift + F10 to launch all tests in the class <---` ).
+ output->display( `************************************************************************` ).
+
output->display( `1) get_sum Method` ).
"This method demonstrates the use of the setup and teardown methods in the test class.
@@ -327,232 +663,6 @@ METHOD if_oo_adt_classrun~main.
ENDMETHOD.
-METHOD class_constructor.
- "Filling demo database tables.
- zcl_demo_abap_flight_tables=>fill_dbtabs( ).
-
- "Preparing a demo database table for this example (get_sum method)
- DELETE FROM zdemo_abap_tab1.
- INSERT zdemo_abap_tab1 FROM @(
- VALUE #( key_field = 1 char1 = 'aaa' char2 = 'bbb' num1 = 25 num2 = 75 ) ).
-ENDMETHOD.
-
-METHOD constructor.
-
- "For demonstrating the back door injection
- data_provider_local_itf = NEW lcl_data_prov_local_itf( ).
-
- "For demonstrating the constructor injection
- IF iref_data_prov IS BOUND.
- "Note: The parameter is only bound when you run the unit test.
- "When you run the unit test and you debug, you will see that iref_data_prov
- "has a type reference to LTD_TEST_DATA_GLOBAL_INTF.
-
- data_provider_global_itf = iref_data_prov.
-
- ELSE.
-
- data_provider_global_itf = NEW lcl_data_prov_glo_itf( ).
-
- ENDIF.
-
- "Object creation for the method call in the get_occ_rate_setter_inj method
- data_provider_setter_inj = NEW lcl_data_prov_glo_itf( ).
-
-ENDMETHOD.
-
-METHOD get_sum.
- "The method selects a record from a database table and sums the values
- "of two fields, both are of type i.
-
- SELECT SINGLE
- FROM zdemo_abap_tab1
- FIELDS num1 + num2 AS sum
- WHERE key_field = @key
- AND char1 = @char
- INTO @sum.
-
-ENDMETHOD.
-
-METHOD get_common_div_and_gcd.
- "Calculates the common divisors and the greatest common divisor of two numbers
-
- CLEAR: common_divisors, gcd.
-
- CHECK a >= 1.
- CHECK b >= 1.
-
- IF a >= b.
- DATA(greater_num) = a.
- DATA(lower_num) = b.
- ELSE.
- greater_num = b.
- lower_num = a.
- ENDIF.
-
- "Getting common divisors
- DATA(div) = 1.
-
- WHILE div <= lower_num.
- IF lower_num MOD div = 0.
- DATA(divisor) = lower_num / div.
- INSERT divisor INTO TABLE common_divisors.
- ENDIF.
-
- div += 1.
- ENDWHILE.
-
- LOOP AT common_divisors ASSIGNING FIELD-SYMBOL().
-
- IF greater_num MOD <> 0.
- DELETE common_divisors WHERE table_line = .
- ENDIF.
-
- ENDLOOP.
-
- "Extracting the greatest common divisor from the list of common divisors
- gcd = common_divisors[ lines( common_divisors ) ].
-
-ENDMETHOD.
-
-METHOD get_digit_sum.
- "Calculates the digit sum of a number
-
- CLEAR digit_sum.
-
- CHECK num >= 0.
-
- DATA(converted_int) = CONV string( num ).
- DATA(len) = strlen( converted_int ).
-
- DO len TIMES.
- DATA(idx) = sy-index - 1.
- digit_sum = digit_sum + converted_int+idx(1).
- ENDDO.
-
-ENDMETHOD.
-
-METHOD get_occ_rate_test_seam.
-"Method to demonstrate test double injection using test seams
-"Note: The code is just for demonstration purposes. Of course, the result can be
-"achieved more elegantly using SQL expressions, for example.
-
- TEST-SEAM select_flights.
- "DOC
- SELECT seatsmax, seatsocc
- FROM zdemo_abap_fli
- WHERE carrid = @carrier_id
- INTO CORRESPONDING FIELDS OF TABLE @seats_table.
- END-TEST-SEAM.
-
- DATA total_seatsmax_tm TYPE i.
- DATA total_seatsocc_tm TYPE i.
-
- LOOP AT seats_table ASSIGNING FIELD-SYMBOL().
-
- total_seatsmax_tm = total_seatsmax_tm + -seatsmax.
- total_seatsocc_tm = total_seatsocc_tm + -seatsocc.
-
- ENDLOOP.
-
- occupancy_rate = total_seatsocc_tm / total_seatsmax_tm * 100.
-
- "Further examples for test seams
- DATA(var) = 0.
-
- "Empty test seam; code is injected during unit test
- "Check the output when running the class using F9 and
- "the test results when running the unit test.
- TEST-SEAM num1.
- END-TEST-SEAM.
-
- IF var = 0.
- num1 = 1.
- ELSE.
- num1 = 999.
- ENDIF.
-
- num2 = 0.
-
- "Empty injection
- "See the test class: The code that is included in the test
- "seam should be excluded from the test. Therefore, the
- "test injection block in the test class is empty.
- "Check the output when running the class using F9 and
- "the test results when running the unit test.
- TEST-SEAM num2.
- num2 = 123.
- END-TEST-SEAM.
-
-ENDMETHOD.
-
-METHOD get_occ_rate_local_itf.
- "Method to demonstrate test double injection using back door
- "injection and a local interface
-
- DATA total_seatsmax_local_itf TYPE i.
- DATA total_seatsocc_local_itf TYPE i.
-
- "Assumption: The original code in this method was as follows (the line commented out).
- "It was identified as DOC (reading data from a database table).
-
- "DATA(flight_data) = select_flight_data( carrier = carrier_id ).
-
- "Instead of a method call like above and for a proper unit testing - a global interface
- "is not available - a local interface is created, and
- "an interface method is implemented. In this example, the local interface is
- "created in the local types tab (CCIMP include): lif_get_data
- "A local class (lcl_data_prov_local_itf) is also created in the CCIMP include. It
- "implements the local interface.
-
- "When the class is executed using F9, the object used here refers to type lcl_data_prov_local_itf.
- "When the unit test is executed, the object used here refers to type ltd_test_data_local_itf,
- "i.e. the local test double is injected.
- DATA(flight_data) = data_provider_local_itf->select_flight_data( carrier = carrier_id ).
-
- LOOP AT flight_data ASSIGNING FIELD-SYMBOL().
-
- total_seatsmax_local_itf = total_seatsmax_local_itf + -seatsmax.
- total_seatsocc_local_itf = total_seatsocc_local_itf + -seatsocc.
-
- ENDLOOP.
-
- occupancy_rate = total_seatsocc_local_itf / total_seatsmax_local_itf * 100.
-
-ENDMETHOD.
-
-METHOD get_occ_rate_global_itf.
- "Method to demonstrate test double injection using constructor injection
- "and a global interface
-
- DATA total_seatsmax_global_itf TYPE i.
- DATA total_seatsocc_global_itf TYPE i.
-
- "Assumption: The original code in this method was as follows (the line commented out).
- "It was identified as DOC (reading data from a database table).
-
- "DATA(flight_data) = select_flight_data( carrier = carrier_id ).
-
- "Instead of a method call like above and for a proper unit testing, a global interface
- "is provided.
- "In the example, an interface method is implemented in a local class in the local types
- "tab (CCIMP include): lcl_data_prov_glo_itf
-
- "When the class is executed using F9, the object used here refers to type lcl_data_prov_glo_itf.
- "When the unit test is executed, the object used here refers to type ltd_test_data_global_intf,
- "i.e. the local test double is injected.
- DATA(flight_data) = data_provider_global_itf->select_flight_data( carrier = carrier_id ).
-
- LOOP AT flight_data ASSIGNING FIELD-SYMBOL().
-
- total_seatsmax_global_itf = total_seatsmax_global_itf + -seatsmax.
- total_seatsocc_global_itf = total_seatsocc_global_itf + -seatsocc.
-
- ENDLOOP.
-
- occupancy_rate = total_seatsocc_global_itf / total_seatsmax_global_itf * 100.
-
-ENDMETHOD.
METHOD select_flight_data.
"Method that is identified as DOC in the method implementations above.
@@ -564,56 +674,6 @@ METHOD select_flight_data.
INTO CORRESPONDING FIELDS OF TABLE @flight_data.
ENDMETHOD.
-METHOD get_occ_rate_using_meth.
- "This method demonstrates test double injection using inheritance and method redefinition.
-
- DATA total_seatsmax_no TYPE i.
- DATA total_seatsocc_no TYPE i.
-
- "During the unit test, the redefined method in the test class is called.
- DATA(flight_data) = select_flight_data( carrier = carrier_id ).
-
- LOOP AT flight_data ASSIGNING FIELD-SYMBOL().
-
- total_seatsmax_no = total_seatsmax_no + -seatsmax.
- total_seatsocc_no = total_seatsocc_no + -seatsocc.
-
- ENDLOOP.
-
- occupancy_rate = total_seatsocc_no / total_seatsmax_no * 100.
-
-ENDMETHOD.
-
-METHOD get_occ_rate_setter_inj.
- "This method demonstrates test double injection using setting injection.
- "See the setter_meth method.
-
- DATA total_seatsmax_setter_inj TYPE i.
- DATA total_seatsocc_setter_inj TYPE i.
-
- "Assumption: The original code in this method was as follows (the line commented out).
- "It was identified as DOC (reading data from a database table).
-
- "DATA(flight_data) = select_flight_data( carrier = carrier_id ).
-
- "Instead of a method call like above and for a proper unit testing, a global interface
- "is provided.
- "In the example, an interface method is implemented in a local class in the local types
- "tab (CCIMP include): lcl_data_prov_glo_itf
-
- "See the comment in the setter_meth method
- DATA(flight_data) = data_provider_setter_inj->select_flight_data( carrier = carrier_id ).
-
- LOOP AT flight_data ASSIGNING FIELD-SYMBOL().
-
- total_seatsmax_setter_inj = total_seatsmax_setter_inj + -seatsmax.
- total_seatsocc_setter_inj = total_seatsocc_setter_inj + -seatsocc.
-
- ENDLOOP.
-
- occupancy_rate = total_seatsocc_setter_inj / total_seatsmax_setter_inj * 100.
-
-ENDMETHOD.
METHOD setter_meth.
"Method to demonstrate the test double injection using setter injection
@@ -623,44 +683,4 @@ METHOD setter_meth.
"i.e. the local test double is injected.
data_provider_setter_inj = data_prov.
ENDMETHOD.
-
-METHOD get_occ_rate_param_inj.
- "This method demonstrates test double injection using parameter injection.
-
- DATA total_seatsmax_param_inj TYPE i.
- DATA total_seatsocc_param_inj TYPE i.
-
- "Assumption: The original code in this method was as follows (the line commented out).
- "It was identified as DOC (reading data from a database table).
-
- "DATA(flight_data) = select_flight_data( carrier = carrier_id ).
-
- "Instead of a method call like above and for a proper unit testing, a global interface
- "is provided.
- "In the example, an interface method is implemented in a local class in the local types
- "tab (CCIMP include): lcl_data_prov_glo_itf
-
- "The method has an optional importing parameter. When the unit test is executed,
- "the parameter is bound. An object of the test double class is passed in that case.
- "Otherwise, when the class is executed using F9, an object of the actual data provider
- "is created.
- IF data_prov IS BOUND.
- data_provider_param_inj = data_prov.
- ELSE.
- data_provider_param_inj = NEW lcl_data_prov_glo_itf( ).
- ENDIF.
-
- DATA(flight_data) = data_provider_param_inj->select_flight_data( carrier = carrier_id ).
-
- LOOP AT flight_data ASSIGNING FIELD-SYMBOL().
-
- total_seatsmax_param_inj = total_seatsmax_param_inj + -seatsmax.
- total_seatsocc_param_inj = total_seatsocc_param_inj + -seatsocc.
-
- ENDLOOP.
-
- occupancy_rate = total_seatsocc_param_inj / total_seatsmax_param_inj * 100.
-
-ENDMETHOD.
-
-ENDCLASS.
\ No newline at end of file
+ENDCLASS.
diff --git a/src/zcl_demo_abap_unit_test.clas.testclasses.abap b/src/zcl_demo_abap_unit_test.clas.testclasses.abap
index 1462c75..4710705 100644
--- a/src/zcl_demo_abap_unit_test.clas.testclasses.abap
+++ b/src/zcl_demo_abap_unit_test.clas.testclasses.abap
@@ -1381,4 +1381,4 @@ METHOD test_get_occ_rate_par_inj_fail.
ENDMETHOD.
-ENDCLASS.
\ No newline at end of file
+ENDCLASS.
diff --git a/src/zcl_demo_abap_unit_test.clas.xml b/src/zcl_demo_abap_unit_test.clas.xml
index 1525fa3..00173f5 100644
--- a/src/zcl_demo_abap_unit_test.clas.xml
+++ b/src/zcl_demo_abap_unit_test.clas.xml
@@ -5,11 +5,11 @@
ZCL_DEMO_ABAP_UNIT_TEST
E
- ABAP cheat sheet: Unit test
+ ABAP cheat sheet: Unit tests
1
X
X
- 5
+ X
X
diff --git a/src/zdemo_abap_carr.tabl.xml b/src/zdemo_abap_carr.tabl.xml
index 7e12f1a..d5c1fd0 100644
--- a/src/zdemo_abap_carr.tabl.xml
+++ b/src/zdemo_abap_carr.tabl.xml
@@ -11,7 +11,6 @@
E
A
1
- 5
ZDEMO_ABAP_CARR
diff --git a/src/zdemo_abap_draft.tabl.xml b/src/zdemo_abap_draft.tabl.xml
index fc407f8..17acf58 100644
--- a/src/zdemo_abap_draft.tabl.xml
+++ b/src/zdemo_abap_draft.tabl.xml
@@ -13,7 +13,6 @@
X
A
1
- 5
ZDEMO_ABAP_DRAFT
diff --git a/src/zdemo_abap_fli.tabl.xml b/src/zdemo_abap_fli.tabl.xml
index 5e9038b..1a1a285 100644
--- a/src/zdemo_abap_fli.tabl.xml
+++ b/src/zdemo_abap_fli.tabl.xml
@@ -11,7 +11,6 @@
E
A
1
- 5
ZDEMO_ABAP_FLI
diff --git a/src/zdemo_abap_flsch.tabl.xml b/src/zdemo_abap_flsch.tabl.xml
index 699b4ed..dc1d057 100644
--- a/src/zdemo_abap_flsch.tabl.xml
+++ b/src/zdemo_abap_flsch.tabl.xml
@@ -12,7 +12,6 @@
X
A
1
- 5
ZDEMO_ABAP_FLSCH
diff --git a/src/zdemo_abap_get_data_itf.intf.xml b/src/zdemo_abap_get_data_itf.intf.xml
index 3e8a07b..e40e8b9 100644
--- a/src/zdemo_abap_get_data_itf.intf.xml
+++ b/src/zdemo_abap_get_data_itf.intf.xml
@@ -8,7 +8,7 @@
Interface for ABAP cheat sheet example
2
1
- 5
+ X
diff --git a/src/zdemo_abap_objects_interface.intf.xml b/src/zdemo_abap_objects_interface.intf.xml
index c94d0ab..fc31bfe 100644
--- a/src/zdemo_abap_objects_interface.intf.xml
+++ b/src/zdemo_abap_objects_interface.intf.xml
@@ -8,7 +8,7 @@
Interface for ABAP cheat sheet example
2
1
- 5
+ X
diff --git a/src/zdemo_abap_rap_draft_m.bdef.asbdef b/src/zdemo_abap_rap_draft_m.bdef.asbdef
index e78801f..322d015 100644
--- a/src/zdemo_abap_rap_draft_m.bdef.asbdef
+++ b/src/zdemo_abap_rap_draft_m.bdef.asbdef
@@ -1,5 +1,5 @@
managed implementation in class zbp_demo_abap_rap_draft_m unique;
-strict;
+strict(2);
with draft;
define behavior for ZDEMO_ABAP_RAP_DRAFT_M alias calc
@@ -22,11 +22,7 @@ late numbering
determination det_modify on modify { field num1, num2, arithm_op; }
draft action Resume;
draft action Edit;
- //As of release 2308: Draft action "Activate" should be defined as "optimized"
- //to enable optimized execution of determinations and validations.
- //Comment in the following notation, comment out the one below.
- //draft action Activate optimized;
- draft action Activate;
+ draft action Activate optimized;
draft action Discard;
draft determine action Prepare
{
diff --git a/src/zdemo_abap_rap_draft_m.bdef.xml b/src/zdemo_abap_rap_draft_m.bdef.xml
index aeab9fc..f41ce70 100644
--- a/src/zdemo_abap_rap_draft_m.bdef.xml
+++ b/src/zdemo_abap_rap_draft_m.bdef.xml
@@ -14,12 +14,6 @@
http://www.sap.com/adt/relations/versions
Historic versions
- -
- /sap/bc/adt/repository/informationsystem/abaplanguageversions?uri=%2Fsap%2Fbc%2Fadt%2Fbo%2Fbehaviordefinitions%2Fzdemo_abap_rap_draft_m
- http://www.sap.com/adt/relations/informationsystem/abaplanguageversions
- application/vnd.sap.adt.nameditems.v1+xml
- Allowed ABAP language versions
-
-
./zdemo_abap_rap_draft_m/source/main
http://www.sap.com/adt/relations/source
@@ -32,11 +26,6 @@
text/html
Source Content (HTML)
- -
- ./zdemo_abap_rap_draft_m/objectstructure
- http://www.sap.com/adt/relations/objectstructure
- Object Structure
-
EN
5
diff --git a/src/zdemo_abap_rap_ro_m.bdef.asbdef b/src/zdemo_abap_rap_ro_m.bdef.asbdef
index 1766aa3..2501e12 100644
--- a/src/zdemo_abap_rap_ro_m.bdef.asbdef
+++ b/src/zdemo_abap_rap_ro_m.bdef.asbdef
@@ -1,5 +1,5 @@
managed implementation in class zbp_demo_abap_rap_ro_m unique;
-strict;
+strict(2);
define behavior for ZDEMO_ABAP_RAP_RO_M alias root
persistent table zdemo_abap_rapt1
diff --git a/src/zdemo_abap_rap_ro_m.bdef.xml b/src/zdemo_abap_rap_ro_m.bdef.xml
index 79a0de4..7c4446e 100644
--- a/src/zdemo_abap_rap_ro_m.bdef.xml
+++ b/src/zdemo_abap_rap_ro_m.bdef.xml
@@ -14,12 +14,6 @@
http://www.sap.com/adt/relations/versions
Historic versions
- -
- /sap/bc/adt/repository/informationsystem/abaplanguageversions?uri=%2Fsap%2Fbc%2Fadt%2Fbo%2Fbehaviordefinitions%2Fzdemo_abap_rap_ro_m
- http://www.sap.com/adt/relations/informationsystem/abaplanguageversions
- application/vnd.sap.adt.nameditems.v1+xml
- Allowed ABAP language versions
-
-
./zdemo_abap_rap_ro_m/source/main
http://www.sap.com/adt/relations/source
@@ -32,11 +26,6 @@
text/html
Source Content (HTML)
- -
- ./zdemo_abap_rap_ro_m/objectstructure
- http://www.sap.com/adt/relations/objectstructure
- Object Structure
-
EN
5
diff --git a/src/zdemo_abap_rap_ro_u.bdef.asbdef b/src/zdemo_abap_rap_ro_u.bdef.asbdef
index 514e174..da5f875 100644
--- a/src/zdemo_abap_rap_ro_u.bdef.asbdef
+++ b/src/zdemo_abap_rap_ro_u.bdef.asbdef
@@ -1,5 +1,5 @@
unmanaged implementation in class zbp_demo_abap_rap_ro_u unique;
-strict;
+strict(2);
define behavior for ZDEMO_ABAP_RAP_RO_U alias root
lock master
diff --git a/src/zdemo_abap_rap_ro_u.bdef.xml b/src/zdemo_abap_rap_ro_u.bdef.xml
index 51bc58b..4430d7a 100644
--- a/src/zdemo_abap_rap_ro_u.bdef.xml
+++ b/src/zdemo_abap_rap_ro_u.bdef.xml
@@ -14,12 +14,6 @@
http://www.sap.com/adt/relations/versions
Historic versions
- -
- /sap/bc/adt/repository/informationsystem/abaplanguageversions?uri=%2Fsap%2Fbc%2Fadt%2Fbo%2Fbehaviordefinitions%2Fzdemo_abap_rap_ro_u
- http://www.sap.com/adt/relations/informationsystem/abaplanguageversions
- application/vnd.sap.adt.nameditems.v1+xml
- Allowed ABAP language versions
-
-
./zdemo_abap_rap_ro_u/source/main
http://www.sap.com/adt/relations/source
@@ -32,11 +26,6 @@
text/html
Source Content (HTML)
- -
- ./zdemo_abap_rap_ro_u/objectstructure
- http://www.sap.com/adt/relations/objectstructure
- Object Structure
-
EN
5
diff --git a/src/zdemo_abap_rapt1.tabl.xml b/src/zdemo_abap_rapt1.tabl.xml
index 7080f71..67007ba 100644
--- a/src/zdemo_abap_rapt1.tabl.xml
+++ b/src/zdemo_abap_rapt1.tabl.xml
@@ -12,7 +12,6 @@
X
A
1
- 5
ZDEMO_ABAP_RAPT1
diff --git a/src/zdemo_abap_rapt2.tabl.xml b/src/zdemo_abap_rapt2.tabl.xml
index 6bcfa50..e4fc463 100644
--- a/src/zdemo_abap_rapt2.tabl.xml
+++ b/src/zdemo_abap_rapt2.tabl.xml
@@ -12,7 +12,6 @@
X
A
1
- 5
ZDEMO_ABAP_RAPT2
diff --git a/src/zdemo_abap_tab1.tabl.xml b/src/zdemo_abap_tab1.tabl.xml
index 610fe69..bb3611f 100644
--- a/src/zdemo_abap_tab1.tabl.xml
+++ b/src/zdemo_abap_tab1.tabl.xml
@@ -12,7 +12,6 @@
X
A
1
- 5
ZDEMO_ABAP_TAB1
diff --git a/src/zdemo_abap_tab2.tabl.xml b/src/zdemo_abap_tab2.tabl.xml
index d812188..ef04e39 100644
--- a/src/zdemo_abap_tab2.tabl.xml
+++ b/src/zdemo_abap_tab2.tabl.xml
@@ -12,7 +12,6 @@
X
A
1
- 5
ZDEMO_ABAP_TAB2
diff --git a/src/zdemo_abap_tabca.tabl.xml b/src/zdemo_abap_tabca.tabl.xml
index cd1bb97..a14546f 100644
--- a/src/zdemo_abap_tabca.tabl.xml
+++ b/src/zdemo_abap_tabca.tabl.xml
@@ -12,7 +12,6 @@
X
A
1
- 5
ZDEMO_ABAP_TABCA