Update content

This commit is contained in:
danrega
2023-06-29 15:43:51 +02:00
parent 43e5f2dc2f
commit b4cac3ae22
12 changed files with 58 additions and 56 deletions

View File

@@ -721,7 +721,7 @@ operator](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?f
`FILTER` operator constructs an internal table according to a specified type (which can be an explicitly specified, non-generic table type or the `#` character as a symbol for the [operand type](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenoperand_type_glosry.htm) before the first parenthesis).
- The lines for the new internal table are taken from an
existing internal table based on conditions specified in a `WHERE` clause. Note that the table type of the existing internal table must be convertible into the specified target type.
- The conditions can either be based on either single values or a [filter
- The conditions can be based on either single values or a [filter
table](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenconstructor_expr_filter_table.htm).
- Additions:
@@ -733,7 +733,7 @@ operator](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?f
Examples:
```abap
"FILTER on conditions based on single values
"Assumption the component num is of type i.
"Assumption: The component num is of type i.
DATA itab1 TYPE SORTED TABLE OF struc WITH NON-UNIQUE KEY num.
DATA itab2 TYPE STANDARD TABLE OF struc WITH NON-UNIQUE SORTED KEY sec_key COMPONENTS num.
DATA itab3 TYPE HASHED TABLE OF struc WITH UNIQUE KEY num.
@@ -857,10 +857,10 @@ functionality, your use case, the
performance or readability of the code may play a role. For more information, see
the programming guidelines for the [target
area (F1 docu for standard ABAP)](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abentable_output_guidl.htm "Guideline").
An obvious use case for `INTO dobj` is when the table should
A use case for `INTO dobj` is when the table should
not be changed using the copied table line. However, copying comes
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 of course 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).
<p align="right">(<a href="#top">back to top</a>)</p>
@@ -871,6 +871,7 @@ The following example shows `READ TABLE` statements to read a single line from a
key, the addition can be specified and the line to be read is then determined from its secondary table index. If the primary table key is
specified by its name `primary_key`, the table must be an index table, and the behavior is the same as if `USING KEY` was
not specified.
Note that the examples only show reading into a work area. Other targets are possible as shown above.
``` abap
READ TABLE itab INTO wa INDEX i.
@@ -885,21 +886,22 @@ not found results in an runtime error. To avoid an error, you can
use a [`TRY ... CATCH ... ENDTRY.`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaptry.htm) block.
``` abap
DATA(lv1) = itab[ i ].
"In the examples, integer values are specified for the index.
DATA(lv1) = itab[ 1 ].
TRY.
DATA(lv2) = itab[ i ].
DATA(lv2) = itab[ 2 ].
CATCH cx_sy_itab_line_not_found.
...
ENDTRY.
DATA(lv3) = itab[ KEY primary_key INDEX i ].
DATA(lv3) = itab[ KEY primary_key INDEX 3 ].
"Copying a table line via table expression and embedding in constructor expression
DATA(lv4) = VALUE #( itab[ i ] ).
DATA(lv4) = VALUE #( itab[ 4 ] ).
"Reading into data reference variable using the REF operator
DATA(lv5_ref) = REF #( itab[ i ] ).
DATA(lv5_ref) = REF #( itab[ 5 ] ).
```
When you read a non-existent line using a table expression, you may not want to throw an exception. You can also embed the table expression
@@ -909,9 +911,9 @@ Alternatively, you can use the `DEFAULT` addition to return a
default line in case of an unsuccessful read operation, which can also be another table expression or constructor expression.
``` abap
DATA(line1) = VALUE #( itab[ i ] OPTIONAL ).
DATA(line1) = VALUE #( itab[ 6 ] OPTIONAL ).
DATA(line2) = VALUE #( itab[ i ] DEFAULT itab[ i2 ] ).
DATA(line2) = VALUE #( itab[ 7 ] DEFAULT itab[ 8 ] ).
```
<p align="right">(<a href="#top">back to top</a>)</p>
@@ -921,7 +923,7 @@ DATA(line2) = VALUE #( itab[ i ] DEFAULT itab[ i2 ] ).
Lines can be read by explicitly specifying the table keys or the alias names, if any.
```abap
"Example internal table with primary and secondary key and alias names
"Assumption: all components are of type i
"Assumption: All components are of type i
DATA it TYPE SORTED TABLE OF struc
WITH NON-UNIQUE KEY primary_key ALIAS pk COMPONENTS a b
@@ -1131,7 +1133,8 @@ should do so immediately after the `LOOP` statement to avoid possible overwritin
*Restricting the area of the table to be looped over*
The additions of `LOOP` statements come into play when you want to restrict the table content to be respected by the loop because
you do not want to loop over the entire table.
you do not want to loop over the entire table. Note that the examples only show work areas as target objects to hold the table line read.
Other options are possible as shown above.
``` abap
"FROM/TO: Only for index tables
@@ -1447,7 +1450,7 @@ statements allow you to delete the entire table content.
The difference between the two is in the handling of the memory space originally allocated to the table. When a table is cleared with `CLEAR`,
the content are removed, but the memory space initially requested remains
allocated. If the table is filled again later, the memory space is still
available, which is a performance advantag over
available, which is a performance advantage over
clearing an internal table with `FREE`. Such a statement also
deletes the table content, but it also releases the memory
space.

View File

@@ -138,7 +138,7 @@ SELECT FROM source "What database table or view to read from
```
> **💡 Note**<br>
>- There are further clauses available of which some are dealt with
further down. In general, the recommendation is to hit `F1` for the keywords and additions to get the all the details in the ABAP Keyword Documentation.
further down. In general, the recommendation is to hit `F1` for the keywords and additions to get all the details in the ABAP Keyword Documentation.
>- Especially in older ABAP programs, you will see other forms of the
`SELECT` syntax that you should no longer use. Strict syntax check modes might enforce the use
of specific ABAP SQL syntax. For example, the `INTO` clause should be placed after the other clauses. Furthermore, [host variables](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenhost_variable_glosry.htm "Glossary Entry") or [host expressions](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenhost_expression_glosry.htm "Glossary Entry") are required for data objects and expressions, i. e. they must be preceded by `@` or `@( ... )`. Further information: [Release-Dependent Syntax Check Modes (F1 docu for standard ABAP)](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap_sql_strict_modes.htm).
@@ -1099,33 +1099,33 @@ SELECT *
WHERE comp1 = 'abc' "Equals some value
"More example WHERE conditions:
comp2 > 100 "Greater than some value; alternatively GT is possible
AND comp2 > 100 "Greater than some value; alternatively GT is possible
"Not equals plus an additional condition that must be respected
comp3 <> 100 AND comp4 = 'xyz'
AND comp3 <> 100 AND comp4 = 'xyz'
"(Not) between a value range
comp5 BETWEEN 1 AND 10
comp6 NOT BETWEEN 1 AND 10
AND comp5 BETWEEN 1 AND 10
AND comp6 NOT BETWEEN 1 AND 10
"A character literal has a certain pattern, preceded and
"followed by any string.
"comp7 LIKE '%XYZ%'
AND comp7 LIKE '%XYZ%'
"The second character is not Y. _ stands for any character.
comp8 NOT LIKE '_Y%'
AND comp8 NOT LIKE '_Y%'
"Contains one of the values specified in the parentheses
comp9 IN ( 'ABC', 'DEF', 'GHI' )
AND comp9 IN ( 'ABC', 'DEF', 'GHI' )
"Does not contain one of the values specified in the parentheses
comp10 NOT IN ( 'JKL', 'MNO' )
AND comp10 NOT IN ( 'JKL', 'MNO' )
"Checking if an operand has an initial value
comp11 IS INITIAL
AND comp11 IS INITIAL
"Combination of logical expression using AND, OR and parentheses
( comp12 = a AND comp13 < b ) OR ( comp14 > c AND comp15 <> d )
AND ( comp12 = a AND comp13 < b ) OR ( comp14 > c AND comp15 <> d )
INTO TABLE @DATA(itab_where).
```

View File

@@ -1100,12 +1100,9 @@ CLASS global_class DEFINITION CREATE PUBLIC FRIENDS other_global_class ... .
- [Events](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenevent_glosry.htm "Glossary Entry")
can trigger the processing of [processing blocks](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenprocessing_block_glosry.htm "Glossary Entry").
- Declaring events: Can be declared in a visibility section of the declaration part of a class or in an interface, e. g. as
- instance event using an
[`EVENTS`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapevents.htm)
statement. Note that they can only be raised in instance methods of the same class.
- static event using
[`CLASS-EVENTS`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapclass-events.htm). They can be raised in all methods of the same class or of a class that implements the interface. Static event handlers can be called by the event independently of an instance of the class.
- Declaring events: Can be declared in a visibility section of the declaration part of a class or in an interface, e. g. as
- instance event using an [`EVENTS`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapevents.htm) statement. Note that they can only be raised in instance methods of the same class.
- static event using [`CLASS-EVENTS`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapclass-events.htm). They can be raised in all methods of the same class or of a class that implements the interface. Static event handlers can be called by the event independently of an instance of the class.
``` abap
"Declaration part of a class/interface

View File

@@ -501,7 +501,7 @@ Examples:
"Result: 0.2
DATA(a) = CONV decfloat34( 1 / 5 ).
"Comparison with an expression without CONV; the result is 0
"Comparison with an expression without CONV; the result is 0, the data type is i
DATA(b) = 1 / 5.
```
@@ -519,13 +519,16 @@ DATA(c) = CONV decfloat34( '0.4' ).
"Instead of
DATA d TYPE decfloat34 VALUE '0.4'.
"or
DATA e TYPE decfloat34.
e = '0.4'.
"Redundant conversion
"Derives the string type automatically
DATA(e) = `hallo`.
DATA(f) = `hallo`.
"Produces a syntax warning
"DATA(f) = CONV string( `hallo` ).
"DATA(g) = CONV string( `hallo` ).
```

View File

@@ -90,8 +90,7 @@ ENDLOOP.
> **💡 Note**<br>
>- After its declaration, a field symbol is initial, i. e. a memory area is not (yet) assigned to it (apart from the inline declaration). If you use an unassigned field symbol, an exception is raised.
>- There are plenty of options for generic ABAP types. A prominent one
is `data` that stands for any data type (the older generic
type `any` has the same effect). See more information in the
is `data` that stands for any data type. See more information in the
topic [Generic ABAP
Types](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenbuilt_in_types_generic.htm).
>- Field symbols cannot be declared in the declaration part of
@@ -268,7 +267,7 @@ data object](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.ht
at runtime by assigning the reference to the data object of a data reference variable. You can use the [instance
operator](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abeninstance_operator_glosry.htm "Glossary Entry")
[`NEW`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenconstructor_expression_new.htm).
It replaces the older syntax [`CREATE DATA`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapcreate_data.htm). However, as shown further, `CREATE DATA` is required for specifying a dynamically determined type.
It replaces the older syntax [`CREATE DATA`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapcreate_data.htm). However, as shown below, `CREATE DATA` is required for specifying a dynamically determined type.
``` abap
"Declaring data reference variables
@@ -365,7 +364,7 @@ ref5 = CAST #( ref6 ).
Before addressing the content of data objects a data reference points to, you must dereference data reference variables. Use the
[dereferencing operator](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abendereferencing_operat_glosry.htm "Glossary Entry")
`->*`. To check if dereferncing works, you can use a logical expression with [`IS BOUND`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenlogexp_bound.htm).
`->*`. To check if dereferencing works, you can use a logical expression with [`IS BOUND`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenlogexp_bound.htm).
``` abap
"Creating data reference variables and assign values
@@ -580,10 +579,10 @@ Note that dynamically specifying syntax elements has downsides, too. Consider so
ENDLOOP.
```
- ASSIGN statements
- `ASSIGN` statements
``` abap
"Accessing components of structures dynamically
"Dynamically accessing components of structures
"Populating a structure
SELECT SINGLE *
@@ -691,7 +690,7 @@ Note that dynamically specifying syntax elements has downsides, too. Consider so
"in place. The advantage is that the data type is constructed in a suitable way.
SELECT *
FROM (db_table)
INTO TABLE NEW @DATA(a_dobj).
INTO TABLE NEW @DATA(dref_tab).
"Dynamic WHERE clause
"This is an example for using an internal table with a character-like row type

View File

@@ -430,7 +430,7 @@ and
[`to_upper`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencase_functions.htm)
transform characters of a string to either lowercase or uppercase and
store the result in a target variable.
- If you want ot apply the transformation directly to the source directly, you can use
- If you want to apply the transformation to the source directly, you can use
[`TRANSLATE`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaptranslate.htm)
statements.

View File

@@ -388,7 +388,7 @@ WITH
        ( SELECT FROM demo_cds_simple_tree( p_id = @root_id )
                 FIELDS * )
          WITH HIERARCHY demo_cds_simple_tree
SELECT FROM  +tree "hierarchy ]
SELECT FROM  +tree "hierarchy
             FIELDS id,
                    parent,
                    name,
@@ -416,7 +416,7 @@ WITH
                   parent,
                   name )
          WITH HIERARCHY asql_hierarchy
SELECT FROM +tree "hierarchy ]
SELECT FROM +tree "hierarchy
             FIELDS id,
                    parent,
                    name,
@@ -452,7 +452,7 @@ WITH
                   parent,
                   name  )
            WITH HIERARCHY cte_hierarchy
SELECT FROM +tree "hierarchy ]
SELECT FROM +tree "hierarchy
             FIELDS id,
                    parent,
                    name,

View File

@@ -1,8 +1,8 @@
<a name="top"></a>
# A Glimpse on AMDP
# ABAP Managed Database Procedures (AMDP)
- [A Glimpse on AMDP](#a-glimpse-on-amdp)
- [ABAP Managed Database Procedures (AMDP)](#abap-managed-database-procedures-amdp)
- [About AMDP](#about-amdp)
- [AMDP Classes](#amdp-classes)
- [AMDP Methods](#amdp-methods)

View File

@@ -1,8 +1,8 @@
<a name="top"></a>
# A Glimpse on ABAP Unit Tests
# ABAP Unit Tests
- [A Glimpse on ABAP Unit Tests](#a-glimpse-on-abap-unit-tests)
- [ABAP Unit Tests](#abap-unit-tests)
- [Unit Tests in ABAP](#unit-tests-in-abap)
- [High-Level Steps for ABAP Unit Tests](#high-level-steps-for-abap-unit-tests)
- [Creating Test Classes](#creating-test-classes)

View File

@@ -57,7 +57,7 @@ ABAP cheat sheets[^1] ...
| Cheat Sheet | Topics Covered | Demo Example |
| ------------- | ------------- | ----- |
|[Data Types and Data Objects](16_Data_Types_and_Objects.md)| The basics of data types and data objects in ABAP. | [zcl_demo_abap_dtype_dobj](./src/zcl_demo_abap_dtype_dobj.clas.abap) |
|[Data Types and Data Objects](16_Data_Types_and_Objects.md)| Contains basic information about data types and data objects in ABAP | [zcl_demo_abap_dtype_dobj](./src/zcl_demo_abap_dtype_dobj.clas.abap) |
|[Working with Internal Tables](01_Internal_Tables.md)| Creating, filling, reading from, sorting, modifying internal tables | [zcl_demo_abap_internal_tables](./src/zcl_demo_abap_internal_tables.clas.abap) |
|[Working with Structures](02_Structures.md)| Creating structures and structured types, variants of structures, accessing components of structures, filling structures, clearing structures, structures in use in the context of tables | [zcl_demo_abap_structures](./src/zcl_demo_abap_structures.clas.abap) |
|[ABAP SQL in Use](03_ABAP_SQL.md)| Reading from database tables using `SELECT`, changing data in database tables using `INSERT`, `UPDATE`, `MODIFY` and `DELETE` | [zcl_demo_abap_sql](./src/zcl_demo_abap_sql.clas.abap) |
@@ -69,9 +69,9 @@ ABAP cheat sheets[^1] ...
|[Excursion Down to Bits and Bytes](09_Bits_and_Bytes.md)|Covers the technical background of data types and data objects|-|
|[ABAP SQL: Working with Hierarchies](10_ABAP_SQL_Hierarchies.md)|Summarizes the functions ABAP SQL offers together with ABAP CDS for working with hierarchical data that is stored in database tables|-|
|[ABAP SQL: Grouping Internal Tables](11_ABAP_SQL_Grouping_Internal_Tables.md)|Covers the `GROUP BY` clause in ABAP SQL|[zcl_demo_abap_sql_group_by](./src/zcl_demo_abap_sql_group_by.clas.abap)|
|[A Glimpse on AMDP](12_AMDP.md)|Covers ABAP Managed Database Procedures (AMDP): AMDP Procedures and AMDP Functions (including CDS Table Functions)|[zcl_demo_abap_amdp](./src/zcl_demo_abap_amdp.clas.abap)|
|[ABAP Managed Database Procedures (AMDP)](12_AMDP.md)|Covers ABAP Managed Database Procedures (AMDP): AMDP Procedures and AMDP Functions (including CDS Table Functions)|[zcl_demo_abap_amdp](./src/zcl_demo_abap_amdp.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)|
|[A Glimpse on 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)|
<br>

View File

@@ -1,6 +1,6 @@
***********************************************************************
*
* ABAP Cheat Sheet: A Glimpse on ABAP Unit Tests
* ABAP Cheat Sheet: ABAP Unit Tests
*
* -------------------------- PURPOSE ----------------------------------
* - Example to demonstrate ABAP unit tests.
@@ -178,7 +178,7 @@ METHOD if_oo_adt_classrun~main.
DATA(output) = NEW zcl_demo_abap_display( out ).
output->display( `ABAP Cheat Sheet Demonstration Example: A Glimpse on ABAP Unit Tests` ).
output->display( `ABAP Cheat Sheet Demonstration Example: ABAP Unit Tests` ).
output->display( `1) get_sum Method` ).
"This method demonstrates the use of the setup and teardown methods in the test class.

View File

@@ -1,6 +1,6 @@
***********************************************************************
* ---------------------------- PURPOSE --------------------------------
* Interface to support the ABAP cheat sheet: A Glimpse on ABAP Unit Tests
* Interface to support the ABAP cheat sheet: ABAP Unit Tests
*
* ----------------------------- NOTE ----------------------------------
* The code presented in this class is only meant for supporting the ABAP
@@ -17,7 +17,7 @@
*
***********************************************************************
"! <p class="shorttext synchronized">Interface for ABAP cheat sheet example</p>
"! The interface supports the ABAP cheat sheet: A Glimpse on ABAP Unit Tests.
"! The interface supports the ABAP cheat sheet: ABAP Unit Tests.
INTERFACE zdemo_abap_get_data_itf
PUBLIC.