Update main branch for ABAP Cloud only
This commit is contained in:
@@ -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.
|
- 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).
|
- 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).
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Basic Properties of Internal Tables
|
## Basic Properties of Internal Tables
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ Internal Tables ...
|
|||||||
- [Programming guidelines: Internal Tables (F1 docu for standard ABAP)](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenadmin_costs_dyn_mem_obj_guidl.htm)
|
- [Programming guidelines: Internal Tables (F1 docu for standard ABAP)](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenadmin_costs_dyn_mem_obj_guidl.htm)
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Table Keys in Internal Tables (Primary, Secondary, Standard, Empty)
|
## Table Keys in Internal Tables (Primary, Secondary, Standard, Empty)
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ Internal Tables ...
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
|
|
||||||
## Creating Internal Tables and Types
|
## Creating Internal Tables and Types
|
||||||
@@ -397,7 +397,7 @@ SELECT * FROM zdemo_abap_fli INTO TABLE @it_sel.
|
|||||||
SELECT * FROM zdemo_abap_fli INTO TABLE @FINAL(it_inline5).
|
SELECT * FROM zdemo_abap_fli INTO TABLE @FINAL(it_inline5).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Filling and Copying Internal Tables
|
## Filling and Copying Internal Tables
|
||||||
|
|
||||||
@@ -492,7 +492,7 @@ INSERT lv_struc INTO itab2 INDEX i.
|
|||||||
INSERT LINES OF itab2 INTO itab INDEX i.
|
INSERT LINES OF itab2 INTO itab INDEX i.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
**Adding lines using constructor expressions**
|
**Adding lines using constructor expressions**
|
||||||
|
|
||||||
@@ -614,7 +614,7 @@ MOVE-CORRESPONDING itab_nested1 TO itab_nested2 EXPANDING NESTED TABLES.
|
|||||||
MOVE-CORRESPONDING itab_nested1 TO itab_nested2 EXPANDING NESTED TABLES KEEPING TARGET LINES.
|
MOVE-CORRESPONDING itab_nested1 TO itab_nested2 EXPANDING NESTED TABLES KEEPING TARGET LINES.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Excursions with Internal Tables
|
### Excursions with Internal Tables
|
||||||
For more details on ABAP SQL, see the cheat sheet on [ABAP SQL](03_ABAP_SQL.md).
|
For more details on ABAP SQL, see the cheat sheet on [ABAP SQL](03_ABAP_SQL.md).
|
||||||
@@ -801,7 +801,7 @@ tables with a unique primary key, especially hashed tables.
|
|||||||
COLLECT VALUE dtype( comp1 = a comp2 = b ... ) INTO itab.
|
COLLECT VALUE dtype( comp1 = a comp2 = b ... ) INTO itab.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Reading from Internal Tables
|
## Reading from Internal Tables
|
||||||
|
|
||||||
@@ -869,7 +869,7 @@ at a performance cost. Imagine that your table contains many columns or
|
|||||||
nested components. In this case, it is better not to copy at all (although you can use
|
nested components. In this case, it is better not to copy at all (although you can use
|
||||||
the `TRANSPORTING` addition to restrict the fields to be copied).
|
the `TRANSPORTING` addition to restrict the fields to be copied).
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
*Reading a single line by index*
|
*Reading a single line by index*
|
||||||
|
|
||||||
@@ -922,7 +922,7 @@ DATA(line1) = VALUE #( itab[ 6 ] OPTIONAL ).
|
|||||||
DATA(line2) = VALUE #( itab[ 7 ] DEFAULT itab[ 8 ] ).
|
DATA(line2) = VALUE #( itab[ 7 ] DEFAULT itab[ 8 ] ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
*Reading single lines using table keys*
|
*Reading single lines using table keys*
|
||||||
|
|
||||||
@@ -984,7 +984,7 @@ READ TABLE it FROM sec_keys USING KEY sec_key INTO wa.
|
|||||||
READ TABLE it FROM sec_keys USING KEY sk INTO wa.
|
READ TABLE it FROM sec_keys USING KEY sk INTO wa.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
**Reading a single line using a free key**
|
**Reading a single line using a free key**
|
||||||
|
|
||||||
@@ -1017,7 +1017,7 @@ DATA(comp4) = dref->c.
|
|||||||
"Note: The syntax dref->*-c is also possible.
|
"Note: The syntax dref->*-c is also possible.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
**Checking the existence and the index of a line in an internal table**
|
**Checking the existence and the index of a line in an internal table**
|
||||||
|
|
||||||
@@ -1077,7 +1077,7 @@ DATA(idx) = line_index( it[ b = 2 ] ).
|
|||||||
DATA(number_of_lines) = lines( it ).
|
DATA(number_of_lines) = lines( it ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Processing Multiple Internal Table Lines Sequentially
|
## Processing Multiple Internal Table Lines Sequentially
|
||||||
|
|
||||||
@@ -1205,7 +1205,7 @@ DATA(tab2) = VALUE ttype( FOR ls IN it WHERE ( a < 7 )
|
|||||||
( a = ls-a b = ls-b + 5 ) ).
|
( a = ls-a b = ls-b + 5 ) ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Sorting Internal Tables
|
## Sorting Internal Tables
|
||||||
|
|
||||||
@@ -1272,7 +1272,7 @@ SORT itab BY a b ASCENDING c DESCENDING.
|
|||||||
SORT itab BY table_line.
|
SORT itab BY table_line.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Modifying Internal Table Content
|
## Modifying Internal Table Content
|
||||||
|
|
||||||
@@ -1373,7 +1373,7 @@ MODIFY it FROM line TRANSPORTING b c WHERE a < 5.
|
|||||||
> **💡 Note**<br>
|
> **💡 Note**<br>
|
||||||
> The system field `sy-subrc` is set to `0` if at least one line was changed. It is set to `4` if no lines were changed.
|
> The system field `sy-subrc` is set to `0` if at least one line was changed. It is set to `4` if no lines were changed.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Deleting Internal Table Content
|
## Deleting Internal Table Content
|
||||||
|
|
||||||
@@ -1471,7 +1471,7 @@ FREE it.
|
|||||||
"Assignment using the VALUE operator without entries in the parentheses
|
"Assignment using the VALUE operator without entries in the parentheses
|
||||||
it = VALUE #( ).
|
it = VALUE #( ).
|
||||||
```
|
```
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## More Information
|
## More Information
|
||||||
Topic [Internal
|
Topic [Internal
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ Structures ...
|
|||||||
- A [CDS entity](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencds_entity_glosry.htm) such as a [CDS view](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencds_view_glosry.htm) also represents a structured data type and can be used as such in ABAP programs (but not in the ABAP Dictionary). The same applies to [DDIC views](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenddic_view_glosry.htm) that are only available in [Standard ABAP](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenstandard_abap_glosry.htm).
|
- A [CDS entity](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencds_entity_glosry.htm) such as a [CDS view](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencds_view_glosry.htm) also represents a structured data type and can be used as such in ABAP programs (but not in the ABAP Dictionary). The same applies to [DDIC views](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenddic_view_glosry.htm) that are only available in [Standard ABAP](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenstandard_abap_glosry.htm).
|
||||||
- Structures and structured data types can also be defined in the public [visibility section](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenvisibility_section_glosry.htm) of [global classes](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenglobal_class_glosry.htm) or in [global interfaces](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenglobal_interface_glosry.htm) and then used globally.
|
- Structures and structured data types can also be defined in the public [visibility section](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenvisibility_section_glosry.htm) of [global classes](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenglobal_class_glosry.htm) or in [global interfaces](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenglobal_interface_glosry.htm) and then used globally.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Creating Structures and Structured Types
|
## Creating Structures and Structured Types
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ LOOP AT itab INTO DATA(wa_2).
|
|||||||
ENDLOOP.
|
ENDLOOP.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Variants of Structures
|
## Variants of Structures
|
||||||
|
|
||||||
@@ -263,7 +263,7 @@ that is, it refers to another structure. The following example has multiple subs
|
|||||||
>- [Work areas](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenwork_area_glosry.htm) of ABAP SQL statements cannot contain any deep components other than strings among others.
|
>- [Work areas](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenwork_area_glosry.htm) of ABAP SQL statements cannot contain any deep components other than strings among others.
|
||||||
>- Especially for assignments and comparisons of deep structures, the compatibility of the source and target structure must be taken into account.
|
>- Especially for assignments and comparisons of deep structures, the compatibility of the source and target structure must be taken into account.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Accessing (Components of) Structures
|
## Accessing (Components of) Structures
|
||||||
|
|
||||||
@@ -318,7 +318,7 @@ Nested components can be addressed using chaining:
|
|||||||
> **💡 Note**<br>
|
> **💡 Note**<br>
|
||||||
> The [`ASSIGN`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapassign_dynamic_components.htm) statement has special variants for dynamically accessing structure components.
|
> The [`ASSIGN`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapassign_dynamic_components.htm) statement has special variants for dynamically accessing structure components.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Populating Structures
|
## Populating Structures
|
||||||
|
|
||||||
@@ -350,7 +350,7 @@ address-street = `Vegetable Lane 11`.
|
|||||||
address-city = `349875 Botanica`.
|
address-city = `349875 Botanica`.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Using the VALUE Operator
|
### Using the VALUE Operator
|
||||||
|
|
||||||
@@ -404,7 +404,7 @@ DATA(str_ref) = NEW struc_nested( a = 1
|
|||||||
nested_2 = VALUE #( d = 4 e = 5 ) ).
|
nested_2 = VALUE #( d = 4 e = 5 ) ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Using the CORRESPONDING Operator and MOVE-CORRESPONDING Statements
|
### Using the CORRESPONDING Operator and MOVE-CORRESPONDING Statements
|
||||||
|
|
||||||
@@ -513,7 +513,7 @@ diff_deep_struc = CORRESPONDING #( APPENDING BASE ( diff_struc ) deep_struc ).
|
|||||||
diff_deep_struc = CORRESPONDING #( DEEP APPENDING BASE ( diff_struc ) deep_struc ).
|
diff_deep_struc = CORRESPONDING #( DEEP APPENDING BASE ( diff_struc ) deep_struc ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Clearing Structures
|
## Clearing Structures
|
||||||
You can reset individual components to their initial values and clear the
|
You can reset individual components to their initial values and clear the
|
||||||
@@ -527,7 +527,7 @@ CLEAR struc.
|
|||||||
struc = VALUE #( ).
|
struc = VALUE #( ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Processing Structures
|
## Processing Structures
|
||||||
Structures are primarily used to process data from tables. In this context, structures often take on the role of a [work area](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenwork_area_glosry.htm "Glossary Entry").
|
Structures are primarily used to process data from tables. In this context, structures often take on the role of a [work area](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenwork_area_glosry.htm "Glossary Entry").
|
||||||
@@ -658,7 +658,7 @@ APPEND struc TO itab.
|
|||||||
MODIFY TABLE itab FROM struc.
|
MODIFY TABLE itab FROM struc.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Excursion: Including Structures
|
## Excursion: Including Structures
|
||||||
|
|
||||||
@@ -701,7 +701,7 @@ TYPES BEGIN OF address_type.
|
|||||||
TYPES END OF address_type.
|
TYPES END OF address_type.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Executable Example
|
## Executable Example
|
||||||
[zcl_demo_abap_structures](./src/zcl_demo_abap_structures.clas.abap)
|
[zcl_demo_abap_structures](./src/zcl_demo_abap_structures.clas.abap)
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ Views](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm
|
|||||||
systems (that support the ABAP CDS characteristics).
|
systems (that support the ABAP CDS characteristics).
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Reading Data Using SELECT
|
## Reading Data Using SELECT
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ SELECT FROM source "What database table or view to read from
|
|||||||
processing the internal table entries. Find more information in the
|
processing the internal table entries. Find more information in the
|
||||||
ABAP cheat sheet [Internal Tables](01_Internal_Tables.md). In newer ABAP releases, the declaration operator [`FINAL`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenfinal_inline.htm) can be used to declare immutable variables.
|
ABAP cheat sheet [Internal Tables](01_Internal_Tables.md). In newer ABAP releases, the declaration operator [`FINAL`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenfinal_inline.htm) can be used to declare immutable variables.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Using SELECT for Multiple Purposes
|
### Using SELECT for Multiple Purposes
|
||||||
|
|
||||||
@@ -260,7 +260,7 @@ SELECT FROM dbtab
|
|||||||
|
|
||||||
ENDSELECT.
|
ENDSELECT.
|
||||||
```
|
```
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Clause Variations and Additions in SELECT Statements
|
### Clause Variations and Additions in SELECT Statements
|
||||||
|
|
||||||
@@ -454,7 +454,7 @@ SELECT FROM dbtab
|
|||||||
INTO TABLE NEW @DATA(dref).
|
INTO TABLE NEW @DATA(dref).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### More Clauses
|
### More Clauses
|
||||||
|
|
||||||
@@ -531,7 +531,7 @@ SELECT FROM dbtab
|
|||||||
INTO ...
|
INTO ...
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Operands and Expressions in ABAP SQL Statements
|
### Operands and Expressions in ABAP SQL Statements
|
||||||
|
|
||||||
@@ -1303,7 +1303,7 @@ SELECT *
|
|||||||
INTO TABLE @DATA(result).
|
INTO TABLE @DATA(result).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Changing Data in Database Tables
|
## Changing Data in Database Tables
|
||||||
|
|
||||||
@@ -1351,7 +1351,7 @@ INSERT dbtab FROM TABLE @itab ACCEPTING DUPLICATE KEYS.
|
|||||||
INSERT dbtab FROM ( SELECT ... ).
|
INSERT dbtab FROM ( SELECT ... ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Using [`UPDATE`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapupdate.htm)
|
### Using [`UPDATE`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapupdate.htm)
|
||||||
- Changes the content of one or more rows of a database table specified.
|
- Changes the content of one or more rows of a database table specified.
|
||||||
@@ -1403,7 +1403,7 @@ UPDATE dbtab FROM TABLE @ind_tab INDICATORS NOT SET STRUCTURE comp_ind.
|
|||||||
UPDATE dbtab SET comp2 = ... .
|
UPDATE dbtab SET comp2 = ... .
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Using [`MODIFY`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapmodify_dbtab.htm)
|
### Using [`MODIFY`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapmodify_dbtab.htm)
|
||||||
- Inserts one or more rows into a database table specified or overwrites existing ones.
|
- Inserts one or more rows into a database table specified or overwrites existing ones.
|
||||||
@@ -1432,7 +1432,7 @@ MODIFY dbtab FROM TABLE @( VALUE #( ( comp1 = ... comp2 = ... )
|
|||||||
MODIFY dbtab FROM ( SELECT ... ).
|
MODIFY dbtab FROM ( SELECT ... ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Using [`DELETE`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapdelete_dbtab.htm)
|
### Using [`DELETE`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapdelete_dbtab.htm)
|
||||||
- Deletes one or more rows from a database table specified.
|
- Deletes one or more rows from a database table specified.
|
||||||
@@ -1466,7 +1466,7 @@ DELETE dbtab FROM TABLE @( VALUE #( ( comp1 = ... )
|
|||||||
( comp1 = ... ) ) ).
|
( comp1 = ... ) ) ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## More Information
|
## More Information
|
||||||
- Note that ABAP SQL statements offer syntax options for dynamic programming. For example, you can specify the data source to read from dynamically. See more information in the ABAP Keyword Documentation or the [ABAP cheat sheet on dynamic programming](06_Dynamic_Programming.md).
|
- Note that ABAP SQL statements offer syntax options for dynamic programming. For example, you can specify the data source to read from dynamically. See more information in the ABAP Keyword Documentation or the [ABAP cheat sheet on dynamic programming](06_Dynamic_Programming.md).
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ Classes ...
|
|||||||
that determine the behavior of an object
|
that determine the behavior of an object
|
||||||
- [Events](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenevent_glosry.htm "Glossary Entry") to trigger the processing of ABAP code
|
- [Events](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenevent_glosry.htm "Glossary Entry") to trigger the processing of ABAP code
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Creating Classes
|
### Creating Classes
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ of the class itself, and of its
|
|||||||
be instantiated in methods of the class itself or of its friends. Hence,
|
be instantiated in methods of the class itself or of its friends. Hence,
|
||||||
it cannot be instantiated as an inherited component of subclasses.
|
it cannot be instantiated as an inherited component of subclasses.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Visibility of Components
|
### Visibility of Components
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ CLASS local_class DEFINITION.
|
|||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Defining Components
|
### Defining Components
|
||||||
|
|
||||||
@@ -278,7 +278,7 @@ CLASS local_class IMPLEMENTATION.
|
|||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
**Methods**
|
**Methods**
|
||||||
|
|
||||||
@@ -357,7 +357,7 @@ In the simplest form, methods can have no parameter at all. Apart from that, met
|
|||||||
However, when using this addition, as the name implies, a default
|
However, when using this addition, as the name implies, a default
|
||||||
value is set.
|
value is set.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
**Constructors**
|
**Constructors**
|
||||||
|
|
||||||
@@ -436,7 +436,7 @@ CLASS local_class IMPLEMENTATION.
|
|||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Working with Objects and Components
|
## Working with Objects and Components
|
||||||
|
|
||||||
@@ -692,7 +692,7 @@ METHOD me_ref.
|
|||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Notes on Inheritance
|
## Notes on Inheritance
|
||||||
|
|
||||||
@@ -714,7 +714,7 @@ ENDMETHOD.
|
|||||||
[`FINAL`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapmethods_abstract_final.htm#!ABAP_ADDITION_2@2@)
|
[`FINAL`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapmethods_abstract_final.htm#!ABAP_ADDITION_2@2@)
|
||||||
(e. g. `CLASS global_class DEFINITION PUBLIC FINAL CREATE PUBLIC. ...`).
|
(e. g. `CLASS global_class DEFINITION PUBLIC FINAL CREATE PUBLIC. ...`).
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
**Excursion: Additions `ABSTRACT` and `FINAL`**
|
**Excursion: Additions `ABSTRACT` and `FINAL`**
|
||||||
- Both classes and methods can be defined with the additions `ABSTRACT` and `FINAL`.
|
- Both classes and methods can be defined with the additions `ABSTRACT` and `FINAL`.
|
||||||
@@ -746,7 +746,7 @@ CLASS cls2 IMPLEMENTATION.
|
|||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
**Redefining Methods**
|
**Redefining Methods**
|
||||||
|
|
||||||
@@ -769,7 +769,7 @@ ENDCLASS.
|
|||||||
> - Regarding the static constructor: When calling a subclass for the first time, the preceding static constructors of all of the entire inheritance tree must have been called first.
|
> - Regarding the static constructor: When calling a subclass for the first time, the preceding static constructors of all of the entire inheritance tree must have been called first.
|
||||||
> - More information [here](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abeninheritance_constructors.htm).
|
> - More information [here](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abeninheritance_constructors.htm).
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Notes on Polymorphism and Casting
|
## Notes on Polymorphism and Casting
|
||||||
|
|
||||||
@@ -885,7 +885,7 @@ DATA(rtti_d) = CAST cl_abap_structdescr(
|
|||||||
)->components.
|
)->components.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Notes on Interfaces
|
## Notes on Interfaces
|
||||||
|
|
||||||
@@ -911,7 +911,7 @@ Interfaces ...
|
|||||||
`CLASS-METHODS`, are possible. Constructors are not
|
`CLASS-METHODS`, are possible. Constructors are not
|
||||||
possible.
|
possible.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
Defining interfaces:
|
Defining interfaces:
|
||||||
- Can be done either globally in the repository or locally in an ABAP program.
|
- Can be done either globally in the repository or locally in an ABAP program.
|
||||||
@@ -1063,7 +1063,7 @@ i_ref = NEW class( ).
|
|||||||
... intf=>const ...
|
... intf=>const ...
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Additional Notes
|
## Additional Notes
|
||||||
|
|
||||||
@@ -1095,7 +1095,7 @@ CLASS lo_class DEFINITION CREATE PRIVATE FRIENDS other_class ... .
|
|||||||
CLASS global_class DEFINITION CREATE PUBLIC FRIENDS other_global_class ... .
|
CLASS global_class DEFINITION CREATE PUBLIC FRIENDS other_global_class ... .
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
@@ -1151,7 +1151,7 @@ SET HANDLER handler3.
|
|||||||
"Note that multiple handler methods can be specified.
|
"Note that multiple handler methods can be specified.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Excursion: Factory Methods and Singletons as Design Patterns
|
### Excursion: Factory Methods and Singletons as Design Patterns
|
||||||
|
|
||||||
@@ -1217,7 +1217,7 @@ DATA obj_factory TYPE REF TO class.
|
|||||||
obj_factory = class=>factory_method( par = ... ).
|
obj_factory = class=>factory_method( par = ... ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## More Information
|
## More Information
|
||||||
You can check the subtopics of
|
You can check the subtopics of
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ implies that the data object is initialized. However, for some
|
|||||||
constructor operators, there is an addition with which the
|
constructor operators, there is an addition with which the
|
||||||
initialization can be avoided.
|
initialization can be avoided.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## VALUE
|
## VALUE
|
||||||
|
|
||||||
@@ -273,7 +273,7 @@ also valid for other constructor expressions further down but not
|
|||||||
necessarily mentioned explicitly. See the details on the syntactical
|
necessarily mentioned explicitly. See the details on the syntactical
|
||||||
options of the constructor operators in the ABAP Keyword Documentation.
|
options of the constructor operators in the ABAP Keyword Documentation.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## CORRESPONDING
|
## CORRESPONDING
|
||||||
|
|
||||||
@@ -352,7 +352,7 @@ two statements are not the same:
|
|||||||
>MOVE-CORRESPONDING struc1 TO struc2.
|
>MOVE-CORRESPONDING struc1 TO struc2.
|
||||||
>```
|
>```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## NEW
|
## NEW
|
||||||
|
|
||||||
@@ -477,7 +477,7 @@ DATA(oref3) = NEW cl2( p1 = ... p2 = ... ).
|
|||||||
... NEW some_class( ... )->attr ...
|
... NEW some_class( ... )->attr ...
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## CONV
|
## CONV
|
||||||
|
|
||||||
@@ -532,7 +532,7 @@ DATA(f) = `hallo`.
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## EXACT
|
## EXACT
|
||||||
|
|
||||||
@@ -568,7 +568,7 @@ TRY.
|
|||||||
ENDTRY.
|
ENDTRY.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## REF
|
## REF
|
||||||
|
|
||||||
@@ -613,7 +613,7 @@ DATA(oref_a) = NEW some_class( ).
|
|||||||
DATA(oref_b) = REF #( oref_a ).
|
DATA(oref_b) = REF #( oref_a ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## CAST
|
## CAST
|
||||||
|
|
||||||
@@ -650,7 +650,7 @@ DATA(methods) = CAST cl_abap_objectdescr(
|
|||||||
cl_abap_objectdescr=>describe_by_name( 'LOCAL_CLASS' ) )->methods.
|
cl_abap_objectdescr=>describe_by_name( 'LOCAL_CLASS' ) )->methods.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## COND
|
## COND
|
||||||
|
|
||||||
@@ -679,7 +679,7 @@ DATA(b) = COND #( WHEN a BETWEEN 1 AND 3 THEN w
|
|||||||
ELSE z ).
|
ELSE z ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## SWITCH
|
## SWITCH
|
||||||
|
|
||||||
@@ -699,7 +699,7 @@ DATA(b) = SWITCH #( a
|
|||||||
ELSE z ).
|
ELSE z ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## FILTER
|
## FILTER
|
||||||
|
|
||||||
@@ -768,7 +768,7 @@ DATA(f10) = FILTER #( itab2 IN filter_tab2 USING KEY line WHERE num = table_line
|
|||||||
DATA(f11) = FILTER #( itab2 USING KEY sec_key EXCEPT IN filter_tab2 WHERE num = table_line ).
|
DATA(f11) = FILTER #( itab2 USING KEY sec_key EXCEPT IN filter_tab2 WHERE num = table_line ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## REDUCE
|
## REDUCE
|
||||||
|
|
||||||
@@ -800,7 +800,7 @@ DATA(sum) = REDUCE i( INIT s = 0
|
|||||||
>- Once the loop has finished, the target variable is assigned the
|
>- Once the loop has finished, the target variable is assigned the
|
||||||
resulting value.
|
resulting value.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Iteration Expressions with FOR
|
## Iteration Expressions with FOR
|
||||||
|
|
||||||
@@ -897,7 +897,7 @@ TYPES t_type LIKE itab.
|
|||||||
compZ = wa3-comp3 ) ).
|
compZ = wa3-comp3 ) ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## LET Expressions
|
## LET Expressions
|
||||||
|
|
||||||
@@ -929,7 +929,7 @@ DATA(a) = COND #( LET b = c IN
|
|||||||
ELSE ... ).
|
ELSE ... ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Executable Example
|
## Executable Example
|
||||||
[zcl_demo_abap_constructor_expr](./src/zcl_demo_abap_constructor_expr.clas.abap)
|
[zcl_demo_abap_constructor_expr](./src/zcl_demo_abap_constructor_expr.clas.abap)
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
that include dynamic programming features may be difficult.
|
that include dynamic programming features may be difficult.
|
||||||
|
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Excursion: Field Symbols and Data References
|
## Excursion: Field Symbols and Data References
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ LOOP AT itab ASSIGNING FIELD-SYMBOL(<fs2>).
|
|||||||
ENDLOOP.
|
ENDLOOP.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Data References
|
### 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
|
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").
|
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").
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Dynamic ABAP Statements
|
## 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.
|
"The addition EXCEPTION-TABLE for exceptions is not dealt with here.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Runtime Type Services (RTTS)
|
## 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"),
|
[ADT](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenadt_glosry.htm "Glossary Entry"),
|
||||||
for more details.
|
for more details.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Getting Type Information at Runtime
|
### 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').
|
CREATE OBJECT oref4abs TYPE ('\CLASS=ZCL_DEMO_ABAP_DYNAMIC_PROG').
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Dynamically Creating Data Types at Runtime
|
### Dynamically Creating Data Types at Runtime
|
||||||
You can create data types at program runtime using methods of the type description classes of RTTS.
|
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' ).
|
DATA(tdo_ref_4) = cl_abap_refdescr=>get_by_name( 'ZCL_DEMO_ABAP_DYNAMIC_PROG' ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Dynamically Creating Data Objects at Runtime
|
### 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.
|
CREATE DATA dref_cr TYPE HANDLE tdo_ref.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## More Information
|
## 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).
|
- 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).
|
||||||
|
|||||||
@@ -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
|
corresponding ABAP statements, or even more. The return value of string functions
|
||||||
that return character strings is always of type `string`.
|
that return character strings is always of type `string`.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Data Types for Character Strings
|
## 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
|
forms that should not exceed a certain length. If limiting a string
|
||||||
is not relevant, text strings are a good choice.
|
is not relevant, text strings are a good choice.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Declaring Character-Like Data Objects
|
## Declaring Character-Like Data Objects
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ DATA char(4) TYPE c.
|
|||||||
DATA char_len_one TYPE c.
|
DATA char_len_one TYPE c.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Assigning Values
|
## 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)
|
differences](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenliteral_operator.htm)
|
||||||
to `&&`.
|
to `&&`.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## String Templates
|
## String Templates
|
||||||
- Using string templates, you can construct strings very elegantly from
|
- Using string templates, you can construct strings very elegantly from
|
||||||
@@ -311,7 +311,7 @@ s1 = |{ CONV decfloat34( - 1 / 3 ) DECIMALS = 3 }|. "'-0.333'
|
|||||||
> **💡 Note**<br>
|
> **💡 Note**<br>
|
||||||
> Escape `\|{}` in string templates using `\`, i. e. `\\` means `\`.
|
> Escape `\|{}` in string templates using `\`, i. e. `\\` means `\`.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Determining the Length of Strings
|
## Determining the Length of Strings
|
||||||
|
|
||||||
@@ -333,7 +333,7 @@ len_c = numofchar( 'abc ' ). "3
|
|||||||
len_str = numofchar( `abc ` ). "3
|
len_str = numofchar( `abc ` ). "3
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Concatenating Strings
|
## Concatenating Strings
|
||||||
|
|
||||||
@@ -379,7 +379,7 @@ s1 = concat_lines_of( table = itab ). "Without separator
|
|||||||
s1 = concat_lines_of( table = itab sep = ` ` ). "With separator
|
s1 = concat_lines_of( table = itab sep = ` ` ). "With separator
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Splitting Strings
|
## 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
|
s2 = segment( val = s1 index = 2 sep = `,` ). "world
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Modifying Strings
|
## Modifying Strings
|
||||||
**Transforming to Lowercase and Uppercase**
|
**Transforming to Lowercase and Uppercase**
|
||||||
@@ -609,7 +609,7 @@ OVERLAY txt1 WITH txt2 ONLY 'ab'.
|
|||||||
"txt1: z.x.c.Z.x.c.A
|
"txt1: z.x.c.Z.x.c.A
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Processing Substrings
|
## Processing Substrings
|
||||||
|
|
||||||
@@ -694,7 +694,7 @@ s2 = substring_from( val = s1 sub = `a3` ). "a3bb4
|
|||||||
s2 = substring_to( val = s1 sub = `3b` ). "aa1bb2aa3b
|
s2 = substring_to( val = s1 sub = `3b` ). "aa1bb2aa3b
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Searching and Replacing
|
## Searching and Replacing
|
||||||
|
|
||||||
@@ -715,7 +715,7 @@ on single characters only or more complex, pattern-based
|
|||||||
operations on character sequences using [PCRE regular
|
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").
|
expressions](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenpcre_regex_glosry.htm "Glossary Entry").
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Searching for Specific Characters
|
### Searching for Specific Characters
|
||||||
|
|
||||||
@@ -807,7 +807,7 @@ res = count_any_not_of( val = str sub = `Piecs ofak.` ). "0
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Replacing Specific Characters in Strings
|
### 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.
|
TRANSLATE s1 USING `_.a#g+`. "...#bc.def.....+hi.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Searching for Substrings in Strings (and Tables)
|
### Searching for Substrings in Strings (and Tables)
|
||||||
|
|
||||||
@@ -1168,7 +1168,7 @@ TRY.
|
|||||||
ENDTRY.
|
ENDTRY.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Replacing Substrings in Strings (and Tables)
|
### 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")
|
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.
|
anymore, they are obsolete.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Simple Pattern-Based Searching Using Comparison Operators
|
### 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)
|
IF s1 NP `i+`. ... "true; sy-fdpos = 11 (length of searched string)
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Complex Searching and Replacing Using Regular Expressions
|
### Complex Searching and Replacing Using Regular Expressions
|
||||||
|
|
||||||
@@ -1517,7 +1517,7 @@ Anchors and Positions
|
|||||||
| `\b` | Start or end of word | 1. `\ba.` <br>2. `\Dd\b` <br>3. `\b.d\b` | abcd a12d ed | 1. <ins>**ab**</ins>cd <ins>**a1**</ins>2d ed <br>2. ab<ins>**cd**</ins> a12d <ins>**ed**</ins> <br> 3. abcd a12d <ins>**ed**</ins> | 1. ab<ins>**cd**</ins> a1<ins>**2d**</ins> ed <br> 2. abcd a1<ins>**2d**</ins> ed <br> 3. <ins>**abcd**</ins> <ins>**a12d**</ins> ed |
|
| `\b` | Start or end of word | 1. `\ba.` <br>2. `\Dd\b` <br>3. `\b.d\b` | abcd a12d ed | 1. <ins>**ab**</ins>cd <ins>**a1**</ins>2d ed <br>2. ab<ins>**cd**</ins> a12d <ins>**ed**</ins> <br> 3. abcd a12d <ins>**ed**</ins> | 1. ab<ins>**cd**</ins> a1<ins>**2d**</ins> ed <br> 2. abcd a1<ins>**2d**</ins> ed <br> 3. <ins>**abcd**</ins> <ins>**a12d**</ins> ed |
|
||||||
| `\B` | Negation of `\b`, not at the start or end of words | `\Be\B` | see an elefant | s<ins>**e**</ins>e an el<ins>**e**</ins>fant | s<ins>**ee**</ins> an <ins>**e**</ins>lefant |
|
| `\B` | Negation of `\b`, not at the start or end of words | `\Be\B` | see an elefant | s<ins>**e**</ins>e an el<ins>**e**</ins>fant | s<ins>**ee**</ins> an <ins>**e**</ins>lefant |
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
#### Searching Using Regular Expressions
|
#### 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
|
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
|
IGNORING CASE MATCH LINE DATA(d) MATCH OFFSET DATA(e) MATCH LENGTH DATA(f). "d: 1, e: 21, f: 2
|
||||||
```
|
```
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
##### Excursion: System Classes for Regular Expressions
|
##### 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( ).
|
ignore_case = abap_true )->create_matcher( text = str )->find_all( ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
#### Replacing Using Regular Expressions
|
#### 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
|
REPLACE PCRE `(.*?)PP(.*)` IN s1 WITH `$2#$1` IGNORING CASE. "pc app#ab a
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Executable Example
|
## Executable Example
|
||||||
[zcl_demo_abap_string_proc](./src/zcl_demo_abap_string_proc.clas.abap)
|
[zcl_demo_abap_string_proc](./src/zcl_demo_abap_string_proc.clas.abap)
|
||||||
|
|||||||
@@ -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
|
an ABAP program using ABAP EML (which this cheat sheet and the examples
|
||||||
focus on).
|
focus on).
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## ABAP Behavior Pools (ABP)
|
## 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")
|
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).
|
to save data from the transactional buffer to the database).
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### RAP Handler Classes and Methods
|
### RAP Handler Classes and Methods
|
||||||
|
|
||||||
@@ -342,7 +342,7 @@ METHODS some_action FOR MODIFY
|
|||||||
UI if something goes wrong to inform the user.
|
UI if something goes wrong to inform the user.
|
||||||
|
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### RAP Saver Class and Saver Methods
|
### RAP Saver Class and Saver Methods
|
||||||
|
|
||||||
@@ -403,7 +403,7 @@ CLASS lsc_bdef DEFINITION INHERITING FROM cl_abap_behavior_saver.
|
|||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## BDEF Derived Types
|
## BDEF Derived Types
|
||||||
|
|
||||||
@@ -508,7 +508,7 @@ DATA rep TYPE RESPONSE FOR REPORTED entity.
|
|||||||
> **💡 Note**<br>
|
> **💡 Note**<br>
|
||||||
> Some of the derived types can only be created and accessed in implementation classes.
|
> Some of the derived types can only be created and accessed in implementation classes.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Components of BDEF Derived Types
|
### Components of BDEF Derived Types
|
||||||
|
|
||||||
@@ -606,7 +606,7 @@ Bullet points on selected `%` components:
|
|||||||
`if_abap_behv=>mk-off`, the values of these fields
|
`if_abap_behv=>mk-off`, the values of these fields
|
||||||
are not returned in the result.
|
are not returned in the result.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## EML Syntax
|
## EML Syntax
|
||||||
|
|
||||||
@@ -825,7 +825,7 @@ MODIFY ENTITIES OF root_ent
|
|||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### EML Syntax for Reading Operations
|
### EML Syntax for Reading Operations
|
||||||
|
|
||||||
@@ -886,7 +886,7 @@ READ ENTITIES OF root_ent
|
|||||||
LINK DATA(links2).
|
LINK DATA(links2).
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
#### Dynamic Forms of EML Statements
|
#### Dynamic Forms of EML Statements
|
||||||
|
|
||||||
@@ -983,7 +983,7 @@ op_tab = VALUE #(
|
|||||||
|
|
||||||
READ ENTITIES OPERATIONS op_tab.
|
READ ENTITIES OPERATIONS op_tab.
|
||||||
```
|
```
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Persisting to the Database
|
### Persisting to the Database
|
||||||
|
|
||||||
@@ -1029,7 +1029,7 @@ IF sy-subrc <> 0.
|
|||||||
ENDIF.
|
ENDIF.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### EML Statements in ABAP Behavior Pools
|
### EML Statements in ABAP Behavior Pools
|
||||||
|
|
||||||
@@ -1058,7 +1058,7 @@ MODIFY ENTITIES OF root_ent IN LOCAL MODE
|
|||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## RAP Excursions
|
## RAP Excursions
|
||||||
|
|
||||||
@@ -1351,7 +1351,7 @@ The following restrictions apply to operations and/or statements in the individu
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## More Information
|
## More Information
|
||||||
|
|
||||||
@@ -1366,7 +1366,7 @@ The following restrictions apply to operations and/or statements in the individu
|
|||||||
consistency and reliability
|
consistency and reliability
|
||||||
|
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Executable Examples
|
## Executable Examples
|
||||||
This cheat sheet is supported by different executable examples demonstrating various scenarios:
|
This cheat sheet is supported by different executable examples demonstrating various scenarios:
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ learn some additional syntax and then you can start right away.
|
|||||||
> **💡 Note**<br>
|
> **💡 Note**<br>
|
||||||
> 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.
|
> 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.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## SQL Hierarchies
|
## 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
|
The following topics show you step-by-step how SQL hierarchies can be
|
||||||
created and accessed.
|
created and accessed.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Creating SQL Hierarchies
|
## 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,
|
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.
|
involving more ABAP, until we do not use any CDS more in the end.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### ABAP SQL Hierarchy Generator HIERARCHY
|
### ABAP SQL Hierarchy Generator HIERARCHY
|
||||||
The ABAP SQL [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
|
following section and turn directly to the hierarchy navigators if you
|
||||||
are not too interested in this syntactic gimmicks.
|
are not too interested in this syntactic gimmicks.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### ABAP CTE Hierarchies
|
### ABAP CTE Hierarchies
|
||||||
|
|
||||||
@@ -489,7 +489,7 @@ hierarchy association. Running
|
|||||||
`CL_DEMO_SQL_HIERARCHIES` shows that all
|
`CL_DEMO_SQL_HIERARCHIES` shows that all
|
||||||
assertions are fulfilled.
|
assertions are fulfilled.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Hierarchy Navigators
|
## 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),
|
[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.
|
where this is also shown.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Hierarchy Node Navigator HIERARCHY_DESCENDANTS
|
### 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` - not shown here - allows you to restrict the
|
||||||
distance to the respective start node.
|
distance to the respective start node.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Hierarchy Node Navigator HIERARCHY_ANCESTORS
|
### 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
|
easily extract further information like the number of ancestors and so
|
||||||
on.
|
on.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Hierarchy Node Navigator HIERARCHY_SIBLINGS
|
### Hierarchy Node Navigator HIERARCHY_SIBLINGS
|
||||||
|
|
||||||
@@ -616,7 +616,7 @@ the respective start node. Running
|
|||||||
`CL_DEMO_SQL_HIERARCHIES`, where we start with
|
`CL_DEMO_SQL_HIERARCHIES`, where we start with
|
||||||
a node that definitely has some siblings, shows the result.
|
a node that definitely has some siblings, shows the result.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Hierarchy Aggregate Navigators
|
### 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
|
result. It also shows the result of the joined data source, where you
|
||||||
can check that the calculated values are correct.
|
can check that the calculated values are correct.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## More Information
|
## 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).
|
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).
|
||||||
|
|||||||
@@ -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
|
and its members are assigned to `member` and are available in
|
||||||
the member loop.
|
the member loop.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Grouping by More than One Column
|
## 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
|
To access the members of the groups, the exact same member loop can be
|
||||||
inserted as when grouping by one column.
|
inserted as when grouping by one column.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Group Key Binding when Grouping by One Column
|
## Group Key Binding when Grouping by One Column
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ LOOP AT spfli_tab INTO wa
|
|||||||
ENDLOOP.
|
ENDLOOP.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Group Key Binding when Grouping by More than One Column
|
## Group Key Binding when Grouping by More than One Column
|
||||||
Finally, the group key binding for structured group keys:
|
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
|
[`GROUP
|
||||||
SIZE`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaploop_at_itab_group_by_key.htm).
|
SIZE`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaploop_at_itab_group_by_key.htm).
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Executable Example
|
## Executable Example
|
||||||
[zcl_demo_abap_sql_group_by](./src/zcl_demo_abap_sql_group_by.clas.abap)
|
[zcl_demo_abap_sql_group_by](./src/zcl_demo_abap_sql_group_by.clas.abap)
|
||||||
|
|||||||
14
12_AMDP.md
14
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
|
>- 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").
|
(ADT)](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenadt_glosry.htm "Glossary Entry").
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## AMDP Classes
|
## AMDP Classes
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ CLASS cl_some_amdp_class DEFINITION
|
|||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## AMDP Methods
|
## AMDP Methods
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ PRIVATE SECTION.
|
|||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## AMDP Procedures
|
## AMDP Procedures
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ Note:
|
|||||||
and implementation parts. Check the ABAP Keyword Documentation for
|
and implementation parts. Check the ABAP Keyword Documentation for
|
||||||
more details as touched on further down.
|
more details as touched on further down.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## AMDP Functions
|
## AMDP Functions
|
||||||
|
|
||||||
@@ -304,7 +304,7 @@ ENDMETHOD.
|
|||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### CDS Table Functions
|
### 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
|
You can then use the CDS table function as source for a
|
||||||
`SELECT` statement, for example: `SELECT * FROM some_ddl_source INTO ...`.
|
`SELECT` statement, for example: `SELECT * FROM some_ddl_source INTO ...`.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## More Information
|
## 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
|
The client handling is not dealt with in this cheat sheet and not
|
||||||
relevant in the executable example.
|
relevant in the executable example.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Executable Example
|
## Executable Example
|
||||||
[zcl_demo_abap_amdp](./src/zcl_demo_abap_amdp.clas.abap)
|
[zcl_demo_abap_amdp](./src/zcl_demo_abap_amdp.clas.abap)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ ELSE.
|
|||||||
ENDIF.
|
ENDIF.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Expressions and Functions for Conditions
|
## 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).
|
- 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**<br>
|
> **💡 Note**<br>
|
||||||
> Logical expressions and functions can also be used in other ABAP statements.
|
> Logical expressions and functions can also be used in other ABAP statements.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Control Structures
|
## 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
|
> 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.
|
> logical expressions might partly be redundant.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
#### Excursion: `COND` Operator
|
#### Excursion: `COND` Operator
|
||||||
|
|
||||||
@@ -311,7 +311,7 @@ ENDIF.
|
|||||||
ELSE resultn ) ...
|
ELSE resultn ) ...
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### `CASE`: Case Distinctions
|
### `CASE`: Case Distinctions
|
||||||
|
|
||||||
@@ -350,7 +350,7 @@ CASE TYPE OF oref.
|
|||||||
ENDCASE.
|
ENDCASE.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
#### Excursion: `SWITCH` Operator
|
#### Excursion: `SWITCH` Operator
|
||||||
|
|
||||||
@@ -365,7 +365,7 @@ The conditional operator [`SWITCH`](https://help.sap.com/doc/abapdocu_cp_index_h
|
|||||||
ELSE resultn ) ...
|
ELSE resultn ) ...
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Loops
|
### 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.
|
- The value of the system field `sy-index` within the statement block contains the number of previous loop passes including the current pass.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
#### Interrupting and Exiting Loops
|
#### 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.
|
> - [`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.
|
> - `EXIT` and `CHECK` might also be used for exiting procedures. However, their use inside loops is recommended.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
#### `WHILE`: Conditional Loops
|
#### `WHILE`: Conditional Loops
|
||||||
|
|
||||||
@@ -419,7 +419,7 @@ WHILE log_exp.
|
|||||||
ENDWHILE.
|
ENDWHILE.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
#### Loops Across Tables
|
#### 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.
|
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.
|
- 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.
|
- [`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.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Calling Procedures
|
## Calling Procedures
|
||||||
|
|
||||||
@@ -440,7 +440,7 @@ However, ...
|
|||||||
|
|
||||||
Regarding the exiting of procedures, note the hint mentioned above. The use of `RETURN` is recommended.
|
Regarding the exiting of procedures, note the hint mentioned above. The use of `RETURN` is recommended.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Handling Exceptions
|
## Handling Exceptions
|
||||||
- [Exceptions](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenexception_glosry.htm) ...
|
- [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 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).
|
> - 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).
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
#### Notes on Exception Classes
|
#### Notes on Exception Classes
|
||||||
- To distinguish exception classes from *regular* classes, use the naming convention `CX` as prefix and not `CL`.
|
- 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.
|
> - 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.
|
> - 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.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Raising Exceptions
|
### Raising Exceptions
|
||||||
|
|
||||||
@@ -630,7 +630,7 @@ RAISE EXCEPTION TYPE cx_sy_zerodivide.
|
|||||||
ELSE THROW cx_some_error( ) ).
|
ELSE THROW cx_some_error( ) ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Excursion: Runtime Errors and Terminating Programs
|
## 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.
|
- 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.
|
> - 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.
|
> - 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.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Executable Example
|
## Executable Example
|
||||||
[zcl_demo_abap_prog_flow_logic](./src/zcl_demo_abap_prog_flow_logic.clas.abap)
|
[zcl_demo_abap_prog_flow_logic](./src/zcl_demo_abap_prog_flow_logic.clas.abap)
|
||||||
|
|||||||
@@ -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, 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).
|
- 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).
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## High-Level Steps for ABAP Unit Tests
|
## High-Level Steps for ABAP Unit Tests
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ This cheat sheet contains basic information about [unit testing](https://help.sa
|
|||||||
> **💡 Note**<br>
|
> **💡 Note**<br>
|
||||||
> 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.
|
> 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.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Creating Test Classes
|
## Creating Test Classes
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ CLASS ltd_test_double IMPLEMENTATION.
|
|||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Creating and Implementing Test Methods
|
## Creating and Implementing Test Methods
|
||||||
|
|
||||||
@@ -313,7 +313,7 @@ CLASS ltc_test_class IMPLEMENTATION.
|
|||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Special Methods for Implementing the Test Fixture
|
### 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.
|
- 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**<br>
|
> **💡 Note**<br>
|
||||||
> You can also specify helper methods, for example, for recurring tasks such as the assertions.
|
> You can also specify helper methods, for example, for recurring tasks such as the assertions.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Handling Dependencies
|
## 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.
|
- 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 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.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Test Seams
|
### Test Seams
|
||||||
- Seams are sections of the production source code that can be dynamically included or replaced.
|
- Seams are sections of the production source code that can be dynamically included or replaced.
|
||||||
@@ -481,7 +481,7 @@ END-TEST-INJECTION.
|
|||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Running and Evaluating ABAP Unit Tests
|
## 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).
|
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).
|
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).
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## More Information
|
## 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)
|
- [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)
|
- [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)
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Executable Example
|
## Executable Example
|
||||||
[zcl_demo_abap_unit_test](./src/zcl_demo_abap_unit_test.clas.abap)
|
[zcl_demo_abap_unit_test](./src/zcl_demo_abap_unit_test.clas.abap)
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ Data objects:
|
|||||||
> **💡 Note**<br>
|
> **💡 Note**<br>
|
||||||
> There are several differentations that further distinguish and characterize data types and objects. See [here](#glossary-terms-in-a-nutshell).
|
> There are several differentations that further distinguish and characterize data types and objects. See [here](#glossary-terms-in-a-nutshell).
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## ABAP Data Types
|
## 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.
|
> - 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.
|
> - 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.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Complex Data Types
|
### Complex Data Types
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ For an overview, see the [ABAP Type Hierarchy](https://help.sap.com/doc/abapdocu
|
|||||||
> **💡 Note**<br>
|
> **💡 Note**<br>
|
||||||
> 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.
|
> 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.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Reference Types
|
### 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).
|
- 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).
|
> 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.
|
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.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Declaring Data Types
|
### 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.
|
TYPES tr_like_table_ref LIKE TABLE OF REF TO itab_str.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Data Objects
|
## 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.
|
DATA dref_tab_str LIKE TABLE OF REF TO do_some_string.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Assigning Values to Data Objects
|
### 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.
|
str_a2 = some_itab[ 2 ]-carrname.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Creating Data Objects Using Inline Declaration
|
### 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).
|
SELECT * FROM zdemo_abap_carr INTO TABLE NEW @DATA(itab_ref).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Assigning References to Data Reference Variables
|
### Assigning References to Data Reference Variables
|
||||||
|
|
||||||
@@ -766,7 +766,6 @@ dref_1_i = CAST #( dref_3_data ).
|
|||||||
TRY.
|
TRY.
|
||||||
dref_2_str = CAST #( dref_3_data ).
|
dref_2_str = CAST #( dref_3_data ).
|
||||||
CATCH cx_sy_move_cast_error INTO DATA(e).
|
CATCH cx_sy_move_cast_error INTO DATA(e).
|
||||||
output->display( input = e->get_text( ) name = `e->get_text( )` ).
|
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
"Old syntax using the ?= operator
|
"Old syntax using the ?= operator
|
||||||
@@ -777,7 +776,7 @@ dref_1_i ?= dref_3_data.
|
|||||||
dref_1_i = CAST #( dref_6_i ).
|
dref_1_i = CAST #( dref_6_i ).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Creating Anonymous Data Objects
|
### Creating Anonymous Data Objects
|
||||||
|
|
||||||
@@ -872,7 +871,7 @@ SELECT *
|
|||||||
INTO TABLE NEW @DATA(dref_14_inline).
|
INTO TABLE NEW @DATA(dref_14_inline).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Constants and Immutable Variables
|
### Constants and Immutable Variables
|
||||||
|
|
||||||
@@ -912,7 +911,7 @@ ENDLOOP.
|
|||||||
SELECT * FROM zdemo_abap_carr INTO TABLE @FINAL(itab_final_inl).
|
SELECT * FROM zdemo_abap_carr INTO TABLE @FINAL(itab_final_inl).
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Type Conversion
|
## 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.
|
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-`
|
"Result: i2str: `10-`
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Terms Related to Data Types and Objects in a Nutshell
|
## 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
|
"Unnamed data objects
|
||||||
"Literal that is output. It cannot be addressed via a dedicated name.
|
"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
|
"Anonymous data object created using the NEW operator
|
||||||
"Can be addressed using reference variables or field symbols.
|
"Can be addressed using reference variables or field symbols.
|
||||||
@@ -1192,7 +1191,7 @@ DATA itab_str TYPE string_table.
|
|||||||
"some_number = itab_str.
|
"some_number = itab_str.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Notes on the Declaration Context
|
## 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.`).
|
- 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.
|
- Note the following trap: Local declarations hide global declarations of the same name.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Excursions
|
## Excursions
|
||||||
### Enumerated Types and Objects
|
### 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).
|
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).
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Getting Type Information and Creating Types at Runtime
|
### 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")).
|
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")).
|
||||||
|
|||||||
@@ -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).
|
⚠️ 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.
|
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.
|
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
|
- 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
|
- 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
|
- 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
|
```abap
|
||||||
FUNCTION zsome_update_fu_mod
|
FUNCTION zsome_update_fu_mod
|
||||||
IMPORTING
|
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.
|
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.
|
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.
|
- [`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`.
|
- [`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
|
|||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)
|
<p align="right">(<a href="#top">⬆️ back to top</a>)
|
||||||
|
|
||||||
## Executable Example
|
## Executable Example
|
||||||
Coming soon ...
|
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**<br>
|
||||||
|
> - 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.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<details>
|
||||||
|
<summary>Expand to see explanations of the executable example</summary>
|
||||||
|
<!-- -->
|
||||||
|
<br>
|
||||||
|
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.
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
87
18_Dynpro.md
87
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.
|
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 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**<br>
|
> **💡 Note**<br>
|
||||||
> - Classic dynpros are outdated for application programs. New developments should use web-based UIs, such as SAPUI5 or Web Dynpro.
|
> - 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.
|
> - Dynpros cannot be created in ABAP Cloud.
|
||||||
> - This cheat sheet ...
|
> - 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.
|
> - 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.
|
> - 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.
|
> - 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**<br>
|
> **💡 Note**<br>
|
||||||
> 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.
|
> 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.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Dynpro Flow Logic
|
## 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`)
|
- `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
|
- `CALL SUBSCREEN` for calling the flow logic of a subscreen
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Dialog Modules
|
## Dialog Modules
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ MODULE pai_9000 INPUT.
|
|||||||
ENDMODULE.
|
ENDMODULE.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Transporting Data between Dynpros and the ABAP Program
|
## Transporting Data between Dynpros and the ABAP Program
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ ENDCLASS.
|
|||||||
- Notes on working with the *OK field*:
|
- Notes on working with the *OK field*:
|
||||||
- As with the other dynpro fields, a data object must be created in the ABAP program.
|
- 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.
|
- 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.
|
- 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.
|
- 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.
|
|||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Program-Controlled Data Transport
|
### Program-Controlled Data Transport
|
||||||
|
|
||||||
@@ -284,14 +284,14 @@ Example:
|
|||||||
"See some of them below and more details in the ABAP Keyword Documentation.
|
"See some of them below and more details in the ABAP Keyword Documentation.
|
||||||
|
|
||||||
PROCESS AFTER INPUT.
|
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.
|
FIELD field_a.
|
||||||
MODULE module_a. "field_a is available, field_b is not
|
MODULE module_a. "field_a is available, field_b is not
|
||||||
FIELD field_b.
|
FIELD field_b.
|
||||||
MODULE module_b. "both field_a and field_b are available
|
MODULE module_b. "both field_a and field_b are available
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Calling Dialog Modules Conditionally
|
### Calling Dialog Modules Conditionally
|
||||||
|
|
||||||
@@ -321,7 +321,7 @@ PROCESS AFTER INPUT.
|
|||||||
ENDCHAIN.
|
ENDCHAIN.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Input Checks
|
## 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.
|
- 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.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Field and Input Help
|
## Field and Input Help
|
||||||
|
|
||||||
@@ -396,7 +396,7 @@ PROCESS AFTER INPUT.
|
|||||||
- A special form that can be linked to an input field.
|
- 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.
|
- 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.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Dnypro Sequence, Calling and Leaving Dynpros
|
## 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.
|
- 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.
|
- When the current dynpro sequence is finished, the system returns to the previous dynpro sequence if the current dynpro sequence was nested.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### ABAP Statements for Calling and Leaving Dynpros
|
### ABAP Statements for Calling and Leaving Dynpros
|
||||||
|
|
||||||
@@ -498,7 +498,7 @@ SET SCREEN 0.
|
|||||||
LEAVE SCREEN.
|
LEAVE SCREEN.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Modifying Static Attributes of Screen Elements
|
## Modifying Static Attributes of Screen Elements
|
||||||
|
|
||||||
@@ -529,7 +529,7 @@ MODULE pbo_9000 OUTPUT.
|
|||||||
ENDMODULE.
|
ENDMODULE.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
|
|
||||||
## Statements for the GUI Status and Title
|
## Statements for the GUI Status and Title
|
||||||
@@ -589,7 +589,7 @@ ENDMODULE.
|
|||||||
> **💡 Note**<br>
|
> **💡 Note**<br>
|
||||||
> 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.
|
> 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.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## Controls
|
## Controls
|
||||||
|
|
||||||
@@ -646,7 +646,7 @@ REFRESH CONTROL contr FROM SCREEN dynnr.
|
|||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Tabstrips Controls
|
### Tabstrips Controls
|
||||||
- Allow tab pages to be displayed on dynpros
|
- Allow tab pages to be displayed on dynpros
|
||||||
@@ -692,7 +692,7 @@ PROCESS AFTER INPUT.
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### GUI Controls
|
### GUI Controls
|
||||||
- Are components of the presentation view of an AS ABAP.
|
- 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.
|
- 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.
|
- 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.
|
||||||
|
|
||||||
<p align="right">(<a href="#top">⬆️ back to top</a>)</p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
## More Information
|
## 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
|
- [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.
|
- 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
|
## Example
|
||||||
Coming soon ...
|
|
||||||
|
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**<br>
|
||||||
|
> - 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.
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<details>
|
||||||
|
<summary>Expand to see explanations of the executable example</summary>
|
||||||
|
<!-- -->
|
||||||
|
<br>
|
||||||
|
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
|
||||||
|
</details>
|
||||||
107
README.md
107
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.
|
- provide a **collection of information on selected ABAP topics** in a nutshell for your reference.
|
||||||
- focus on **ABAP syntax**.
|
- focus on **ABAP syntax**.
|
||||||
- include **code snippets**.
|
- 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.
|
- 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.
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>💡 Note</summary>
|
<summary>💡 Note</summary>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
- 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.
|
- 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:
|
- 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 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)
|
- [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 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)
|
- [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).
|
- 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).
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
@@ -49,7 +50,7 @@ ABAP cheat sheets[^1] ...
|
|||||||
## 🏗️ How to Use
|
## 🏗️ 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).
|
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.
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
@@ -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)|
|
|[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)|
|
|[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)|
|
|[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 <br> 💡 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|
|
|[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 <br> 💡 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 introduction to dynpro topics with a focus on dynpro-related statements <br> 💡 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 overview of dynpro topics with a focus on dynpro-related statements <br> 💡 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`|
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## 🎬 Getting Started with the Examples
|
## 🎬 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.
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>1) General info</summary>
|
<summary>1) General info</summary>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
- 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.
|
- 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.
|
- The examples **include descriptions and comments** in the code to provide explanations and set the context.
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
@@ -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/).
|
- [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**
|
**Import Code**
|
||||||
|
|
||||||
Use the abapGit plug-in to install the <em>ABAP Cheat Sheets</em> by carrying out the following steps:
|
Use the abapGit plug-in to install the <em>ABAP Cheat Sheets</em> 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.
|
2. Add the package to the *Favorite Packages* in the *Project Explorer* view in ADT.
|
||||||
3. To add the <em>abapGit Repositories</em> view to the <em>ABAP</em> perspective, choose `Window` → `Show View` → `Other...` from the menu bar and choose `abapGit Repositories`.
|
3. To add the <em>abapGit Repositories</em> view to the <em>ABAP</em> perspective, choose *Window* → *Show View* → *Other...* from the menu bar and choose *abapGit Repositories*.
|
||||||
4. In the <em>abapGit Repositories</em> view, click the `+` icon in the upper right corner of the ADT tab to link a new abapGit repository.
|
4. In the <em>abapGit Repositories</em> view, click the `+` icon in the upper right corner of the ADT tab to link a new abapGit repository.
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
@@ -120,19 +121,19 @@ Use the abapGit plug-in to install the <em>ABAP Cheat Sheets</em> by carrying ou
|
|||||||
https://github.com/SAP-samples/abap-cheat-sheets.git
|
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.
|
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`.
|
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.
|
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 <em>Linked</em>.
|
10. In the *abapGit Repositories* view, filter for your package. The repository appears in the *abapGit Repositories* view with the status <em>Linked</em>.
|
||||||
11. Right-click on the new abapGit repository and choose `Pull...` to start the cloning of the repository contents.
|
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`.
|
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`.
|
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 <em>Pull running...</em>. Note that the pull run may take several minutes.
|
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 <em>Pull running...</em>. 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.
|
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.
|
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`).
|
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*).
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
@@ -140,33 +141,40 @@ https://github.com/SAP-samples/abap-cheat-sheets.git
|
|||||||
<br>
|
<br>
|
||||||
|
|
||||||
**Prerequisites**
|
**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] 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`:
|
||||||
- [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*.
|
```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 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 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**
|
**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:
|
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.
|
2. Add the package to the *Favorite Packages* in the *Project Explorer* view in ADT.
|
||||||
3. Run the standalone version of the abapGit report.
|
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:
|
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
|
https://github.com/SAP-samples/abap-cheat-sheets.git
|
||||||
```
|
```
|
||||||
|
|
||||||
- `Package`: Your demo package, for example, `TEST_ABAP_CHEAT_SHEETS`
|
- ***Package***: Your demo package, for example, *TEST_ABAP_CHEAT_SHEETS*
|
||||||
6. Leave the other fields unchanged and choose `Create Online Repo`.
|
- ***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.
|
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.
|
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` (✔️).
|
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.
|
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`).
|
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*).
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
@@ -175,23 +183,28 @@ Use the standalone version of the abapGit report to import the demo examples of
|
|||||||
<br>
|
<br>
|
||||||
|
|
||||||
- Open the package you created containing the imported ABAP artifacts in the ABAP development tools for Eclipse (ADT).
|
- 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.
|
- Classes:
|
||||||
- Choose `F9` to run the class. Alternatively, choose `Run` → `Run As` → `2 ABAP Application (Console)` from the menu.
|
- 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.
|
||||||
- Check the console output.
|
- Choose *F9* to run the class. Alternatively, choose *Run* → *Run As* → *2 ABAP Application (Console)* from the menu.
|
||||||
|
- Check the console output.
|
||||||
|
> **💡 Note**<br>
|
||||||
|
>- 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**<br>
|
|
||||||
>- 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.
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## ⚡ Known Issues
|
## ⚡ 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.
|
- 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.
|
|
||||||
- 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 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.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
<asx:values>
|
<asx:values>
|
||||||
<DEVC>
|
<DEVC>
|
||||||
<CTEXT>ABAP Cheat Sheets</CTEXT>
|
<CTEXT>ABAP Cheat Sheets</CTEXT>
|
||||||
<TPCLASS>X</TPCLASS>
|
|
||||||
</DEVC>
|
</DEVC>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -16,5 +16,5 @@ ENDCLASS.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS zbp_demo_abap_rap_draft_m IMPLEMENTATION.
|
CLASS ZBP_DEMO_ABAP_RAP_DRAFT_M IMPLEMENTATION.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
<CLSDEFINT>ZDEMO_ABAP_RAP_DRAFT_M</CLSDEFINT>
|
<CLSDEFINT>ZDEMO_ABAP_RAP_DRAFT_M</CLSDEFINT>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
|
|||||||
@@ -16,5 +16,5 @@ ENDCLASS.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS zbp_demo_abap_rap_ro_m IMPLEMENTATION.
|
CLASS ZBP_DEMO_ABAP_RAP_RO_M IMPLEMENTATION.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
<CLSDEFINT>ZDEMO_ABAP_RAP_RO_M</CLSDEFINT>
|
<CLSDEFINT>ZDEMO_ABAP_RAP_RO_M</CLSDEFINT>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
|
|||||||
@@ -16,5 +16,5 @@ ENDCLASS.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS zbp_demo_abap_rap_ro_u IMPLEMENTATION.
|
CLASS ZBP_DEMO_ABAP_RAP_RO_U IMPLEMENTATION.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
<CLSDEFINT>ZDEMO_ABAP_RAP_RO_U</CLSDEFINT>
|
<CLSDEFINT>ZDEMO_ABAP_RAP_RO_U</CLSDEFINT>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ CLASS zcl_demo_abap_amdp DEFINITION
|
|||||||
"is made in the PUBLIC visibility section.
|
"is made in the PUBLIC visibility section.
|
||||||
CLASS-METHODS flight_analysis FOR TABLE FUNCTION zdemo_abap_table_function.
|
CLASS-METHODS flight_analysis FOR TABLE FUNCTION zdemo_abap_table_function.
|
||||||
|
|
||||||
|
PROTECTED SECTION.
|
||||||
PRIVATE SECTION.
|
PRIVATE SECTION.
|
||||||
|
|
||||||
"AMDP procedure
|
"AMDP procedure
|
||||||
@@ -145,23 +146,119 @@ CLASS zcl_demo_abap_amdp DEFINITION
|
|||||||
IMPORTING VALUE(carrid) TYPE zdemo_abap_flsch-carrid
|
IMPORTING VALUE(carrid) TYPE zdemo_abap_flsch-carrid
|
||||||
RETURNING VALUE(carr_fli_tab) TYPE carr_fli_tab.
|
RETURNING VALUE(carr_fli_tab) TYPE carr_fli_tab.
|
||||||
|
|
||||||
|
CONSTANTS nl TYPE string value cl_abap_char_utilities=>newline.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS zcl_demo_abap_amdp IMPLEMENTATION.
|
CLASS zcl_demo_abap_amdp IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD class_constructor.
|
METHOD class_constructor.
|
||||||
"Filling demo database tables.
|
"Filling demo database tables.
|
||||||
zcl_demo_abap_flight_tables=>fill_dbtabs( ).
|
zcl_demo_abap_flight_tables=>fill_dbtabs( ).
|
||||||
ENDMETHOD.
|
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.
|
METHOD if_oo_adt_classrun~main.
|
||||||
|
|
||||||
DATA(output) = NEW zcl_demo_abap_display( out ).
|
DATA(output) = NEW zcl_demo_abap_display( out ).
|
||||||
|
|
||||||
output->display( `ABAP Cheat Sheet Example: ABAP AMDP` ).
|
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
|
"Declaring an internal table to store the data that are
|
||||||
"returned by the following method.
|
"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
|
"As can be seen in the method implementation part, this AMDP procedure
|
||||||
"includes an AMDP procedure call from SQLScript.
|
"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
|
"The AMDP procedure select_get_carr_fli calls the AMDP table function
|
||||||
"get_carr_fli in the implementation part. AMDP table functions can
|
"get_carr_fli in the implementation part. AMDP table functions can
|
||||||
@@ -229,7 +326,7 @@ 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
|
"The example demonstrates that a CDS table function can be used as a
|
||||||
@@ -251,7 +348,6 @@ CLASS zcl_demo_abap_amdp IMPLEMENTATION.
|
|||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
**********************************************************************
|
|
||||||
|
|
||||||
METHOD select_carriers
|
METHOD select_carriers
|
||||||
BY DATABASE PROCEDURE
|
BY DATABASE PROCEDURE
|
||||||
@@ -265,93 +361,6 @@ CLASS zcl_demo_abap_amdp IMPLEMENTATION.
|
|||||||
ORDER BY carrid;
|
ORDER BY carrid;
|
||||||
ENDMETHOD.
|
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
|
METHOD select_get_carr_fli
|
||||||
BY DATABASE PROCEDURE
|
BY DATABASE PROCEDURE
|
||||||
@@ -364,5 +373,4 @@ CLASS zcl_demo_abap_amdp IMPLEMENTATION.
|
|||||||
FROM "ZCL_DEMO_ABAP_AMDP=>GET_CARR_FLI"(
|
FROM "ZCL_DEMO_ABAP_AMDP=>GET_CARR_FLI"(
|
||||||
carrid => :carrid );
|
carrid => :carrid );
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -53,11 +53,13 @@ CLASS zcl_demo_abap_cds_ve DEFINITION
|
|||||||
if_oo_adt_classrun.
|
if_oo_adt_classrun.
|
||||||
|
|
||||||
CLASS-METHODS class_constructor.
|
CLASS-METHODS class_constructor.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS zcl_demo_abap_cds_ve IMPLEMENTATION.
|
CLASS zcl_demo_abap_cds_ve IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD class_constructor.
|
METHOD class_constructor.
|
||||||
"Filling demo database tables.
|
"Filling demo database tables.
|
||||||
zcl_demo_abap_flight_tables=>fill_dbtabs( ).
|
zcl_demo_abap_flight_tables=>fill_dbtabs( ).
|
||||||
@@ -91,9 +93,9 @@ CLASS zcl_demo_abap_cds_ve IMPLEMENTATION.
|
|||||||
period = 0 ) ) ).
|
period = 0 ) ) ).
|
||||||
|
|
||||||
MODIFY zdemo_abap_fli FROM TABLE @( VALUE #( ( carrid = 'UA' ) ) ).
|
MODIFY zdemo_abap_fli FROM TABLE @( VALUE #( ( carrid = 'UA' ) ) ).
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
METHOD if_oo_adt_classrun~main.
|
METHOD if_oo_adt_classrun~main.
|
||||||
|
|
||||||
DATA(output) = NEW zcl_demo_abap_display( out ).
|
DATA(output) = NEW zcl_demo_abap_display( out ).
|
||||||
@@ -170,7 +172,7 @@ CLASS zcl_demo_abap_cds_ve IMPLEMENTATION.
|
|||||||
" contain the coalesce function and CASE expressions similar to the
|
" contain the coalesce function and CASE expressions similar to the
|
||||||
" CDS view entity.
|
" CDS view entity.
|
||||||
|
|
||||||
output->display( `----- Inner join -----` ).
|
output->display( `---------- Inner join ----------` ).
|
||||||
|
|
||||||
SELECT _carr~carrid,
|
SELECT _carr~carrid,
|
||||||
_carr~carrname,
|
_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( input = sql_inner_join name = `sql_inner_join` ).
|
||||||
|
|
||||||
output->display( `----- Left outer join -----` ).
|
output->display( `---------- Left outer join ----------` ).
|
||||||
|
|
||||||
SELECT _carr~carrid,
|
SELECT _carr~carrid,
|
||||||
_carr~carrname,
|
_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( input = sql_left_outer_join name = `sql_left_outer_join` ).
|
||||||
|
|
||||||
output->display( `----- Right outer join -----` ).
|
output->display( `---------- Right outer join ----------` ).
|
||||||
|
|
||||||
SELECT _carr~carrid,
|
SELECT _carr~carrid,
|
||||||
_carr~carrname,
|
_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( input = sql_right_outer_join name = `sql_right_outer_join` ).
|
||||||
|
|
||||||
output->display( `----- Cross join -----` ).
|
output->display( `---------- Cross join ----------` ).
|
||||||
|
|
||||||
SELECT _carr~carrid,
|
SELECT _carr~carrid,
|
||||||
_carr~carrname,
|
_carr~carrname,
|
||||||
@@ -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 following ABAP SQL SELECT statement uses a CDS view entity as
|
||||||
"the data source. The statement uses an exposed association.
|
"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` ).
|
output->display( input = assoc_exp_where name = `assoc_exp_where` ).
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -96,7 +96,8 @@ protected section.
|
|||||||
tab1 TYPE TABLE OF s1_type WITH EMPTY KEY,
|
tab1 TYPE TABLE OF s1_type WITH EMPTY KEY,
|
||||||
tab2 TYPE TABLE OF s2_type WITH EMPTY KEY,
|
tab2 TYPE TABLE OF s2_type WITH EMPTY KEY,
|
||||||
tab3 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:
|
CLASS-METHODS:
|
||||||
fill_deep_structures,
|
fill_deep_structures,
|
||||||
@@ -105,15 +106,69 @@ protected section.
|
|||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS zcl_demo_abap_constructor_expr IMPLEMENTATION.
|
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.
|
METHOD if_oo_adt_classrun~main.
|
||||||
|
|
||||||
DATA(output) = NEW zcl_demo_abap_display( out ).
|
DATA(output) = NEW zcl_demo_abap_display( out ).
|
||||||
|
|
||||||
output->display( `ABAP Cheat Sheet Example: Constructor expressions` ).
|
output->display( `ABAP Cheat Sheet Example: Constructor expressions` ).
|
||||||
|
|
||||||
output->next_section( `VALUE` ).
|
output->display( `VALUE` ).
|
||||||
output->display( `1) Structures: Populating a flat structure` ).
|
output->display( `1) Structures: Populating a flat structure` ).
|
||||||
|
|
||||||
"A flat structure is created based on a data type defined with a
|
"A flat structure is created based on a data type defined with a
|
||||||
@@ -1398,55 +1453,4 @@ CLASS zcl_demo_abap_constructor_expr IMPLEMENTATION.
|
|||||||
output->display( input = stringtab name = `stringtab` ).
|
output->display( input = stringtab name = `stringtab` ).
|
||||||
|
|
||||||
ENDMETHOD.
|
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.
|
ENDCLASS.
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -45,22 +45,25 @@ CLASS zcl_demo_abap_display DEFINITION
|
|||||||
IMPORTING
|
IMPORTING
|
||||||
heading TYPE string.
|
heading TYPE string.
|
||||||
|
|
||||||
protected section.
|
PROTECTED SECTION.
|
||||||
PRIVATE SECTION.
|
PRIVATE SECTION.
|
||||||
DATA:
|
DATA:
|
||||||
mo_out TYPE REF TO if_oo_adt_classrun_out,
|
mo_out TYPE REF TO if_oo_adt_classrun_out,
|
||||||
offset TYPE i.
|
offset TYPE i.
|
||||||
|
|
||||||
|
CONSTANTS nl TYPE string VALUE cl_abap_char_utilities=>newline.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS ZCL_DEMO_ABAP_DISPLAY IMPLEMENTATION.
|
CLASS zcl_demo_abap_display IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD constructor.
|
METHOD constructor.
|
||||||
mo_out = io_out.
|
mo_out = io_out.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
METHOD display.
|
METHOD display.
|
||||||
"Checking data type
|
"Checking data type
|
||||||
DATA(type_descr) = cl_abap_typedescr=>describe_by_data( input ).
|
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.
|
WHEN cl_abap_typedescr=>kind_intf.
|
||||||
to_be_serialized = abap_true.
|
to_be_serialized = abap_true.
|
||||||
WHEN cl_abap_typedescr=>kind_elem.
|
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.
|
WHEN cl_abap_typedescr=>kind_ref.
|
||||||
"Checking for data references
|
"Checking for data references
|
||||||
IF type_descr->type_kind = cl_abap_typedescr=>typekind_dref.
|
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->* ).
|
DATA(type_check_dref) = cl_abap_typedescr=>describe_by_data( input->* ).
|
||||||
"Processing (non-)elementary types
|
"Processing (non-)elementary types
|
||||||
IF type_check_dref->kind = type_descr->kind_elem.
|
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.
|
ELSE.
|
||||||
to_be_serialized = abap_true.
|
to_be_serialized = abap_true.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
@@ -127,29 +130,31 @@ CLASS ZCL_DEMO_ABAP_DISPLAY IMPLEMENTATION.
|
|||||||
assoc_arrays_opt = abap_true ).
|
assoc_arrays_opt = abap_true ).
|
||||||
IF to_be_serialized = abap_true.
|
IF to_be_serialized = abap_true.
|
||||||
IF name IS INITIAL.
|
IF name IS INITIAL.
|
||||||
REPLACE PCRE `^` IN display WITH json && cl_abap_char_utilities=>newline.
|
REPLACE PCRE `^` IN display WITH json && nl.
|
||||||
ELSE.
|
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.
|
ENDIF.
|
||||||
"substring found
|
"substring found
|
||||||
ELSE.
|
ELSE.
|
||||||
IF name IS INITIAL.
|
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.
|
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.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
mo_out->write( display ).
|
mo_out->write( display && nl ).
|
||||||
ELSE.
|
ELSE.
|
||||||
mo_out->write( display ).
|
mo_out->write( display && nl ).
|
||||||
ENDIF.
|
ENDIF.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
METHOD next_section.
|
METHOD next_section.
|
||||||
mo_out->write( `_________________________________________________________________________________`
|
mo_out->write( `_________________________________________________________________________________`
|
||||||
&& cl_abap_char_utilities=>newline
|
&& nl
|
||||||
&& cl_abap_char_utilities=>newline
|
&& nl
|
||||||
&& heading
|
&& heading
|
||||||
&& cl_abap_char_utilities=>newline ).
|
&& nl
|
||||||
|
&& nl ).
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
@@ -115,7 +115,147 @@ CLASS zcl_demo_abap_dtype_dobj DEFINITION
|
|||||||
ENDCLASS.
|
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.
|
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
|
"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
|
"Declaring reference types with static types
|
||||||
TYPES tr_i TYPE REF TO i.
|
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.
|
"The following examples deal with the declaration of data ojects.
|
||||||
"They show how data objects can be declared locally in an ABAP program.
|
"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
|
"Note: See more details and examples in the ABAP Keyword Documentations and in the
|
||||||
"respective ABAP cheat sheets.
|
"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
|
"Declaring data reference variables types with static types
|
||||||
DATA dref_int TYPE REF TO i.
|
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.
|
"An assignment passes the content of a source to a target data object.
|
||||||
"Note:
|
"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 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
|
"The data type of the variable is determined by the operand type. It must be possible
|
||||||
"to derive this type completely statically.
|
"to derive this type completely statically.
|
||||||
"Note:
|
"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.
|
" immutable variables as shon below.
|
||||||
"- As shown in the previous section, there are many options for what can be placed on
|
"- As shown in the previous section, there are many options for what can be placed on
|
||||||
" the right side.
|
" 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:
|
"Note:
|
||||||
"- As is true for other data object and types, there are special assignment rules
|
"- 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.
|
"Anonymous data objects are a topic related to data reference variables.
|
||||||
"These data objects are unnamed data objects.
|
"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` ).
|
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
|
"The following example shows the difference between text field strings
|
||||||
"of type c and character strings of type string when it comes to trailing
|
"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
|
"The following example shows the difference between binary and decimal
|
||||||
"floating point numbers.
|
"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.
|
"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
|
"In the example, a date field is assigned the current values
|
||||||
"using the cl_abap_context_info class. Calculations follow. The date of next
|
"using the cl_abap_context_info class. A calculation follows. The date of next
|
||||||
"day and the next hour are calculated.
|
"day is calculated.
|
||||||
"Note: The data types behave like numeric values in the context of calculations.
|
"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.
|
"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.
|
"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'.
|
"In such a case, the date field is assigned the invalid value '00000000'.
|
||||||
|
|
||||||
DATA: today TYPE d,
|
DATA: today TYPE d,
|
||||||
tomorrow TYPE d,
|
tomorrow TYPE d.
|
||||||
now TYPE t,
|
|
||||||
next_hour TYPE t.
|
|
||||||
today = cl_abap_context_info=>get_system_date( ).
|
today = cl_abap_context_info=>get_system_date( ).
|
||||||
now = cl_abap_context_info=>get_system_time( ).
|
|
||||||
tomorrow = today + 1.
|
tomorrow = today + 1.
|
||||||
next_hour = ( now + 3600 ) / 3600 * 3600.
|
|
||||||
output->display(
|
output->display(
|
||||||
|Today: { today }\n| &&
|
|Today: { today }\n| &&
|
||||||
|Now: { now }\n\n| &&
|
|Tommorow: { tomorrow }| ).
|
||||||
|Tommorow: { tomorrow }\n| &&
|
|
||||||
|Next Hour: { next_hour }| ).
|
|
||||||
|
|
||||||
DATA date TYPE d.
|
DATA date TYPE d.
|
||||||
date = '20240101'.
|
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
|
"The purpose of this example is to emphasize the conversion rules
|
||||||
"that should be noted when performing conversions. The example
|
"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
|
"Using RTTI to check type compatibility
|
||||||
"In the following example the applies_to_data method of the RTTI class
|
"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.
|
"As mentioned above, constants cannot be changed at runtime.
|
||||||
CONSTANTS con_str TYPE string VALUE `hallo`.
|
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.
|
DATA str_w_con_as_start_value TYPE string VALUE con_underscores.
|
||||||
|
|
||||||
"Immutable variables
|
"Immutable variables
|
||||||
"In newer ABAP releases, comment the code in.
|
FINAL(do_final_inl) = 1.
|
||||||
* FINAL(do_final_inl) = 1.
|
DATA(do_data_inl) = 1 + do_final_inl.
|
||||||
* DATA(do_data_inl) = 1 + do_final_inl.
|
"not possible
|
||||||
* "not possible
|
"do_final_inl = 2.
|
||||||
* "do_final_inl = 2.
|
|
||||||
*
|
SELECT * FROM zdemo_abap_carr INTO TABLE @DATA(itab_data_inl).
|
||||||
* SELECT * FROM zdemo_abap_carr INTO TABLE @DATA(itab_data_inl).
|
|
||||||
*
|
DATA itab_like_inline LIKE itab_data_inl.
|
||||||
* DATA itab_like_inline LIKE itab_data_inl.
|
|
||||||
*
|
"Using an inline declaration as target of a LOOP statement
|
||||||
* "Using an inline declaration as target of a LOOP statement
|
"A value is assigned multiple times, but it cannot be changed in any other
|
||||||
* "A value is assigned multiple times, but it cannot be changed in any other
|
"write positions.
|
||||||
* "write positions.
|
LOOP AT itab_data_inl INTO FINAL(wa_final).
|
||||||
* LOOP AT itab_data_inl INTO FINAL(wa_final).
|
|
||||||
*
|
"The following is not possible
|
||||||
* "The following is not possible
|
"wa_final-carrid = 'd'.
|
||||||
* "wa_final-carrid = 'd'.
|
"only read access
|
||||||
* "only read access
|
APPEND wa_final TO itab_like_inline.
|
||||||
* APPEND wa_final TO itab_like_inline.
|
ENDLOOP.
|
||||||
* ENDLOOP.
|
|
||||||
*
|
"SELECT statement with a an immutable target table declared inline
|
||||||
* "SELECT statement with a an immutable target table declared inline
|
SELECT * FROM zdemo_abap_carr INTO TABLE @FINAL(itab_final_inl).
|
||||||
* SELECT * FROM zdemo_abap_carr INTO TABLE @FINAL(itab_final_inl).
|
|
||||||
|
|
||||||
output->display( `No output for this section. Check out the code, `
|
output->display( `No output for this section. Check out the code, `
|
||||||
&& `for example, when running the class in the debugger after setting `
|
&& `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 and bound data types
|
||||||
"Standalone: Data type that is defined using the statement TYPES in an ABAP program, as
|
"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.
|
"Generic data types have already been covered above.
|
||||||
"A generic data type is an incomplete type specification that covers multiple
|
"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.
|
"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
|
"The purpose of this example is to emphasize the importance of where
|
||||||
"data objects are decalred. The example deals with local declarations
|
"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
|
"Examples for enumerated types and objects are contained in
|
||||||
"separate methods. Check the comments there.
|
"separate methods. Check the comments there.
|
||||||
@@ -1841,138 +1974,6 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
|
|||||||
|
|
||||||
ENDMETHOD.
|
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.
|
METHOD rtti_enum.
|
||||||
|
|
||||||
@@ -2022,5 +2023,4 @@ CLASS zcl_demo_abap_dtype_dobj IMPLEMENTATION.
|
|||||||
REPLACE FIRST OCCURRENCE OF PCRE `/\s` IN mem_string WITH ``.
|
REPLACE FIRST OCCURRENCE OF PCRE `/\s` IN mem_string WITH ``.
|
||||||
APPEND ` members:` && mem_string TO output.
|
APPEND ` members:` && mem_string TO output.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -31,10 +31,6 @@
|
|||||||
* or use the debugger.
|
* or use the debugger.
|
||||||
*
|
*
|
||||||
* ----------------------------- NOTE -----------------------------------
|
* ----------------------------- 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
|
* 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
|
* cheat sheets. It is not intended for direct use in a production system
|
||||||
* environment. The code examples in the ABAP cheat sheets are primarily
|
* 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-METHODS:
|
||||||
class_constructor.
|
class_constructor.
|
||||||
|
|
||||||
PROTECTED SECTION.
|
|
||||||
PRIVATE SECTION.
|
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
|
CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD class_constructor.
|
METHOD class_constructor.
|
||||||
"Filling demo database tables.
|
"Filling demo database tables.
|
||||||
zcl_demo_abap_flight_tables=>fill_dbtabs( ).
|
zcl_demo_abap_flight_tables=>fill_dbtabs( ).
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
METHOD if_oo_adt_classrun~main.
|
METHOD if_oo_adt_classrun~main.
|
||||||
|
|
||||||
DATA(output) = NEW zcl_demo_abap_display( out ).
|
DATA(output) = NEW zcl_demo_abap_display( out ).
|
||||||
@@ -463,12 +459,11 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
|
|||||||
|
|
||||||
DO.
|
DO.
|
||||||
"sy-index represents the position of a structure component
|
"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 <struct> TO <comp>.
|
|
||||||
|
|
||||||
"ASSIGN <struct>-(sy-index) to <comp>.
|
ASSIGN <struct>-(sy-index) to <comp>.
|
||||||
|
|
||||||
|
"Old syntax
|
||||||
|
"ASSIGN COMPONENT sy-index OF STRUCTURE <struct> TO <comp>.
|
||||||
|
|
||||||
IF sy-subrc <> 0.
|
IF sy-subrc <> 0.
|
||||||
"If all components are processed, the loop is exited.
|
"If all components are processed, the loop is exited.
|
||||||
@@ -959,38 +954,34 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
|
|||||||
output->display( input = <fs_m5> name = `<fs_m5>` ).
|
output->display( input = <fs_m5> name = `<fs_m5>` ).
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
"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` ).
|
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.
|
"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.
|
"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` ) ).
|
DATA(attr) = VALUE string_table( ( `another_string` ) ( `public_string` ) ( `this_will_fail` ) ).
|
||||||
*
|
|
||||||
* LOOP AT attr INTO DATA(attribute).
|
LOOP AT attr INTO DATA(attribute).
|
||||||
*
|
|
||||||
* ASSIGN cl_ref->(attribute) TO FIELD-SYMBOL(<attr>) ELSE UNASSIGN.
|
ASSIGN cl_ref->(attribute) TO FIELD-SYMBOL(<attr>) ELSE UNASSIGN.
|
||||||
* IF sy-subrc = 0.
|
IF sy-subrc = 0.
|
||||||
* output->display( |Successful assignment for attribute "{ attribute }". sy-subrc = { sy-subrc }. | ).
|
output->display( |Successful assignment for attribute "{ attribute }". sy-subrc = { sy-subrc }. | ).
|
||||||
* output->display( input = <attr> name = `<attr>` ).
|
output->display( input = <attr> name = `<attr>` ).
|
||||||
* ELSE.
|
ELSE.
|
||||||
* output->display( |Assignment not successful for attribute "{ attribute }". sy-subrc = { sy-subrc }. | ).
|
output->display( |Assignment not successful for attribute "{ attribute }". sy-subrc = { sy-subrc }. | ).
|
||||||
* ENDIF.
|
ENDIF.
|
||||||
*
|
|
||||||
* IF <attr> IS ASSIGNED.
|
IF <attr> IS ASSIGNED.
|
||||||
* output->display( `The field symbol is assigned.` ).
|
output->display( `The field symbol is assigned.` ).
|
||||||
* output->display( `--------------------` ).
|
output->display( `--------------------` ).
|
||||||
* ELSE.
|
ELSE.
|
||||||
* output->display( `The field symbol is not assigned.` ).
|
output->display( `The field symbol is not assigned.` ).
|
||||||
* ENDIF.
|
ENDIF.
|
||||||
*
|
|
||||||
* ENDLOOP.
|
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` ).
|
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( ).
|
DATA(comp_name) = lcl_det_at_runtime=>get_dyn_field( ).
|
||||||
|
|
||||||
* ASSIGN wa-(comp_name) TO FIELD-SYMBOL(<fs_m6>).
|
ASSIGN wa-(comp_name) TO FIELD-SYMBOL(<fs_m6>).
|
||||||
*
|
|
||||||
* ASSIGN wa-('CARRNAME') TO FIELD-SYMBOL(<fs_m7>).
|
|
||||||
*
|
|
||||||
* IF sy-subrc = 0.
|
|
||||||
* DATA(subrc1) = sy-subrc.
|
|
||||||
* ENDIF.
|
|
||||||
*
|
|
||||||
* "No exception occurs in case of an unsuccessful assignment.
|
|
||||||
* ASSIGN wa-('CRRNM') TO FIELD-SYMBOL(<fs_m8>).
|
|
||||||
*
|
|
||||||
* 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(<fs_m9>).
|
|
||||||
*
|
|
||||||
* "If the value is 0, the memory area of the entire structure is assigned to the field symbol.
|
|
||||||
* ASSIGN wa-(0) TO FIELD-SYMBOL(<fs_m10>).
|
|
||||||
|
|
||||||
"The above statements replace the following syntax
|
ASSIGN wa-('CARRNAME') TO FIELD-SYMBOL(<fs_m7>).
|
||||||
|
|
||||||
|
IF sy-subrc = 0.
|
||||||
|
DATA(subrc1) = sy-subrc.
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
"No exception occurs in case of an unsuccessful assignment.
|
||||||
|
ASSIGN wa-('CRRNM') TO FIELD-SYMBOL(<fs_m8>).
|
||||||
|
|
||||||
|
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(<fs_m9>).
|
||||||
|
|
||||||
|
"If the value is 0, the memory area of the entire structure is assigned to the field symbol.
|
||||||
|
ASSIGN wa-(0) TO FIELD-SYMBOL(<fs_m10>).
|
||||||
|
|
||||||
|
"Old syntax
|
||||||
ASSIGN COMPONENT 'CARRID' OF STRUCTURE wa TO FIELD-SYMBOL(<fs_m11>).
|
ASSIGN COMPONENT 'CARRID' OF STRUCTURE wa TO FIELD-SYMBOL(<fs_m11>).
|
||||||
|
|
||||||
ASSIGN COMPONENT 5 OF STRUCTURE wa TO FIELD-SYMBOL(<fs_m12>).
|
ASSIGN COMPONENT 5 OF STRUCTURE wa TO FIELD-SYMBOL(<fs_m12>).
|
||||||
@@ -1034,12 +1025,12 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION.
|
|||||||
|
|
||||||
ASSIGN ref_m->('CARRNAME') TO FIELD-SYMBOL(<fs_m13>).
|
ASSIGN ref_m->('CARRNAME') TO FIELD-SYMBOL(<fs_m13>).
|
||||||
|
|
||||||
* output->display( input = <fs_m6> name = `<fs_m6>` ).
|
output->display( input = <fs_m6> name = `<fs_m6>` ).
|
||||||
* output->display( input = <fs_m7> name = `<fs_m7>` ).
|
output->display( input = <fs_m7> name = `<fs_m7>` ).
|
||||||
* output->display( input = subrc1 name = `subrc1` ).
|
output->display( input = subrc1 name = `subrc1` ).
|
||||||
* output->display( input = subrc2 name = `subrc2` ).
|
output->display( input = subrc2 name = `subrc2` ).
|
||||||
* output->display( input = <fs_m9> name = `<fs_m9>` ).
|
output->display( input = <fs_m9> name = `<fs_m9>` ).
|
||||||
* output->display( input = <fs_m10> name = `<fs_m10>` ).
|
output->display( input = <fs_m10> name = `<fs_m10>` ).
|
||||||
output->display( input = <fs_m11> name = `<fs_m11>` ).
|
output->display( input = <fs_m11> name = `<fs_m11>` ).
|
||||||
output->display( input = <fs_m12> name = `<fs_m12>` ).
|
output->display( input = <fs_m12> name = `<fs_m12>` ).
|
||||||
output->display( input = <fs_m13> name = `<fs_m13>` ).
|
output->display( input = <fs_m13> name = `<fs_m13>` ).
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ ENDCLASS.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS zcl_demo_abap_flight_tables IMPLEMENTATION.
|
CLASS ZCL_DEMO_ABAP_FLIGHT_TABLES IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD clear_dbtabs.
|
METHOD clear_dbtabs.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -110,12 +110,16 @@ protected section.
|
|||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD class_constructor.
|
METHOD class_constructor.
|
||||||
fill_dbtabs( ).
|
fill_dbtabs( ).
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
METHOD fill_dbtabs.
|
METHOD fill_dbtabs.
|
||||||
"Initializing and filling of database tables to have data to work with
|
"Initializing and filling of database tables to have data to work with
|
||||||
|
|
||||||
@@ -137,6 +141,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
|||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
METHOD fill_itabs_for_corresponding.
|
METHOD fill_itabs_for_corresponding.
|
||||||
tab1 = VALUE #( ( a = 1 b = 'aaa' c = 'aaa' d = 'A' )
|
tab1 = VALUE #( ( a = 1 b = 'aaa' c = 'aaa' d = 'A' )
|
||||||
( a = 2 b = 'bbb' c = 'bbb' d = 'B' ) ).
|
( a = 2 b = 'bbb' c = 'bbb' d = 'B' ) ).
|
||||||
@@ -177,6 +182,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
|||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
METHOD if_oo_adt_classrun~main.
|
METHOD if_oo_adt_classrun~main.
|
||||||
|
|
||||||
DATA(output) = NEW zcl_demo_abap_display( out ).
|
DATA(output) = NEW zcl_demo_abap_display( out ).
|
||||||
@@ -425,6 +431,10 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION.
|
|||||||
|
|
||||||
output->display( input = tab1 name = `tab1` ).
|
output->display( input = tab1 name = `tab1` ).
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
|
output->next_section( `11g) ... excluding components and using MAPPING` ).
|
||||||
|
|
||||||
"EXCEPT * means that all components remain initial not specified
|
"EXCEPT * means that all components remain initial not specified
|
||||||
"for mapping
|
"for mapping
|
||||||
tab1 = CORRESPONDING #( tab2 MAPPING d = f EXCEPT * ).
|
tab1 = CORRESPONDING #( tab2 MAPPING d = f EXCEPT * ).
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -81,18 +81,21 @@ ENDCLASS.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS zcl_demo_abap_objects IMPLEMENTATION.
|
CLASS ZCL_DEMO_ABAP_OBJECTS IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD hallo_instance_method.
|
METHOD hallo_instance_method.
|
||||||
string = |Hallo { sy-uname }. | &&
|
string = |Hallo { sy-uname }. | &&
|
||||||
|I'm an instance method of class zcl_demo_abap_objects.|.
|
|I'm an instance method of class zcl_demo_abap_objects.|.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
METHOD hallo_static_method.
|
METHOD hallo_static_method.
|
||||||
string = |Hallo { sy-uname }. | &&
|
string = |Hallo { sy-uname }. | &&
|
||||||
|I'm a static method of class zcl_demo_abap_objects.|.
|
|I'm a static method of class zcl_demo_abap_objects.|.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
METHOD if_oo_adt_classrun~main.
|
METHOD if_oo_adt_classrun~main.
|
||||||
|
|
||||||
DATA(output) = NEW zcl_demo_abap_display( out ).
|
DATA(output) = NEW zcl_demo_abap_display( out ).
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -23,11 +23,15 @@
|
|||||||
PUBLIC SECTION.
|
PUBLIC SECTION.
|
||||||
CLASS-METHODS get_strings RETURNING VALUE(res_string) TYPE string_table.
|
CLASS-METHODS get_strings RETURNING VALUE(res_string) TYPE string_table.
|
||||||
|
|
||||||
|
protected section.
|
||||||
|
private section.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS ZCL_DEMO_ABAP_OBJECTS_FRIEND IMPLEMENTATION.
|
CLASS ZCL_DEMO_ABAP_OBJECTS_FRIEND IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD get_strings.
|
METHOD get_strings.
|
||||||
"Getting the strings and adding them to the string table.
|
"Getting the strings and adding them to the string table.
|
||||||
"Accessing an attribute in a public visibility section.
|
"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.
|
"Accessing an attribute in a private visibility section.
|
||||||
APPEND zcl_demo_abap_objects=>private_string TO res_string.
|
APPEND zcl_demo_abap_objects=>private_string TO res_string.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ CLASS zcl_demo_abap_prog_flow_logic DEFINITION
|
|||||||
PUBLIC SECTION.
|
PUBLIC SECTION.
|
||||||
INTERFACES: if_oo_adt_classrun.
|
INTERFACES: if_oo_adt_classrun.
|
||||||
|
|
||||||
|
protected section.
|
||||||
PRIVATE SECTION.
|
PRIVATE SECTION.
|
||||||
|
|
||||||
"Structured type for calculation example
|
"Structured type for calculation example
|
||||||
@@ -98,7 +99,118 @@ CLASS zcl_demo_abap_prog_flow_logic DEFINITION
|
|||||||
|
|
||||||
ENDCLASS.
|
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.
|
METHOD if_oo_adt_classrun~main.
|
||||||
|
|
||||||
@@ -1223,111 +1335,6 @@ CLASS zcl_demo_abap_prog_flow_logic IMPLEMENTATION.
|
|||||||
|
|
||||||
ENDMETHOD.
|
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.
|
METHOD meth_with_return.
|
||||||
|
|
||||||
@@ -1341,6 +1348,36 @@ CLASS zcl_demo_abap_prog_flow_logic IMPLEMENTATION.
|
|||||||
|
|
||||||
ENDMETHOD.
|
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.
|
METHOD validate_email.
|
||||||
|
|
||||||
IF matches( val = email
|
IF matches( val = email
|
||||||
@@ -1363,32 +1400,4 @@ CLASS zcl_demo_abap_prog_flow_logic IMPLEMENTATION.
|
|||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
ENDMETHOD.
|
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.
|
ENDCLASS.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -903,65 +903,65 @@ CLASS ZCL_DEMO_ABAP_RAP_EXT_NUM_M IMPLEMENTATION.
|
|||||||
*
|
*
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
|
|
||||||
* output->next_section( `11) Excursion: Read and read-by-association ` &&
|
output->next_section( `11) Excursion: Read and read-by-association ` &&
|
||||||
* `operations using dynamic EML` ).
|
`operations using dynamic EML` ).
|
||||||
* DATA:
|
DATA:
|
||||||
* op_tab TYPE abp_behv_retrievals_tab,
|
op_tab TYPE abp_behv_retrievals_tab,
|
||||||
* read_dyn TYPE TABLE FOR READ IMPORT zdemo_abap_rap_ro_m,
|
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,
|
read_dyn_result TYPE TABLE FOR READ RESULT zdemo_abap_rap_ro_m,
|
||||||
* rba_dyn TYPE TABLE FOR READ IMPORT
|
rba_dyn TYPE TABLE FOR READ IMPORT
|
||||||
* zdemo_abap_rap_ro_m\_child,
|
zdemo_abap_rap_ro_m\_child,
|
||||||
* rba_dyn_result TYPE TABLE FOR READ RESULT
|
rba_dyn_result TYPE TABLE FOR READ RESULT
|
||||||
* zdemo_abap_rap_ro_m\_child,
|
zdemo_abap_rap_ro_m\_child,
|
||||||
* rba_dyn_link TYPE TABLE FOR READ LINK zdemo_abap_rap_ro_m\_child.
|
rba_dyn_link TYPE TABLE FOR READ LINK zdemo_abap_rap_ro_m\_child.
|
||||||
*
|
|
||||||
* read_dyn = VALUE #(
|
read_dyn = VALUE #(
|
||||||
* ( %key-key_field = 1
|
( %key-key_field = 1
|
||||||
* %control = VALUE #(
|
%control = VALUE #(
|
||||||
* field1 = if_abap_behv=>mk-on
|
field1 = if_abap_behv=>mk-on
|
||||||
* field2 = if_abap_behv=>mk-on
|
field2 = if_abap_behv=>mk-on
|
||||||
* field3 = if_abap_behv=>mk-on
|
field3 = if_abap_behv=>mk-on
|
||||||
* field4 = if_abap_behv=>mk-on ) )
|
field4 = if_abap_behv=>mk-on ) )
|
||||||
* ( %key-key_field = 2
|
( %key-key_field = 2
|
||||||
* %control = VALUE #(
|
%control = VALUE #(
|
||||||
* field1 = if_abap_behv=>mk-on
|
field1 = if_abap_behv=>mk-on
|
||||||
* field2 = if_abap_behv=>mk-on
|
field2 = if_abap_behv=>mk-on
|
||||||
* field3 = if_abap_behv=>mk-on
|
field3 = if_abap_behv=>mk-on
|
||||||
* field4 = if_abap_behv=>mk-on ) ) ).
|
field4 = if_abap_behv=>mk-on ) ) ).
|
||||||
*
|
|
||||||
* rba_dyn = VALUE #(
|
rba_dyn = VALUE #(
|
||||||
* ( %key-key_field = 1
|
( %key-key_field = 1
|
||||||
* %control = VALUE #(
|
%control = VALUE #(
|
||||||
* key_ch = if_abap_behv=>mk-on
|
key_ch = if_abap_behv=>mk-on
|
||||||
* field_ch1 = if_abap_behv=>mk-on
|
field_ch1 = if_abap_behv=>mk-on
|
||||||
* field_ch2 = if_abap_behv=>mk-on ) )
|
field_ch2 = if_abap_behv=>mk-on ) )
|
||||||
* ( %key-key_field = 2
|
( %key-key_field = 2
|
||||||
* %control = VALUE #(
|
%control = VALUE #(
|
||||||
* key_ch = if_abap_behv=>mk-on
|
key_ch = if_abap_behv=>mk-on
|
||||||
* field_ch1 = if_abap_behv=>mk-on
|
field_ch1 = if_abap_behv=>mk-on
|
||||||
* field_ch2 = if_abap_behv=>mk-on ) ) ).
|
field_ch2 = if_abap_behv=>mk-on ) ) ).
|
||||||
*
|
|
||||||
* op_tab = VALUE #(
|
op_tab = VALUE #(
|
||||||
* ( op = if_abap_behv=>op-r-read
|
( op = if_abap_behv=>op-r-read
|
||||||
* entity_name = 'ZDEMO_ABAP_RAP_RO_M'
|
entity_name = 'ZDEMO_ABAP_RAP_RO_M'
|
||||||
* instances = REF #( read_dyn )
|
instances = REF #( read_dyn )
|
||||||
* results = REF #( read_dyn_result ) )
|
results = REF #( read_dyn_result ) )
|
||||||
* ( op = if_abap_behv=>op-r-read_ba
|
( op = if_abap_behv=>op-r-read_ba
|
||||||
* entity_name = 'ZDEMO_ABAP_RAP_RO_M'
|
entity_name = 'ZDEMO_ABAP_RAP_RO_M'
|
||||||
* sub_name = '_CHILD'
|
sub_name = '_CHILD'
|
||||||
* full = abap_true
|
full = abap_true
|
||||||
* instances = REF #( rba_dyn )
|
instances = REF #( rba_dyn )
|
||||||
* results = REF #( rba_dyn_result )
|
results = REF #( rba_dyn_result )
|
||||||
* links = REF #( rba_dyn_link ) ) ).
|
links = REF #( rba_dyn_link ) ) ).
|
||||||
*
|
|
||||||
* READ ENTITIES OPERATIONS op_tab.
|
READ ENTITIES OPERATIONS op_tab.
|
||||||
*
|
|
||||||
* output->display( `Read result (root)` ).
|
output->display( `Read result (root)` ).
|
||||||
* output->display( input = read_dyn_result name = `read_dyn_result` ).
|
output->display( input = read_dyn_result name = `read_dyn_result` ).
|
||||||
* output->display( `Read result (read-by-association)` ).
|
output->display( `Read result (read-by-association)` ).
|
||||||
* output->display( input = rba_dyn_result name = `rba_dyn_result` ).
|
output->display( input = rba_dyn_result name = `rba_dyn_result` ).
|
||||||
* output->display( `Links` ).
|
output->display( `Links` ).
|
||||||
* output->display( input = rba_dyn_link name = `rba_dyn_link` ).
|
output->display( input = rba_dyn_link name = `rba_dyn_link` ).
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -90,12 +90,16 @@ protected section.
|
|||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
CLASS zcl_demo_abap_rap_ext_num_u IMPLEMENTATION.
|
|
||||||
|
|
||||||
|
CLASS ZCL_DEMO_ABAP_RAP_EXT_NUM_U IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD class_constructor.
|
METHOD class_constructor.
|
||||||
initialize_dbtabs( ).
|
initialize_dbtabs( ).
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
METHOD extract_from_failed.
|
METHOD extract_from_failed.
|
||||||
CLEAR errors.
|
CLEAR errors.
|
||||||
|
|
||||||
@@ -983,95 +987,93 @@ CLASS zcl_demo_abap_rap_ext_num_u IMPLEMENTATION.
|
|||||||
* Excursion: Read and read-by-association operation using dynamic
|
* Excursion: Read and read-by-association operation using dynamic
|
||||||
* EML statements
|
* EML statements
|
||||||
*
|
*
|
||||||
* Notes:
|
* Note:
|
||||||
* - If the parameter for FULL is not flagged, only the association
|
* If the parameter for FULL is not flagged, only the association
|
||||||
* links are returned. The parameter for RESULT will be empty.
|
* 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.
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
|
|
||||||
* output->next_section( `12) Excursion: Read and read-by-association ` &&
|
output->next_section( `12) Excursion: Read and read-by-association ` &&
|
||||||
* `operations using dynamic EML` ).
|
`operations using dynamic EML` ).
|
||||||
*
|
|
||||||
* DATA:
|
DATA:
|
||||||
* op_tab TYPE abp_behv_retrievals_tab,
|
op_tab TYPE abp_behv_retrievals_tab,
|
||||||
* read_dyn TYPE TABLE FOR READ IMPORT zdemo_abap_rap_ro_u,
|
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,
|
read_dyn_result TYPE TABLE FOR READ RESULT zdemo_abap_rap_ro_u,
|
||||||
* rba_dyn TYPE TABLE FOR READ IMPORT
|
rba_dyn TYPE TABLE FOR READ IMPORT
|
||||||
* zdemo_abap_rap_ro_u\_child,
|
zdemo_abap_rap_ro_u\_child,
|
||||||
* rba_dyn_result TYPE TABLE FOR READ RESULT
|
rba_dyn_result TYPE TABLE FOR READ RESULT
|
||||||
* zdemo_abap_rap_ro_u\_child,
|
zdemo_abap_rap_ro_u\_child,
|
||||||
* rba_dyn_link TYPE TABLE FOR READ LINK zdemo_abap_rap_ro_u\_child.
|
rba_dyn_link TYPE TABLE FOR READ LINK zdemo_abap_rap_ro_u\_child.
|
||||||
*
|
|
||||||
* read_dyn = VALUE #(
|
read_dyn = VALUE #(
|
||||||
* ( %key-key_field = 1
|
( %key-key_field = 1
|
||||||
* %control = VALUE #(
|
%control = VALUE #(
|
||||||
* field1 = if_abap_behv=>mk-on
|
field1 = if_abap_behv=>mk-on
|
||||||
* field2 = if_abap_behv=>mk-on
|
field2 = if_abap_behv=>mk-on
|
||||||
* field3 = if_abap_behv=>mk-on
|
field3 = if_abap_behv=>mk-on
|
||||||
* field4 = if_abap_behv=>mk-on ) )
|
field4 = if_abap_behv=>mk-on ) )
|
||||||
* ( %key-key_field = 2
|
( %key-key_field = 2
|
||||||
* %control = VALUE #(
|
%control = VALUE #(
|
||||||
* field1 = if_abap_behv=>mk-on
|
field1 = if_abap_behv=>mk-on
|
||||||
* field2 = if_abap_behv=>mk-on
|
field2 = if_abap_behv=>mk-on
|
||||||
* field3 = if_abap_behv=>mk-on
|
field3 = if_abap_behv=>mk-on
|
||||||
* field4 = if_abap_behv=>mk-on ) ) ).
|
field4 = if_abap_behv=>mk-on ) ) ).
|
||||||
*
|
|
||||||
* rba_dyn = VALUE #(
|
rba_dyn = VALUE #(
|
||||||
* ( %key-key_field = 1
|
( %key-key_field = 1
|
||||||
* %control = VALUE #(
|
%control = VALUE #(
|
||||||
* key_ch = if_abap_behv=>mk-on
|
key_ch = if_abap_behv=>mk-on
|
||||||
* field_ch1 = if_abap_behv=>mk-on
|
field_ch1 = if_abap_behv=>mk-on
|
||||||
* field_ch2 = if_abap_behv=>mk-on ) )
|
field_ch2 = if_abap_behv=>mk-on ) )
|
||||||
* ( %key-key_field = 2
|
( %key-key_field = 2
|
||||||
* %control = VALUE #(
|
%control = VALUE #(
|
||||||
* key_ch = if_abap_behv=>mk-on
|
key_ch = if_abap_behv=>mk-on
|
||||||
* field_ch1 = if_abap_behv=>mk-on
|
field_ch1 = if_abap_behv=>mk-on
|
||||||
* field_ch2 = if_abap_behv=>mk-on ) ) ).
|
field_ch2 = if_abap_behv=>mk-on ) ) ).
|
||||||
*
|
|
||||||
* output->display( `Result if FULL parameter is ` &&
|
output->display( `Result if FULL parameter is ` &&
|
||||||
* `not flagged for RBA` ).
|
`not flagged for RBA` ).
|
||||||
*
|
|
||||||
* op_tab = VALUE #(
|
op_tab = VALUE #(
|
||||||
* ( op = if_abap_behv=>op-r-read
|
( op = if_abap_behv=>op-r-read
|
||||||
* entity_name = 'ZDEMO_ABAP_RAP_RO_U'
|
entity_name = 'ZDEMO_ABAP_RAP_RO_U'
|
||||||
* instances = REF #( read_dyn )
|
instances = REF #( read_dyn )
|
||||||
* results = REF #( read_dyn_result ) )
|
results = REF #( read_dyn_result ) )
|
||||||
* ( op = if_abap_behv=>op-r-read_ba
|
( op = if_abap_behv=>op-r-read_ba
|
||||||
* entity_name = 'ZDEMO_ABAP_RAP_RO_U'
|
entity_name = 'ZDEMO_ABAP_RAP_RO_U'
|
||||||
* sub_name = '_CHILD'
|
sub_name = '_CHILD'
|
||||||
* full = abap_false
|
full = abap_false
|
||||||
* instances = REF #( rba_dyn )
|
instances = REF #( rba_dyn )
|
||||||
* results = REF #( rba_dyn_result )
|
results = REF #( rba_dyn_result )
|
||||||
* links = REF #( rba_dyn_link ) ) ).
|
links = REF #( rba_dyn_link ) ) ).
|
||||||
*
|
|
||||||
* READ ENTITIES OPERATIONS op_tab.
|
READ ENTITIES OPERATIONS op_tab.
|
||||||
*
|
|
||||||
* output->display( input = read_dyn_result name = `read_dyn_result` ).
|
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_result name = `rba_dyn_result` ).
|
||||||
* output->display( input = rba_dyn_link name = `rba_dyn_link` ).
|
output->display( input = rba_dyn_link name = `rba_dyn_link` ).
|
||||||
*
|
|
||||||
* output->display( `Result if FULL parameter is ` &&
|
output->display( `Result if FULL parameter is ` &&
|
||||||
* `flagged for RBA` ).
|
`flagged for RBA` ).
|
||||||
*
|
|
||||||
* op_tab = VALUE #(
|
op_tab = VALUE #(
|
||||||
* ( op = if_abap_behv=>op-r-read
|
( op = if_abap_behv=>op-r-read
|
||||||
* entity_name = 'ZDEMO_ABAP_RAP_RO_U'
|
entity_name = 'ZDEMO_ABAP_RAP_RO_U'
|
||||||
* instances = REF #( read_dyn )
|
instances = REF #( read_dyn )
|
||||||
* results = REF #( read_dyn_result ) )
|
results = REF #( read_dyn_result ) )
|
||||||
* ( op = if_abap_behv=>op-r-read_ba
|
( op = if_abap_behv=>op-r-read_ba
|
||||||
* entity_name = 'ZDEMO_ABAP_RAP_RO_U'
|
entity_name = 'ZDEMO_ABAP_RAP_RO_U'
|
||||||
* sub_name = '_CHILD'
|
sub_name = '_CHILD'
|
||||||
* full = abap_true
|
full = abap_true
|
||||||
* instances = REF #( rba_dyn )
|
instances = REF #( rba_dyn )
|
||||||
* results = REF #( rba_dyn_result )
|
results = REF #( rba_dyn_result )
|
||||||
* links = REF #( rba_dyn_link ) ) ).
|
links = REF #( rba_dyn_link ) ) ).
|
||||||
*
|
|
||||||
* READ ENTITIES OPERATIONS op_tab.
|
READ ENTITIES OPERATIONS op_tab.
|
||||||
*
|
|
||||||
* output->display( input = read_dyn_result name = `read_dyn_result` ).
|
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_result name = `rba_dyn_result` ).
|
||||||
* output->display( input = rba_dyn_link name = `rba_dyn_link` ).
|
output->display( input = rba_dyn_link name = `rba_dyn_link` ).
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -61,13 +61,15 @@ ENDCLASS.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS zcl_demo_abap_sql IMPLEMENTATION.
|
CLASS ZCL_DEMO_ABAP_SQL IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD class_constructor.
|
METHOD class_constructor.
|
||||||
"Filling demo database tables.
|
"Filling demo database tables.
|
||||||
zcl_demo_abap_flight_tables=>fill_dbtabs( ).
|
zcl_demo_abap_flight_tables=>fill_dbtabs( ).
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
METHOD if_oo_adt_classrun~main.
|
METHOD if_oo_adt_classrun~main.
|
||||||
|
|
||||||
DATA(output) = NEW zcl_demo_abap_display( out ).
|
DATA(output) = NEW zcl_demo_abap_display( out ).
|
||||||
@@ -1588,6 +1590,7 @@ CLASS zcl_demo_abap_sql IMPLEMENTATION.
|
|||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
METHOD select_from_dbtab.
|
METHOD select_from_dbtab.
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM zdemo_abap_carr
|
FROM zdemo_abap_carr
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ ENDCLASS.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS zcl_demo_abap_sql_group_by IMPLEMENTATION.
|
CLASS ZCL_DEMO_ABAP_SQL_GROUP_BY IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD class_constructor.
|
METHOD class_constructor.
|
||||||
@@ -75,7 +75,7 @@ CLASS zcl_demo_abap_sql_group_by IMPLEMENTATION.
|
|||||||
FROM zdemo_abap_flsch
|
FROM zdemo_abap_flsch
|
||||||
INTO TABLE @DATA(fli_tab).
|
INTO TABLE @DATA(fli_tab).
|
||||||
|
|
||||||
output->next_section( `1) Representative Binding` ).
|
output->display( `1) Representative Binding` ).
|
||||||
output->display( `1a) Grouping by one column` ).
|
output->display( `1a) Grouping by one column` ).
|
||||||
|
|
||||||
LOOP AT fli_tab INTO wa
|
LOOP AT fli_tab INTO wa
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -51,7 +51,10 @@ CLASS zcl_demo_abap_string_proc DEFINITION
|
|||||||
PRIVATE SECTION.
|
PRIVATE SECTION.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
CLASS zcl_demo_abap_string_proc IMPLEMENTATION.
|
|
||||||
|
|
||||||
|
CLASS ZCL_DEMO_ABAP_STRING_PROC IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
METHOD if_oo_adt_classrun~main.
|
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
|
"The expression must be convertible to a string. A blank (not
|
||||||
"within the curly brackets) means a blank in the resulting string.
|
"within the curly brackets) means a blank in the resulting string.
|
||||||
DATA(str_c1) = `Hallo`. "String created with backquotes
|
DATA(str_c1) = `Hallo`.
|
||||||
DATA(str_c2) = `how`. "Strings created with pipes
|
DATA(str_c2) = `how`.
|
||||||
DATA(str_c3) = `are`.
|
DATA(str_c3) = `are`.
|
||||||
DATA(str_c4) = |{ str_c1 } { sy-uname }, | &&
|
DATA(str_c4) = |{ str_c1 } { sy-uname }, | &&
|
||||||
|{ str_c2 } { str_c3 } you?|.
|
|{ str_c2 } { str_c3 } you?|.
|
||||||
|
|
||||||
|
output->display( input = str_c4 name = `str_c4` ).
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
|
|
||||||
output->next_section( `3b) String Templates (2): Control Characters` ).
|
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 },| &&
|
DATA(str_c5) = |{ str_c1 }\n{ sy-uname },| &&
|
||||||
|\n{ str_c2 }\n{ str_c3 }\nyou?|.
|
|\n{ str_c2 }\n{ str_c3 }\nyou?|.
|
||||||
|
|
||||||
output->display( input = str_c4 name = `str_c4` ).
|
|
||||||
output->display( input = str_c5 name = `str_c5` ).
|
output->display( input = str_c5 name = `str_c5` ).
|
||||||
|
|
||||||
"Excursion: Class CL_ABAP_CHAR_UTILITIES provides attributes and methods as utilities for string processing.
|
"Excursion: Class CL_ABAP_CHAR_UTILITIES provides attributes and methods as utilities for string processing.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -108,7 +108,41 @@ protected section.
|
|||||||
ENDCLASS.
|
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.
|
METHOD if_oo_adt_classrun~main.
|
||||||
|
|
||||||
@@ -1116,40 +1150,12 @@ CLASS zcl_demo_abap_structures IMPLEMENTATION.
|
|||||||
|
|
||||||
ENDMETHOD.
|
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.
|
METHOD initialize_dbtabs.
|
||||||
DELETE FROM zdemo_abap_tab1.
|
DELETE FROM zdemo_abap_tab1.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
METHOD select_from_dbtab.
|
METHOD select_from_dbtab.
|
||||||
|
|
||||||
SELECT FROM zdemo_abap_tab1
|
SELECT FROM zdemo_abap_tab1
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -165,7 +165,338 @@ PRIVATE SECTION.
|
|||||||
|
|
||||||
ENDCLASS.
|
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(<i>).
|
||||||
|
|
||||||
|
IF greater_num MOD <i> <> 0.
|
||||||
|
DELETE common_divisors WHERE table_line = <i>.
|
||||||
|
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(<l>).
|
||||||
|
|
||||||
|
total_seatsmax_global_itf = total_seatsmax_global_itf + <l>-seatsmax.
|
||||||
|
total_seatsocc_global_itf = total_seatsocc_global_itf + <l>-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(<k>).
|
||||||
|
|
||||||
|
total_seatsmax_local_itf = total_seatsmax_local_itf + <k>-seatsmax.
|
||||||
|
total_seatsocc_local_itf = total_seatsocc_local_itf + <k>-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(<o>).
|
||||||
|
|
||||||
|
total_seatsmax_param_inj = total_seatsmax_param_inj + <o>-seatsmax.
|
||||||
|
total_seatsocc_param_inj = total_seatsocc_param_inj + <o>-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(<n>).
|
||||||
|
|
||||||
|
total_seatsmax_setter_inj = total_seatsmax_setter_inj + <n>-seatsmax.
|
||||||
|
total_seatsocc_setter_inj = total_seatsocc_setter_inj + <n>-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(<j>).
|
||||||
|
|
||||||
|
total_seatsmax_tm = total_seatsmax_tm + <j>-seatsmax.
|
||||||
|
total_seatsocc_tm = total_seatsocc_tm + <j>-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(<m>).
|
||||||
|
|
||||||
|
total_seatsmax_no = total_seatsmax_no + <m>-seatsmax.
|
||||||
|
total_seatsocc_no = total_seatsocc_no + <m>-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.
|
METHOD if_oo_adt_classrun~main.
|
||||||
"Note: The example includes a couple of implementations for the methods
|
"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 ).
|
DATA(output) = NEW zcl_demo_abap_display( out ).
|
||||||
|
|
||||||
output->display( `ABAP Cheat Sheet Example: ABAP Unit Tests` ).
|
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` ).
|
output->display( `1) get_sum Method` ).
|
||||||
"This method demonstrates the use of the setup and teardown methods in the test class.
|
"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.
|
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(<i>).
|
|
||||||
|
|
||||||
IF greater_num MOD <i> <> 0.
|
|
||||||
DELETE common_divisors WHERE table_line = <i>.
|
|
||||||
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(<j>).
|
|
||||||
|
|
||||||
total_seatsmax_tm = total_seatsmax_tm + <j>-seatsmax.
|
|
||||||
total_seatsocc_tm = total_seatsocc_tm + <j>-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(<k>).
|
|
||||||
|
|
||||||
total_seatsmax_local_itf = total_seatsmax_local_itf + <k>-seatsmax.
|
|
||||||
total_seatsocc_local_itf = total_seatsocc_local_itf + <k>-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(<l>).
|
|
||||||
|
|
||||||
total_seatsmax_global_itf = total_seatsmax_global_itf + <l>-seatsmax.
|
|
||||||
total_seatsocc_global_itf = total_seatsocc_global_itf + <l>-seatsocc.
|
|
||||||
|
|
||||||
ENDLOOP.
|
|
||||||
|
|
||||||
occupancy_rate = total_seatsocc_global_itf / total_seatsmax_global_itf * 100.
|
|
||||||
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD select_flight_data.
|
METHOD select_flight_data.
|
||||||
"Method that is identified as DOC in the method implementations above.
|
"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.
|
INTO CORRESPONDING FIELDS OF TABLE @flight_data.
|
||||||
ENDMETHOD.
|
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(<m>).
|
|
||||||
|
|
||||||
total_seatsmax_no = total_seatsmax_no + <m>-seatsmax.
|
|
||||||
total_seatsocc_no = total_seatsocc_no + <m>-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(<n>).
|
|
||||||
|
|
||||||
total_seatsmax_setter_inj = total_seatsmax_setter_inj + <n>-seatsmax.
|
|
||||||
total_seatsocc_setter_inj = total_seatsocc_setter_inj + <n>-seatsocc.
|
|
||||||
|
|
||||||
ENDLOOP.
|
|
||||||
|
|
||||||
occupancy_rate = total_seatsocc_setter_inj / total_seatsmax_setter_inj * 100.
|
|
||||||
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD setter_meth.
|
METHOD setter_meth.
|
||||||
"Method to demonstrate the test double injection using setter injection
|
"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.
|
"i.e. the local test double is injected.
|
||||||
data_provider_setter_inj = data_prov.
|
data_provider_setter_inj = data_prov.
|
||||||
ENDMETHOD.
|
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(<o>).
|
|
||||||
|
|
||||||
total_seatsmax_param_inj = total_seatsmax_param_inj + <o>-seatsmax.
|
|
||||||
total_seatsocc_param_inj = total_seatsocc_param_inj + <o>-seatsocc.
|
|
||||||
|
|
||||||
ENDLOOP.
|
|
||||||
|
|
||||||
occupancy_rate = total_seatsocc_param_inj / total_seatsmax_param_inj * 100.
|
|
||||||
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
@@ -5,11 +5,11 @@
|
|||||||
<VSEOCLASS>
|
<VSEOCLASS>
|
||||||
<CLSNAME>ZCL_DEMO_ABAP_UNIT_TEST</CLSNAME>
|
<CLSNAME>ZCL_DEMO_ABAP_UNIT_TEST</CLSNAME>
|
||||||
<LANGU>E</LANGU>
|
<LANGU>E</LANGU>
|
||||||
<DESCRIPT>ABAP cheat sheet: Unit test</DESCRIPT>
|
<DESCRIPT>ABAP cheat sheet: Unit tests</DESCRIPT>
|
||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<CLSCCINCL>X</CLSCCINCL>
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
<FIXPT>X</FIXPT>
|
<FIXPT>X</FIXPT>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
<WITH_UNIT_TESTS>X</WITH_UNIT_TESTS>
|
<WITH_UNIT_TESTS>X</WITH_UNIT_TESTS>
|
||||||
</VSEOCLASS>
|
</VSEOCLASS>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
<MASTERLANG>E</MASTERLANG>
|
<MASTERLANG>E</MASTERLANG>
|
||||||
<CONTFLAG>A</CONTFLAG>
|
<CONTFLAG>A</CONTFLAG>
|
||||||
<EXCLASS>1</EXCLASS>
|
<EXCLASS>1</EXCLASS>
|
||||||
<ABAP_LANGUAGE_VERSION>5</ABAP_LANGUAGE_VERSION>
|
|
||||||
</DD02V>
|
</DD02V>
|
||||||
<DD09L>
|
<DD09L>
|
||||||
<TABNAME>ZDEMO_ABAP_CARR</TABNAME>
|
<TABNAME>ZDEMO_ABAP_CARR</TABNAME>
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
<MAINFLAG>X</MAINFLAG>
|
<MAINFLAG>X</MAINFLAG>
|
||||||
<CONTFLAG>A</CONTFLAG>
|
<CONTFLAG>A</CONTFLAG>
|
||||||
<EXCLASS>1</EXCLASS>
|
<EXCLASS>1</EXCLASS>
|
||||||
<ABAP_LANGUAGE_VERSION>5</ABAP_LANGUAGE_VERSION>
|
|
||||||
</DD02V>
|
</DD02V>
|
||||||
<DD09L>
|
<DD09L>
|
||||||
<TABNAME>ZDEMO_ABAP_DRAFT</TABNAME>
|
<TABNAME>ZDEMO_ABAP_DRAFT</TABNAME>
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
<MASTERLANG>E</MASTERLANG>
|
<MASTERLANG>E</MASTERLANG>
|
||||||
<CONTFLAG>A</CONTFLAG>
|
<CONTFLAG>A</CONTFLAG>
|
||||||
<EXCLASS>1</EXCLASS>
|
<EXCLASS>1</EXCLASS>
|
||||||
<ABAP_LANGUAGE_VERSION>5</ABAP_LANGUAGE_VERSION>
|
|
||||||
</DD02V>
|
</DD02V>
|
||||||
<DD09L>
|
<DD09L>
|
||||||
<TABNAME>ZDEMO_ABAP_FLI</TABNAME>
|
<TABNAME>ZDEMO_ABAP_FLI</TABNAME>
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
<MAINFLAG>X</MAINFLAG>
|
<MAINFLAG>X</MAINFLAG>
|
||||||
<CONTFLAG>A</CONTFLAG>
|
<CONTFLAG>A</CONTFLAG>
|
||||||
<EXCLASS>1</EXCLASS>
|
<EXCLASS>1</EXCLASS>
|
||||||
<ABAP_LANGUAGE_VERSION>5</ABAP_LANGUAGE_VERSION>
|
|
||||||
</DD02V>
|
</DD02V>
|
||||||
<DD09L>
|
<DD09L>
|
||||||
<TABNAME>ZDEMO_ABAP_FLSCH</TABNAME>
|
<TABNAME>ZDEMO_ABAP_FLSCH</TABNAME>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<DESCRIPT>Interface for ABAP cheat sheet example</DESCRIPT>
|
<DESCRIPT>Interface for ABAP cheat sheet example</DESCRIPT>
|
||||||
<EXPOSURE>2</EXPOSURE>
|
<EXPOSURE>2</EXPOSURE>
|
||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOINTERF>
|
</VSEOINTERF>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<DESCRIPT>Interface for ABAP cheat sheet example</DESCRIPT>
|
<DESCRIPT>Interface for ABAP cheat sheet example</DESCRIPT>
|
||||||
<EXPOSURE>2</EXPOSURE>
|
<EXPOSURE>2</EXPOSURE>
|
||||||
<STATE>1</STATE>
|
<STATE>1</STATE>
|
||||||
<UNICODE>5</UNICODE>
|
<UNICODE>X</UNICODE>
|
||||||
</VSEOINTERF>
|
</VSEOINTERF>
|
||||||
</asx:values>
|
</asx:values>
|
||||||
</asx:abap>
|
</asx:abap>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
managed implementation in class zbp_demo_abap_rap_draft_m unique;
|
managed implementation in class zbp_demo_abap_rap_draft_m unique;
|
||||||
strict;
|
strict(2);
|
||||||
with draft;
|
with draft;
|
||||||
|
|
||||||
define behavior for ZDEMO_ABAP_RAP_DRAFT_M alias calc
|
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; }
|
determination det_modify on modify { field num1, num2, arithm_op; }
|
||||||
draft action Resume;
|
draft action Resume;
|
||||||
draft action Edit;
|
draft action Edit;
|
||||||
//As of release 2308: Draft action "Activate" should be defined as "optimized"
|
draft action Activate 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 Discard;
|
draft action Discard;
|
||||||
draft determine action Prepare
|
draft determine action Prepare
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,12 +14,6 @@
|
|||||||
<REL>http://www.sap.com/adt/relations/versions</REL>
|
<REL>http://www.sap.com/adt/relations/versions</REL>
|
||||||
<TITLE>Historic versions</TITLE>
|
<TITLE>Historic versions</TITLE>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<HREF>/sap/bc/adt/repository/informationsystem/abaplanguageversions?uri=%2Fsap%2Fbc%2Fadt%2Fbo%2Fbehaviordefinitions%2Fzdemo_abap_rap_draft_m</HREF>
|
|
||||||
<REL>http://www.sap.com/adt/relations/informationsystem/abaplanguageversions</REL>
|
|
||||||
<TYPE>application/vnd.sap.adt.nameditems.v1+xml</TYPE>
|
|
||||||
<TITLE>Allowed ABAP language versions</TITLE>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<HREF>./zdemo_abap_rap_draft_m/source/main</HREF>
|
<HREF>./zdemo_abap_rap_draft_m/source/main</HREF>
|
||||||
<REL>http://www.sap.com/adt/relations/source</REL>
|
<REL>http://www.sap.com/adt/relations/source</REL>
|
||||||
@@ -32,11 +26,6 @@
|
|||||||
<TYPE>text/html</TYPE>
|
<TYPE>text/html</TYPE>
|
||||||
<TITLE>Source Content (HTML)</TITLE>
|
<TITLE>Source Content (HTML)</TITLE>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<HREF>./zdemo_abap_rap_draft_m/objectstructure</HREF>
|
|
||||||
<REL>http://www.sap.com/adt/relations/objectstructure</REL>
|
|
||||||
<TITLE>Object Structure</TITLE>
|
|
||||||
</item>
|
|
||||||
</LINKS>
|
</LINKS>
|
||||||
<MASTER_LANGUAGE>EN</MASTER_LANGUAGE>
|
<MASTER_LANGUAGE>EN</MASTER_LANGUAGE>
|
||||||
<ABAP_LANGU_VERSION>5</ABAP_LANGU_VERSION>
|
<ABAP_LANGU_VERSION>5</ABAP_LANGU_VERSION>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
managed implementation in class zbp_demo_abap_rap_ro_m unique;
|
managed implementation in class zbp_demo_abap_rap_ro_m unique;
|
||||||
strict;
|
strict(2);
|
||||||
|
|
||||||
define behavior for ZDEMO_ABAP_RAP_RO_M alias root
|
define behavior for ZDEMO_ABAP_RAP_RO_M alias root
|
||||||
persistent table zdemo_abap_rapt1
|
persistent table zdemo_abap_rapt1
|
||||||
|
|||||||
@@ -14,12 +14,6 @@
|
|||||||
<REL>http://www.sap.com/adt/relations/versions</REL>
|
<REL>http://www.sap.com/adt/relations/versions</REL>
|
||||||
<TITLE>Historic versions</TITLE>
|
<TITLE>Historic versions</TITLE>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<HREF>/sap/bc/adt/repository/informationsystem/abaplanguageversions?uri=%2Fsap%2Fbc%2Fadt%2Fbo%2Fbehaviordefinitions%2Fzdemo_abap_rap_ro_m</HREF>
|
|
||||||
<REL>http://www.sap.com/adt/relations/informationsystem/abaplanguageversions</REL>
|
|
||||||
<TYPE>application/vnd.sap.adt.nameditems.v1+xml</TYPE>
|
|
||||||
<TITLE>Allowed ABAP language versions</TITLE>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<HREF>./zdemo_abap_rap_ro_m/source/main</HREF>
|
<HREF>./zdemo_abap_rap_ro_m/source/main</HREF>
|
||||||
<REL>http://www.sap.com/adt/relations/source</REL>
|
<REL>http://www.sap.com/adt/relations/source</REL>
|
||||||
@@ -32,11 +26,6 @@
|
|||||||
<TYPE>text/html</TYPE>
|
<TYPE>text/html</TYPE>
|
||||||
<TITLE>Source Content (HTML)</TITLE>
|
<TITLE>Source Content (HTML)</TITLE>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<HREF>./zdemo_abap_rap_ro_m/objectstructure</HREF>
|
|
||||||
<REL>http://www.sap.com/adt/relations/objectstructure</REL>
|
|
||||||
<TITLE>Object Structure</TITLE>
|
|
||||||
</item>
|
|
||||||
</LINKS>
|
</LINKS>
|
||||||
<MASTER_LANGUAGE>EN</MASTER_LANGUAGE>
|
<MASTER_LANGUAGE>EN</MASTER_LANGUAGE>
|
||||||
<ABAP_LANGU_VERSION>5</ABAP_LANGU_VERSION>
|
<ABAP_LANGU_VERSION>5</ABAP_LANGU_VERSION>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
unmanaged implementation in class zbp_demo_abap_rap_ro_u unique;
|
unmanaged implementation in class zbp_demo_abap_rap_ro_u unique;
|
||||||
strict;
|
strict(2);
|
||||||
|
|
||||||
define behavior for ZDEMO_ABAP_RAP_RO_U alias root
|
define behavior for ZDEMO_ABAP_RAP_RO_U alias root
|
||||||
lock master
|
lock master
|
||||||
|
|||||||
@@ -14,12 +14,6 @@
|
|||||||
<REL>http://www.sap.com/adt/relations/versions</REL>
|
<REL>http://www.sap.com/adt/relations/versions</REL>
|
||||||
<TITLE>Historic versions</TITLE>
|
<TITLE>Historic versions</TITLE>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<HREF>/sap/bc/adt/repository/informationsystem/abaplanguageversions?uri=%2Fsap%2Fbc%2Fadt%2Fbo%2Fbehaviordefinitions%2Fzdemo_abap_rap_ro_u</HREF>
|
|
||||||
<REL>http://www.sap.com/adt/relations/informationsystem/abaplanguageversions</REL>
|
|
||||||
<TYPE>application/vnd.sap.adt.nameditems.v1+xml</TYPE>
|
|
||||||
<TITLE>Allowed ABAP language versions</TITLE>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<HREF>./zdemo_abap_rap_ro_u/source/main</HREF>
|
<HREF>./zdemo_abap_rap_ro_u/source/main</HREF>
|
||||||
<REL>http://www.sap.com/adt/relations/source</REL>
|
<REL>http://www.sap.com/adt/relations/source</REL>
|
||||||
@@ -32,11 +26,6 @@
|
|||||||
<TYPE>text/html</TYPE>
|
<TYPE>text/html</TYPE>
|
||||||
<TITLE>Source Content (HTML)</TITLE>
|
<TITLE>Source Content (HTML)</TITLE>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<HREF>./zdemo_abap_rap_ro_u/objectstructure</HREF>
|
|
||||||
<REL>http://www.sap.com/adt/relations/objectstructure</REL>
|
|
||||||
<TITLE>Object Structure</TITLE>
|
|
||||||
</item>
|
|
||||||
</LINKS>
|
</LINKS>
|
||||||
<MASTER_LANGUAGE>EN</MASTER_LANGUAGE>
|
<MASTER_LANGUAGE>EN</MASTER_LANGUAGE>
|
||||||
<ABAP_LANGU_VERSION>5</ABAP_LANGU_VERSION>
|
<ABAP_LANGU_VERSION>5</ABAP_LANGU_VERSION>
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
<MAINFLAG>X</MAINFLAG>
|
<MAINFLAG>X</MAINFLAG>
|
||||||
<CONTFLAG>A</CONTFLAG>
|
<CONTFLAG>A</CONTFLAG>
|
||||||
<EXCLASS>1</EXCLASS>
|
<EXCLASS>1</EXCLASS>
|
||||||
<ABAP_LANGUAGE_VERSION>5</ABAP_LANGUAGE_VERSION>
|
|
||||||
</DD02V>
|
</DD02V>
|
||||||
<DD09L>
|
<DD09L>
|
||||||
<TABNAME>ZDEMO_ABAP_RAPT1</TABNAME>
|
<TABNAME>ZDEMO_ABAP_RAPT1</TABNAME>
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
<MAINFLAG>X</MAINFLAG>
|
<MAINFLAG>X</MAINFLAG>
|
||||||
<CONTFLAG>A</CONTFLAG>
|
<CONTFLAG>A</CONTFLAG>
|
||||||
<EXCLASS>1</EXCLASS>
|
<EXCLASS>1</EXCLASS>
|
||||||
<ABAP_LANGUAGE_VERSION>5</ABAP_LANGUAGE_VERSION>
|
|
||||||
</DD02V>
|
</DD02V>
|
||||||
<DD09L>
|
<DD09L>
|
||||||
<TABNAME>ZDEMO_ABAP_RAPT2</TABNAME>
|
<TABNAME>ZDEMO_ABAP_RAPT2</TABNAME>
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
<MAINFLAG>X</MAINFLAG>
|
<MAINFLAG>X</MAINFLAG>
|
||||||
<CONTFLAG>A</CONTFLAG>
|
<CONTFLAG>A</CONTFLAG>
|
||||||
<EXCLASS>1</EXCLASS>
|
<EXCLASS>1</EXCLASS>
|
||||||
<ABAP_LANGUAGE_VERSION>5</ABAP_LANGUAGE_VERSION>
|
|
||||||
</DD02V>
|
</DD02V>
|
||||||
<DD09L>
|
<DD09L>
|
||||||
<TABNAME>ZDEMO_ABAP_TAB1</TABNAME>
|
<TABNAME>ZDEMO_ABAP_TAB1</TABNAME>
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
<MAINFLAG>X</MAINFLAG>
|
<MAINFLAG>X</MAINFLAG>
|
||||||
<CONTFLAG>A</CONTFLAG>
|
<CONTFLAG>A</CONTFLAG>
|
||||||
<EXCLASS>1</EXCLASS>
|
<EXCLASS>1</EXCLASS>
|
||||||
<ABAP_LANGUAGE_VERSION>5</ABAP_LANGUAGE_VERSION>
|
|
||||||
</DD02V>
|
</DD02V>
|
||||||
<DD09L>
|
<DD09L>
|
||||||
<TABNAME>ZDEMO_ABAP_TAB2</TABNAME>
|
<TABNAME>ZDEMO_ABAP_TAB2</TABNAME>
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
<MAINFLAG>X</MAINFLAG>
|
<MAINFLAG>X</MAINFLAG>
|
||||||
<CONTFLAG>A</CONTFLAG>
|
<CONTFLAG>A</CONTFLAG>
|
||||||
<EXCLASS>1</EXCLASS>
|
<EXCLASS>1</EXCLASS>
|
||||||
<ABAP_LANGUAGE_VERSION>5</ABAP_LANGUAGE_VERSION>
|
|
||||||
</DD02V>
|
</DD02V>
|
||||||
<DD09L>
|
<DD09L>
|
||||||
<TABNAME>ZDEMO_ABAP_TABCA</TABNAME>
|
<TABNAME>ZDEMO_ABAP_TABCA</TABNAME>
|
||||||
|
|||||||
Reference in New Issue
Block a user