Update
This commit is contained in:
@@ -864,7 +864,7 @@ INSERT LINES OF itab2 FROM 5 TO 9 INTO TABLE itab.
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td> Inserting one line or multiple lines from another internal table at a specific position </td>
|
<td> Inserting one line represented by a structure or multiple lines from another internal table at a specific position </td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
`FROM` and `TO` can be used here, too.
|
`FROM` and `TO` can be used here, too.
|
||||||
@@ -3933,7 +3933,12 @@ The expressions are covered in the [Constructor Expressions](05_Constructor_Expr
|
|||||||
|
|
||||||
### Interrupting and Exiting Loops
|
### Interrupting and Exiting Loops
|
||||||
|
|
||||||
ABAP keywords such as `CONTINUE` (terminating the current loop pass, continuing with the next), `CHECK` (conditional termination termination of the current loop pass if the logical expression is false), and `EXIT` (loop terminated completely), are available to exit and interrupt loops. Find more information in the [Program Flow Logic](13_Program_Flow_Logic.md#interrupting-and-exiting-loops) cheat sheet.
|
ABAP keywords such as
|
||||||
|
- `CONTINUE` (terminating the current loop pass, continuing with the next)
|
||||||
|
- `CHECK` (conditional termination termination of the current loop pass if the logical expression is false), and
|
||||||
|
- `EXIT` (loop terminated completely),
|
||||||
|
|
||||||
|
are available to exit and interrupt loops. Find more information in the [Program Flow Logic](13_Program_Flow_Logic.md#interrupting-and-exiting-loops) cheat sheet.
|
||||||
|
|
||||||
In the following example, the loop is exited using the `EXIT` statement when a certain condition is met.
|
In the following example, the loop is exited using the `EXIT` statement when a certain condition is met.
|
||||||
```abap
|
```abap
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ that is, it refers to another structure. The following example has multiple subs
|
|||||||
END OF address_n.
|
END OF address_n.
|
||||||
```
|
```
|
||||||
|
|
||||||
- **Deep structures**: Contains at least one internal table, reference type, or string as a component.
|
- **Deep structures**: Contain at least one internal table, reference type, or string as a component.
|
||||||
``` abap
|
``` abap
|
||||||
DATA: BEGIN OF address_d,
|
DATA: BEGIN OF address_d,
|
||||||
name TYPE string VALUE `Mr. Duncan Pea`,
|
name TYPE string VALUE `Mr. Duncan Pea`,
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
| Keyword | Purpose |
|
| Keyword | Purpose |
|
||||||
| -------- | ------------------------------------------------------------------------- |
|
| -------- | ------------------------------------------------------------------------- |
|
||||||
| `SELECT` | Reads data from database tables |
|
| `SELECT` | Reads data from data sources such as database tables and others |
|
||||||
| `INSERT` | Adds rows to database tables |
|
| `INSERT` | Adds rows to database tables |
|
||||||
| `UPDATE` | Changes the content of rows of database tables |
|
| `UPDATE` | Changes the content of rows of database tables |
|
||||||
| `MODIFY` | Inserts rows into database tables or changes the content of existing rows |
|
| `MODIFY` | Inserts rows into database tables or changes the content of existing rows |
|
||||||
|
|||||||
@@ -1540,7 +1540,7 @@ DATA(ref2) = NEW some_class( ). "Reference variable declared inline, explic
|
|||||||
DATA(ref_mand_param) = NEW another_class( ip1 = ... ip2 = ... ).
|
DATA(ref_mand_param) = NEW another_class( ip1 = ... ip2 = ... ).
|
||||||
|
|
||||||
"Older syntax, replaced by NEW operator
|
"Older syntax, replaced by NEW operator
|
||||||
"However, the CREATE OBJECT is required in dynamic object creation.
|
"However, CREATE OBJECT is required in dynamic object creation.
|
||||||
CREATE OBJECT ref3. "Type derived from already declared ref3
|
CREATE OBJECT ref3. "Type derived from already declared ref3
|
||||||
CREATE OBJECT ref4 TYPE some_class. "Corresponds to the result of the expression above
|
CREATE OBJECT ref4 TYPE some_class. "Corresponds to the result of the expression above
|
||||||
```
|
```
|
||||||
@@ -7675,7 +7675,7 @@ ENDCLASS.
|
|||||||
<br>
|
<br>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>🟢 Abstract Factory</summary>
|
<summary>🟢 Abstract factory</summary>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
@@ -7683,8 +7683,8 @@ ENDCLASS.
|
|||||||
- The pattern may be used when you need to create a set of related objects (a family of "products") that work together or are processed together for specific purposes.
|
- The pattern may be used when you need to create a set of related objects (a family of "products") that work together or are processed together for specific purposes.
|
||||||
- Such families of related objects may be required in different variants. However, the created objects must be compatible with each variant.
|
- Such families of related objects may be required in different variants. However, the created objects must be compatible with each variant.
|
||||||
- Here are some examples to illustrate this:
|
- Here are some examples to illustrate this:
|
||||||
- Consider a car manufacturer. Multiple components are needed to assemble a car, such as the chassis, engine, and equipment (certainly, there are more components). These components form a family of related objects to create car. All cars from the manufacturer follow the same setup: each requires a chassis, engine, and equipment. However, the manufacturer offers various car models like convertibles, sedans, SUVs, and pickup trucks. When producing these different variants, specific components may vary. The assembly must only use compatible objects. For example, when producing a convertible, a chassis with a sedan roof should not be used.
|
- Consider a car manufacturer. Multiple components are needed to assemble a car, such as the chassis, engine, and equipment (certainly, there are more components). These components form a family of related objects to a create car. All cars from the manufacturer follow the same setup: each requires a chassis, engine, and equipment. However, the manufacturer offers various car models like convertibles, sedans, SUVs, and pickup trucks. When producing these different variants, specific components may vary. The assembly must only use compatible objects. For example, when producing a convertible, a chassis with a sedan roof should not be used.
|
||||||
- Consider a restaurant offers various three-course menus (this is the example used by the demo classes). Menu items include starters, main dishes, and desserts, forming a family of related objects. Different variants exist to create specific menus. For example, the restaurant offers a vegan menu. When creating the menu, it should be ensured the menu does not include a beef steak as a main dish or dairy products in desserts.
|
- Consider a restaurant offers various three-course menus (this is the example used by the demo classes). Menu items include starters, main dishes, and desserts, forming a family of related objects. Different variants exist to create specific menus. For example, the restaurant offers a vegan menu. When creating the vegan menu, it should be ensured the menu does not include a beef steak as a main dish or dairy products in desserts.
|
||||||
- In terms of code, you may need a setup to create related objects in an organized and consistent way. The abstract factory design pattern enables this by using a high level of abstraction in your class setup, i.e. it enables the creation of related objects that belong to the same family through abstractions like abstract classes, without bothering about their specific implementations and allowing for the creation of objects with appropriate types determined at runtime. A factory, such as an abstract factory class, sets up the object creation process by specifying methods that provide objects. Concrete factories then inherit from the abstract factory class and implement the methods to create specific kinds of objects. More abstraction is involved, as outlined in the example description below.
|
- In terms of code, you may need a setup to create related objects in an organized and consistent way. The abstract factory design pattern enables this by using a high level of abstraction in your class setup, i.e. it enables the creation of related objects that belong to the same family through abstractions like abstract classes, without bothering about their specific implementations and allowing for the creation of objects with appropriate types determined at runtime. A factory, such as an abstract factory class, sets up the object creation process by specifying methods that provide objects. Concrete factories then inherit from the abstract factory class and implement the methods to create specific kinds of objects. More abstraction is involved, as outlined in the example description below.
|
||||||
- Some of the benefits of the pattern include: centralizing multiple object creations in one location, ensuring consistency and compatibility, simplifying object creation for users by hiding complexity, adding or modifying different variants without affecting existing code, providing flexibility and adaptability (however, adding new products might be cumbersome as it requires changes in many parts of the code).
|
- Some of the benefits of the pattern include: centralizing multiple object creations in one location, ensuring consistency and compatibility, simplifying object creation for users by hiding complexity, adding or modifying different variants without affecting existing code, providing flexibility and adaptability (however, adding new products might be cumbersome as it requires changes in many parts of the code).
|
||||||
- The abstract factory pattern differs from the factory method design pattern in several ways. Both facilitate object creation through abstraction. The factory method uses a single interface as an abstraction layer and single factory methods, while the abstract factory pattern uses a higher degree of abstraction and multiple factories. The factory method pattern primarily creates single objects, whereas the abstract factory pattern involves creating multiple related objects.
|
- The abstract factory pattern differs from the factory method design pattern in several ways. Both facilitate object creation through abstraction. The factory method uses a single interface as an abstraction layer and single factory methods, while the abstract factory pattern uses a higher degree of abstraction and multiple factories. The factory method pattern primarily creates single objects, whereas the abstract factory pattern involves creating multiple related objects.
|
||||||
@@ -10756,7 +10756,7 @@ ENDCLASS.
|
|||||||
- When compiling ABAP programs, the specifications with the escape character are not considered as ABAP words.
|
- When compiling ABAP programs, the specifications with the escape character are not considered as ABAP words.
|
||||||
- When executing the programs, the escape characters are ignored.
|
- When executing the programs, the escape characters are ignored.
|
||||||
|
|
||||||
The following nonsensical example shows various specifications with the escape character that emphasize in the program that the operands are not to be confused with ABAP words. These specifications are not mandatory in the example. The example only addresses escape characters you may encounter in ABAP code.
|
The following nonsensical example shows various specifications with the escape character that emphasize in the program that the operands are not to be confused with ABAP words. These specifications are not mandatory in the example. The example only addresses escape characters you may encounter in (older) ABAP code.
|
||||||
|
|
||||||
```abap
|
```abap
|
||||||
CLASS zcl_demo_abap DEFINITION
|
CLASS zcl_demo_abap DEFINITION
|
||||||
|
|||||||
@@ -1768,7 +1768,7 @@ ENDCASE.
|
|||||||
- The conditions can either be based on single values or a [filter
|
- The conditions can either be based on 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).
|
table](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenconstructor_expr_filter_table.htm).
|
||||||
- The source table must have at least one [sorted key](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensorted_key_glosry.htm "Glossary Entry") or a [hash key](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenhash_key_glosry.htm "Glossary Entry") for accessing. If the table does not have such a primary table key, a [secondary table key](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensecondary_table_key_glosry.htm "Glossary Entry") must be available.
|
- The source table must have at least one [sorted key](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensorted_key_glosry.htm "Glossary Entry") or a [hash key](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenhash_key_glosry.htm "Glossary Entry") for accessing. If the table does not have such a primary table key, a [secondary table key](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensecondary_table_key_glosry.htm "Glossary Entry") must be available.
|
||||||
- Syntax options for the using the table key (i.e. specifying its components):
|
- Syntax options for using the table key (i.e. specifying its components):
|
||||||
- Using the [primary table key](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenprimary_table_key_glosry.htm) without the `USING KEY` addition
|
- Using the [primary table key](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenprimary_table_key_glosry.htm) without the `USING KEY` addition
|
||||||
- Using the default name `primary_key` for the primary key with `USING KEY`
|
- Using the default name `primary_key` for the primary key with `USING KEY`
|
||||||
- Using the secondary table key with `USING KEY`
|
- Using the secondary table key with `USING KEY`
|
||||||
|
|||||||
@@ -1456,6 +1456,8 @@ CREATE DATA dref TYPE ('T_STR_REF').
|
|||||||
"----- Pattern: TYPE ... TABLE OF (typename) ... -----
|
"----- Pattern: TYPE ... TABLE OF (typename) ... -----
|
||||||
|
|
||||||
"Creating internal tables
|
"Creating internal tables
|
||||||
|
"Note that the syntax with CREATE DATA does not support the specification of
|
||||||
|
"secondary table keys. This is possible with RTTI and using a type description object.
|
||||||
|
|
||||||
CREATE DATA dref TYPE TABLE OF ('STRING').
|
CREATE DATA dref TYPE TABLE OF ('STRING').
|
||||||
CREATE DATA dref TYPE TABLE OF ('T_FLI_STRUC') WITH EMPTY KEY.
|
CREATE DATA dref TYPE TABLE OF ('T_FLI_STRUC') WITH EMPTY KEY.
|
||||||
@@ -4623,8 +4625,15 @@ CREATE DATA dref_struc TYPE HANDLE tdo_struc_3.
|
|||||||
#### Creating Table Types and Internal Tables Dynamically
|
#### Creating Table Types and Internal Tables Dynamically
|
||||||
|
|
||||||
```abap
|
```abap
|
||||||
"Note regarding cl_abap_tabledescr=>get( ... ): Specifying the line type is mandatory,
|
*&---------------------------------------------------------------------*
|
||||||
"the rest is optional.
|
*& Creating internal tables dynamically using type description objects
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
|
||||||
|
DATA dref_itab TYPE REF TO data.
|
||||||
|
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
*& Internal table with elementary line type and standard table key
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
|
||||||
"An internal table type such as the following shall be created dynamically
|
"An internal table type such as the following shall be created dynamically
|
||||||
"using a type description object.
|
"using a type description object.
|
||||||
@@ -4632,54 +4641,81 @@ TYPES std_tab_type_std_key TYPE STANDARD TABLE OF string WITH DEFAULT KEY.
|
|||||||
DATA itab_1 TYPE std_tab_type_std_key.
|
DATA itab_1 TYPE std_tab_type_std_key.
|
||||||
|
|
||||||
"Creating the type dynamically (creating a type description object)
|
"Creating the type dynamically (creating a type description object)
|
||||||
"Not specifying the other optional parameters means that the
|
"Here, the cl_abap_tabledescr=>get( ... ) method is used. Note that specifying
|
||||||
"default values are used, for example, standard table is the
|
"the line type is mandatory, the rest is optional.
|
||||||
"default value for p_table_kind.
|
"Not specifying the other optional parameters means that the default values are
|
||||||
|
"used, for example, standard table is the default value for p_table_kind.
|
||||||
DATA(tdo_tab_1) = cl_abap_tabledescr=>get(
|
DATA(tdo_tab_1) = cl_abap_tabledescr=>get(
|
||||||
p_line_type = cl_abap_elemdescr=>get_string( ) ).
|
p_line_type = cl_abap_elemdescr=>get_string( ) ).
|
||||||
|
|
||||||
"Creating an internal table dynamically using a type description object
|
"Creating an internal table dynamically using a type description object
|
||||||
DATA dref_itab TYPE REF TO data.
|
|
||||||
CREATE DATA dref_itab TYPE HANDLE tdo_tab_1.
|
CREATE DATA dref_itab TYPE HANDLE tdo_tab_1.
|
||||||
|
|
||||||
ASSERT itab_1 = dref_itab->*.
|
"Getting type information and checking type compatibility
|
||||||
|
DATA(tdo_1a) = CAST cl_abap_tabledescr( cl_abap_typedescr=>describe_by_data( dref_itab->* ) ).
|
||||||
|
DATA(tdo_1b) = CAST cl_abap_tabledescr( cl_abap_typedescr=>describe_by_data( itab_1 ) ).
|
||||||
|
|
||||||
|
DATA(applies_1a) = tdo_1a->applies_to_data_descr( tdo_1b ).
|
||||||
|
DATA(applies_1b) = tdo_1a->applies_to_data( itab_1 ).
|
||||||
|
|
||||||
|
ASSERT applies_1a = abap_true.
|
||||||
|
ASSERT applies_1b = abap_true.
|
||||||
|
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
*& Internal table with structured line type and custom table keys
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
|
||||||
"Another internal table type for which more parameter specifications
|
"Another internal table type for which more parameter specifications
|
||||||
"are needed. The following internal table type shall be created using
|
"are needed. The following internal table type shall be created using
|
||||||
"a type description object.
|
"a type description object.
|
||||||
|
"The structured type of demo DDIC database table is used.
|
||||||
TYPES so_table_type TYPE SORTED TABLE OF zdemo_abap_flsch WITH UNIQUE KEY carrid connid.
|
TYPES so_table_type TYPE SORTED TABLE OF zdemo_abap_flsch WITH UNIQUE KEY carrid connid.
|
||||||
DATA itab_2 TYPE so_table_type.
|
DATA itab_2 TYPE so_table_type.
|
||||||
|
|
||||||
"Creating the type dynamically (creating a type description object)
|
"Creating the type dynamically by creating a type description object
|
||||||
"The following example also demonstrates how comfortably constructor
|
"The following example also demonstrates how comfortably constructor
|
||||||
"operators can be used at these positions.
|
"operators can be used at these positions.
|
||||||
DATA(tdo_tab_2) = cl_abap_tabledescr=>get(
|
DATA(tdo_tab_2) = cl_abap_tabledescr=>get(
|
||||||
p_line_type = CAST cl_abap_structdescr( cl_abap_tabledescr=>describe_by_name( 'ZDEMO_ABAP_FLSCH' ) )
|
p_line_type = CAST cl_abap_structdescr( cl_abap_tabledescr=>describe_by_name( 'ZDEMO_ABAP_FLSCH' ) )
|
||||||
p_table_kind = cl_abap_tabledescr=>tablekind_sorted
|
p_table_kind = cl_abap_tabledescr=>tablekind_sorted
|
||||||
p_key = VALUE #( ( name = 'CARRID' ) ( name = 'CONNID' ) )
|
p_key = VALUE #( ( name = 'CARRID' ) ( name = 'CONNID' ) )
|
||||||
p_unique = cl_abap_typedescr=>true ).
|
p_unique = cl_abap_typedescr=>true
|
||||||
|
p_key_kind = cl_abap_tabledescr=>keydefkind_user ).
|
||||||
|
|
||||||
"Creating an internal table dynamically using a type description object
|
"Creating an internal table dynamically using a type description object
|
||||||
CREATE DATA dref_itab TYPE HANDLE tdo_tab_2.
|
CREATE DATA dref_itab TYPE HANDLE tdo_tab_2.
|
||||||
|
|
||||||
ASSERT itab_2 = dref_itab->*.
|
"Getting type information and checking type compatibility
|
||||||
|
DATA(tdo_2a) = CAST cl_abap_tabledescr( cl_abap_typedescr=>describe_by_data( dref_itab->* ) ).
|
||||||
|
DATA(tdo_2b) = CAST cl_abap_tabledescr( cl_abap_typedescr=>describe_by_data( itab_2 ) ).
|
||||||
|
|
||||||
|
DATA(applies_2a) = tdo_2a->applies_to_data_descr( tdo_2b ).
|
||||||
|
DATA(applies_2b) = tdo_2a->applies_to_data( itab_2 ).
|
||||||
|
|
||||||
|
ASSERT applies_2a = abap_true.
|
||||||
|
ASSERT applies_2b = abap_true.
|
||||||
|
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
*& Internal table with structured line type containing custom components
|
||||||
|
*& and custom table key
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
|
||||||
"A table type and data object such as the following shall be created
|
"A table type and data object such as the following shall be created
|
||||||
"dynamically using a type description object.
|
"dynamically using a type description object.
|
||||||
TYPES: BEGIN OF struc_type_2,
|
TYPES: BEGIN OF struc_type,
|
||||||
a TYPE string, "Built-in ABAP types
|
a TYPE c LENGTH 5, "Built-in ABAP types
|
||||||
b TYPE i,
|
b TYPE i,
|
||||||
c TYPE c LENGTH 5,
|
c TYPE string,
|
||||||
d TYPE land1, "DDIC data element
|
d TYPE land1, "DDIC data element
|
||||||
END OF struc_type_2.
|
END OF struc_type.
|
||||||
DATA itab_3 TYPE HASHED TABLE OF struc_type_2 WITH UNIQUE KEY a.
|
DATA itab_3 TYPE HASHED TABLE OF struc_type WITH UNIQUE KEY a.
|
||||||
|
|
||||||
"Creating the type dynamically (creating a type description object)
|
"Creating the type dynamically by creating a type description object
|
||||||
DATA(tdo_tab_3) = cl_abap_tabledescr=>get(
|
DATA(tdo_tab_3) = cl_abap_tabledescr=>get(
|
||||||
p_line_type = cl_abap_structdescr=>get( VALUE #(
|
p_line_type = cl_abap_structdescr=>get( VALUE #(
|
||||||
( name = 'A' type = cl_abap_elemdescr=>get_string( ) )
|
( name = 'A' type = cl_abap_elemdescr=>get_c( 5 ) )
|
||||||
( name = 'B' type = cl_abap_elemdescr=>get_i( ) )
|
( name = 'B' type = cl_abap_elemdescr=>get_i( ) )
|
||||||
( name = 'C' type = cl_abap_elemdescr=>get_c( 5 ) )
|
( name = 'C' type = cl_abap_elemdescr=>get_string( ) )
|
||||||
( name = 'D' type = CAST cl_abap_datadescr( cl_abap_typedescr=>describe_by_name( 'LAND1' ) ) ) ) )
|
( name = 'D' type = CAST cl_abap_datadescr( cl_abap_typedescr=>describe_by_name( 'LAND1' ) ) ) ) )
|
||||||
p_table_kind = cl_abap_tabledescr=>tablekind_hashed
|
p_table_kind = cl_abap_tabledescr=>tablekind_hashed
|
||||||
p_key = VALUE #( ( name = 'A' ) )
|
p_key = VALUE #( ( name = 'A' ) )
|
||||||
@@ -4688,19 +4724,158 @@ DATA(tdo_tab_3) = cl_abap_tabledescr=>get(
|
|||||||
"Creating an internal table dynamically using a type description object
|
"Creating an internal table dynamically using a type description object
|
||||||
CREATE DATA dref_itab TYPE HANDLE tdo_tab_3.
|
CREATE DATA dref_itab TYPE HANDLE tdo_tab_3.
|
||||||
|
|
||||||
ASSERT itab_3 = dref_itab->*.
|
"Getting type information and checking type compatibility
|
||||||
|
DATA(tdo_3a) = CAST cl_abap_tabledescr( cl_abap_typedescr=>describe_by_data( dref_itab->* ) ).
|
||||||
|
DATA(line_type_3a) = CAST cl_abap_structdescr( tdo_3a->get_table_line_type( ) ).
|
||||||
|
DATA(keys_3a) = tdo_3a->get_keys( ).
|
||||||
|
|
||||||
"Excursion
|
DATA(tdo_3b) = CAST cl_abap_tabledescr( cl_abap_typedescr=>describe_by_data( itab_3 ) ).
|
||||||
"The previous examples show the use of cl_abap_tabledescr=>get to create
|
DATA(line_type_3b) = CAST cl_abap_structdescr( tdo_3b->get_table_line_type( ) ).
|
||||||
"type description objects. These examples show the creation based on
|
DATA(keys_3b) = tdo_3b->get_keys( ).
|
||||||
"other methods/different casts getting type description objects.
|
|
||||||
TYPES ty_str_tab TYPE TABLE OF string WITH EMPTY KEY.
|
|
||||||
DATA itab_4 TYPE string_table.
|
|
||||||
|
|
||||||
DATA(tdo_tab_4) = CAST cl_abap_datadescr( cl_abap_typedescr=>describe_by_name( 'TY_STR_TAB' ) ).
|
|
||||||
|
DATA(applies_3a) = tdo_3a->applies_to_data_descr( tdo_3b ).
|
||||||
|
DATA(applies_3b) = tdo_3a->applies_to_data( itab_3 ).
|
||||||
|
|
||||||
|
ASSERT applies_3a = abap_true.
|
||||||
|
ASSERT applies_3b = abap_true.
|
||||||
|
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
*& Internal table with structured line type containing custom components
|
||||||
|
*& and custom table key (primary and secondary table key)
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
|
||||||
|
"A table type and data object such as the following shall be created
|
||||||
|
"dynamically using a type description object.
|
||||||
|
TYPES: BEGIN OF struc_type_2,
|
||||||
|
e TYPE c LENGTH 5, "Built-in ABAP types
|
||||||
|
f TYPE i,
|
||||||
|
g TYPE land1, "DDIC data element
|
||||||
|
h TYPE zdemo_abap_flsch, "DDIC database table
|
||||||
|
i TYPE REF TO string, "Reference type
|
||||||
|
END OF struc_type_2.
|
||||||
|
DATA itab_4 TYPE SORTED TABLE OF struc_type_2
|
||||||
|
WITH NON-UNIQUE KEY e
|
||||||
|
WITH NON-UNIQUE SORTED KEY secondary_key COMPONENTS f.
|
||||||
|
"Note that the default name primary_key does not need to be specified explicitly.
|
||||||
|
"So, the following declaration corresponds to the previous one.
|
||||||
|
DATA itab_4b TYPE SORTED TABLE OF struc_type_2
|
||||||
|
WITH NON-UNIQUE KEY primary_key COMPONENTS e
|
||||||
|
WITH NON-UNIQUE SORTED KEY sec_key COMPONENTS f.
|
||||||
|
|
||||||
|
"Creating the type dynamically by creating a type description object
|
||||||
|
"Here, the cl_abap_tabledescr=>get_with_keys( ... ) method is used. Check the class documentation
|
||||||
|
"for more details.
|
||||||
|
DATA(tdo_tab_4) = cl_abap_tabledescr=>get_with_keys(
|
||||||
|
p_line_type = cl_abap_structdescr=>get( VALUE #(
|
||||||
|
( name = 'E' type = cl_abap_elemdescr=>get_c( 5 ) )
|
||||||
|
( name = 'F' type = cl_abap_elemdescr=>get_i( ) )
|
||||||
|
( name = 'G' type = CAST cl_abap_datadescr( cl_abap_typedescr=>describe_by_name( 'LAND1' ) ) )
|
||||||
|
( name = 'H' type = CAST cl_abap_datadescr( cl_abap_typedescr=>describe_by_name( 'ZDEMO_ABAP_FLSCH' ) ) )
|
||||||
|
( name = 'I' type = CAST cl_abap_datadescr( CAST cl_abap_refdescr( cl_abap_typedescr=>describe_by_data( REF #( `hello` ) ) ) ) )
|
||||||
|
) )
|
||||||
|
p_keys = VALUE #(
|
||||||
|
( name = VALUE #( ) "In case of the primary table key, a name must be provided here
|
||||||
|
"for an alias. This example table does not specify an alias name.
|
||||||
|
is_primary = abap_true
|
||||||
|
access_kind = cl_abap_tabledescr=>tablekind_sorted
|
||||||
|
is_unique = abap_false
|
||||||
|
key_kind = cl_abap_tabledescr=>keydefkind_user
|
||||||
|
components = VALUE #( ( name = 'E' ) ) )
|
||||||
|
( name = 'SECONDARY_KEY'
|
||||||
|
is_primary = abap_false
|
||||||
|
access_kind = cl_abap_tabledescr=>tablekind_sorted
|
||||||
|
is_unique = abap_false
|
||||||
|
key_kind = cl_abap_tabledescr=>keydefkind_user
|
||||||
|
components = VALUE #( ( name = 'F' ) ) ) ) ).
|
||||||
|
|
||||||
|
"Creating an internal table dynamically using a type description object
|
||||||
CREATE DATA dref_itab TYPE HANDLE tdo_tab_4.
|
CREATE DATA dref_itab TYPE HANDLE tdo_tab_4.
|
||||||
DATA(tdo_tab_5) = CAST cl_abap_tabledescr( cl_abap_typedescr=>describe_by_data( itab_4 ) ).
|
|
||||||
|
"Getting type information and checking type compatibility
|
||||||
|
DATA(tdo_4a) = CAST cl_abap_tabledescr( cl_abap_typedescr=>describe_by_data( dref_itab->* ) ).
|
||||||
|
DATA(line_type_4a) = CAST cl_abap_structdescr( tdo_4a->get_table_line_type( ) ).
|
||||||
|
DATA(keys_4a) = tdo_4a->get_keys( ).
|
||||||
|
|
||||||
|
DATA(tdo_4b) = CAST cl_abap_tabledescr( cl_abap_typedescr=>describe_by_data( itab_4 ) ).
|
||||||
|
DATA(line_type_4b) = CAST cl_abap_structdescr( tdo_4b->get_table_line_type( ) ).
|
||||||
|
DATA(keys_4b) = tdo_4b->get_keys( ).
|
||||||
|
|
||||||
|
DATA(applies_4a) = tdo_4a->applies_to_data_descr( tdo_4b ).
|
||||||
|
DATA(applies_4b) = tdo_4a->applies_to_data( itab_4 ).
|
||||||
|
|
||||||
|
ASSERT applies_4a = abap_true.
|
||||||
|
ASSERT applies_4b = abap_true.
|
||||||
|
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
*& Internal table with structured line type containing custom components
|
||||||
|
*& and custom table key (primary and secondary table key), including
|
||||||
|
*& alias names
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
|
||||||
|
"A internal table such as the following shall be
|
||||||
|
"created dynamically using a type description object.
|
||||||
|
DATA itab_5 TYPE HASHED TABLE OF struc_type
|
||||||
|
WITH UNIQUE KEY primary_key ALIAS pk COMPONENTS a
|
||||||
|
WITH NON-UNIQUE SORTED KEY sec_key ALIAS sk COMPONENTS b c.
|
||||||
|
|
||||||
|
"Creating the type dynamically by creating a type description object
|
||||||
|
DATA(tdo_tab_5) = cl_abap_tabledescr=>get_with_keys(
|
||||||
|
p_line_type = CAST cl_abap_structdescr( cl_abap_typedescr=>describe_by_name( 'STRUC_TYPE' ) )
|
||||||
|
p_keys = VALUE #(
|
||||||
|
( name = 'PK' "Alias name for the primary table key.
|
||||||
|
is_primary = abap_true
|
||||||
|
access_kind = cl_abap_tabledescr=>tablekind_hashed
|
||||||
|
is_unique = abap_true
|
||||||
|
key_kind = cl_abap_tabledescr=>keydefkind_user
|
||||||
|
components = VALUE #( ( name = 'A' ) ) )
|
||||||
|
( name = 'SEC_KEY'
|
||||||
|
is_primary = abap_false
|
||||||
|
access_kind = cl_abap_tabledescr=>tablekind_sorted
|
||||||
|
is_unique = abap_false
|
||||||
|
key_kind = cl_abap_tabledescr=>keydefkind_user
|
||||||
|
components = VALUE #( ( name = 'B' ) ( name = 'C' ) ) ) )
|
||||||
|
p_key_aliases = VALUE #( ( name = 'PRIMARY_KEY' alias = 'PK' ) "Specifying the default primary table key name PRIMARY_KEY
|
||||||
|
( name = 'SEC_KEY' alias = 'SK' ) ) ).
|
||||||
|
|
||||||
|
"Creating an internal table dynamically using a type description object
|
||||||
CREATE DATA dref_itab TYPE HANDLE tdo_tab_5.
|
CREATE DATA dref_itab TYPE HANDLE tdo_tab_5.
|
||||||
|
|
||||||
|
DATA(tdo_5a) = CAST cl_abap_tabledescr( cl_abap_typedescr=>describe_by_data( dref_itab->* ) ).
|
||||||
|
DATA(line_type_5a) = CAST cl_abap_structdescr( tdo_5a->get_table_line_type( ) ).
|
||||||
|
DATA(keys_5a) = tdo_5a->get_keys( ).
|
||||||
|
DATA(key_aliases_5a) = tdo_5a->get_key_aliases( ).
|
||||||
|
|
||||||
|
DATA(tdo_5b) = CAST cl_abap_tabledescr( cl_abap_typedescr=>describe_by_data( itab_5 ) ).
|
||||||
|
DATA(line_type_5b) = CAST cl_abap_structdescr( tdo_5b->get_table_line_type( ) ).
|
||||||
|
DATA(keys_5b) = tdo_5b->get_keys( ).
|
||||||
|
DATA(key_aliases_5b) = tdo_5b->get_key_aliases( ).
|
||||||
|
|
||||||
|
DATA(applies_5a) = tdo_5a->applies_to_data_descr( tdo_5b ).
|
||||||
|
DATA(applies_5b) = tdo_5a->applies_to_data( itab_5 ).
|
||||||
|
|
||||||
|
ASSERT applies_5a = abap_true.
|
||||||
|
ASSERT applies_5b = abap_true.
|
||||||
|
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
*& Creating internal tables dynamically using type description objects
|
||||||
|
*& based on existing table types and internal tables
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
|
||||||
|
"The previous examples show the use of cl_abap_tabledescr=>get* methods
|
||||||
|
"to create type description objects. The following examples show the
|
||||||
|
"creation based on other methods/different casts getting type description
|
||||||
|
"objects.
|
||||||
|
TYPES ty_str_tab TYPE TABLE OF string WITH EMPTY KEY.
|
||||||
|
DATA itab_6 TYPE string_table.
|
||||||
|
|
||||||
|
"Creating a type description object based on an existing table type
|
||||||
|
DATA(tdo_tab_6) = CAST cl_abap_datadescr( cl_abap_typedescr=>describe_by_name( 'TY_STR_TAB' ) ).
|
||||||
|
CREATE DATA dref_itab TYPE HANDLE tdo_tab_6.
|
||||||
|
|
||||||
|
"Creating a type description object based on an existing internal table
|
||||||
|
DATA(tdo_tab_7) = CAST cl_abap_tabledescr( cl_abap_typedescr=>describe_by_data( itab_4 ) ).
|
||||||
|
CREATE DATA dref_itab TYPE HANDLE tdo_tab_7.
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
- [Formatting Options in String Templates](#formatting-options-in-string-templates)
|
- [Formatting Options in String Templates](#formatting-options-in-string-templates)
|
||||||
- [Determining the Length of Strings](#determining-the-length-of-strings)
|
- [Determining the Length of Strings](#determining-the-length-of-strings)
|
||||||
- [Concatenating Strings](#concatenating-strings)
|
- [Concatenating Strings](#concatenating-strings)
|
||||||
|
- [Concatenation Assignment Operator \&\&=](#concatenation-assignment-operator-)
|
||||||
- [Literal Operator](#literal-operator)
|
- [Literal Operator](#literal-operator)
|
||||||
- [Splitting Strings](#splitting-strings)
|
- [Splitting Strings](#splitting-strings)
|
||||||
- [Modifying Strings](#modifying-strings)
|
- [Modifying Strings](#modifying-strings)
|
||||||
@@ -564,6 +565,99 @@ 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>
|
||||||
|
|
||||||
|
### Concatenation Assignment Operator &&=
|
||||||
|
|
||||||
|
- You can use the concatenation assignment operator `&&=` to concatenate strings in an assignment.
|
||||||
|
|
||||||
|
```abap
|
||||||
|
"This assignment using the concatenation assignment operator ...
|
||||||
|
a &&= b.
|
||||||
|
|
||||||
|
"... has the same effect as the following.
|
||||||
|
a = a && b.
|
||||||
|
```
|
||||||
|
|
||||||
|
- `a` can be variables and writable expressions (such as certain constructor expressions, e.g. `CAST`, or table expressions). It cannot be an inline declaration.
|
||||||
|
- `b` can be character-like data objects, constructor expressions, string expressions (such as string templates), table expressions or functions
|
||||||
|
|
||||||
|
```abap
|
||||||
|
DATA a1 TYPE string VALUE `a`.
|
||||||
|
DATA a2 TYPE string VALUE `a`.
|
||||||
|
DATA b TYPE string VALUE `b`.
|
||||||
|
|
||||||
|
a1 &&= b.
|
||||||
|
a2 = a2 && b.
|
||||||
|
|
||||||
|
ASSERT a1 = a2.
|
||||||
|
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
*& Left-hand data object
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
"The left-hand data object can also be represented by a writable expression
|
||||||
|
|
||||||
|
"Constructor expression with CAST
|
||||||
|
DATA ref TYPE REF TO data.
|
||||||
|
ref = NEW string( `h` ).
|
||||||
|
CAST string( ref )->* &&= `ello`. "hello
|
||||||
|
|
||||||
|
"Table expression
|
||||||
|
DATA(str_table) = VALUE string_table( ( `AB` ) ).
|
||||||
|
str_table[ 1 ] &&= `AP`. "ABAP
|
||||||
|
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
*& Right-hand data object
|
||||||
|
*&---------------------------------------------------------------------*
|
||||||
|
|
||||||
|
"The right-hand data object can be represented by a character-like data object, as
|
||||||
|
"shown in the previous examples, or whose content can be converted, as well as ...
|
||||||
|
|
||||||
|
"... constructor expressions
|
||||||
|
DATA txt TYPE string.
|
||||||
|
txt = `abc`.
|
||||||
|
"abcdef
|
||||||
|
txt &&= CONV string( 'def' ).
|
||||||
|
|
||||||
|
txt = `ghi`.
|
||||||
|
"The REDUCE operator itself uses the concatenation assignment operator
|
||||||
|
"in the assignment of NEXT.
|
||||||
|
"ghijkl
|
||||||
|
txt &&= REDUCE string( INIT str = VALUE #( )
|
||||||
|
FOR line IN VALUE string_table( ( `j` ) ( `k` ) ( `l` ) )
|
||||||
|
NEXT str &&= line ).
|
||||||
|
|
||||||
|
txt = `mno`.
|
||||||
|
"mnopqr
|
||||||
|
txt &&= COND #( WHEN txt = `mno` THEN `pqr` ELSE `stu` ).
|
||||||
|
|
||||||
|
"... string expressions such as string templates
|
||||||
|
CLEAR txt.
|
||||||
|
DO 5 TIMES.
|
||||||
|
"1, 2, 3, 4, 5
|
||||||
|
txt &&= |{ COND #( WHEN sy-index <> 1 THEN `, ` ) }{ sy-index }|.
|
||||||
|
ENDDO.
|
||||||
|
|
||||||
|
"... table expressions
|
||||||
|
DATA(tab) = VALUE string_table( ( `v` ) ( `w` ) ( `x` ) ).
|
||||||
|
txt = `a`.
|
||||||
|
"av
|
||||||
|
txt &&= tab[ 1 ].
|
||||||
|
|
||||||
|
"Content of tab[ 2 ]: wx
|
||||||
|
tab[ 2 ] &&= tab[ 3 ].
|
||||||
|
|
||||||
|
"... functions
|
||||||
|
txt = `a`.
|
||||||
|
"abbbbb
|
||||||
|
txt &&= repeat( val = `b` occ = 5 ).
|
||||||
|
|
||||||
|
DATA(strtab) = VALUE string_table( ( `b` ) ( `c` ) ( `d` ) ).
|
||||||
|
txt = `a`.
|
||||||
|
"abcd
|
||||||
|
txt &&= concat_lines_of( table = strtab ).
|
||||||
|
```
|
||||||
|
|
||||||
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Literal Operator
|
### Literal Operator
|
||||||
|
|
||||||
The [literal operator](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenliteral_operator_glosry.htm "Glossary Entry") `&` combines [text string literals](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abentext_string_literal_glosry.htm "Glossary Entry"), however, with [significant differences](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenliteral_operator.htm) to `&&`, which the code snippet addresses.
|
The [literal operator](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenliteral_operator_glosry.htm "Glossary Entry") `&` combines [text string literals](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abentext_string_literal_glosry.htm "Glossary Entry"), however, with [significant differences](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenliteral_operator.htm) to `&&`, which the code snippet addresses.
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
- [Read-by-Association Operation](#read-by-association-operation)
|
- [Read-by-Association Operation](#read-by-association-operation)
|
||||||
- [Dynamic ABAP EML READ Statements](#dynamic-abap-eml-read-statements)
|
- [Dynamic ABAP EML READ Statements](#dynamic-abap-eml-read-statements)
|
||||||
- [COMMIT ENTITIES: Persisting to the Database](#commit-entities-persisting-to-the-database)
|
- [COMMIT ENTITIES: Persisting to the Database](#commit-entities-persisting-to-the-database)
|
||||||
|
- [ROLLBACK ENTITIES](#rollback-entities)
|
||||||
- [GET PERMISSIONS: Retrieving Information about RAP BO Permissions](#get-permissions-retrieving-information-about-rap-bo-permissions)
|
- [GET PERMISSIONS: Retrieving Information about RAP BO Permissions](#get-permissions-retrieving-information-about-rap-bo-permissions)
|
||||||
- [Raising RAP Business Events](#raising-rap-business-events)
|
- [Raising RAP Business Events](#raising-rap-business-events)
|
||||||
- [IN LOCAL MODE Addition to ABAP EML Statements in ABAP Behavior Pools](#in-local-mode-addition-to-abap-eml-statements-in-abap-behavior-pools)
|
- [IN LOCAL MODE Addition to ABAP EML Statements in ABAP Behavior Pools](#in-local-mode-addition-to-abap-eml-statements-in-abap-behavior-pools)
|
||||||
@@ -2107,6 +2108,50 @@ ENDDO.
|
|||||||
|
|
||||||
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
|
### ROLLBACK ENTITIES
|
||||||
|
|
||||||
|
- The `ROLLBACK ENTITIES` statement rolls back all changes of the current [RAP transaction](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_luw_glosry.htm).
|
||||||
|
- This rollback includes the clearing of the transactional buffer (by calling the `cleanup` method) and locks.
|
||||||
|
- Note that in unmanaged scenarios, you must implement the behavior yourself. For example, the `cleanup` method must include an appropriate implementation to clear the transactional buffer.
|
||||||
|
- Same as for `COMMIT ENTITIES`, in natively supported RAP scenarios, such as an SAP Fiori application using OData, the `ROLLBACK ENTITIES` call is implicitly and automatically performed by the RAP runtime engine.
|
||||||
|
|
||||||
|
The following example demonstrates the effect of `ROLLBACK ENTITIES`. In the second loop pass, `ROLLBACK ENTITIES` clears the transactional buffer, leaving nothing to commit. Therefore, the assertions are also true for the second loop.
|
||||||
|
|
||||||
|
|
||||||
|
```abap
|
||||||
|
DELETE FROM zdemo_abap_rapt1.
|
||||||
|
|
||||||
|
DO 2 TIMES.
|
||||||
|
MODIFY ENTITIES OF zdemo_abap_rap_ro_m
|
||||||
|
ENTITY root
|
||||||
|
CREATE FIELDS ( key_field )
|
||||||
|
AUTO FILL CID WITH VALUE #( ( key_field = sy-index ) )
|
||||||
|
MAPPED DATA(m1)
|
||||||
|
FAILED DATA(f1)
|
||||||
|
REPORTED DATA(r1).
|
||||||
|
|
||||||
|
IF sy-index = 2.
|
||||||
|
ROLLBACK ENTITIES.
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
COMMIT ENTITIES.
|
||||||
|
|
||||||
|
IF sy-subrc <> 0.
|
||||||
|
...
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
SELECT FROM zdemo_abap_rapt1
|
||||||
|
FIELDS key_field
|
||||||
|
ORDER BY key_field
|
||||||
|
INTO TABLE @DATA(tab).
|
||||||
|
|
||||||
|
ASSERT lines( tab ) = 1.
|
||||||
|
ASSERT tab[ 1 ]-key_field = 1.
|
||||||
|
ENDDO.
|
||||||
|
```
|
||||||
|
|
||||||
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### GET PERMISSIONS: Retrieving Information about RAP BO Permissions
|
### GET PERMISSIONS: Retrieving Information about RAP BO Permissions
|
||||||
|
|
||||||
- RAP BO permissions cover aspects such as global and instance authorization, or global, instance, and static feature control.
|
- RAP BO permissions cover aspects such as global and instance authorization, or global, instance, and static feature control.
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
- [Using AMDP in ABAP for Cloud Development](#using-amdp-in-abap-for-cloud-development)
|
- [Using AMDP in ABAP for Cloud Development](#using-amdp-in-abap-for-cloud-development)
|
||||||
- [Notes on Client Handling and Client Safety](#notes-on-client-handling-and-client-safety)
|
- [Notes on Client Handling and Client Safety](#notes-on-client-handling-and-client-safety)
|
||||||
- [Restrictions for AMDP Methods in ABAP for Cloud Development](#restrictions-for-amdp-methods-in-abap-for-cloud-development)
|
- [Restrictions for AMDP Methods in ABAP for Cloud Development](#restrictions-for-amdp-methods-in-abap-for-cloud-development)
|
||||||
- [Making AMDP Methods Client-Safe in ABAP for Cloud Development](#making-amdp-methods-client-safe-in-abap-for-cloud-development)
|
- [Making AMDP Methods Client-Safe](#making-amdp-methods-client-safe)
|
||||||
- [More Information](#more-information)
|
- [More Information](#more-information)
|
||||||
- [Executable Example](#executable-example)
|
- [Executable Example](#executable-example)
|
||||||
|
|
||||||
@@ -409,6 +409,8 @@ You can then use the CDS table function as source for a
|
|||||||
- Therefore, all objects in the `USING` list of AMDP methods must be client-safe, including CDS table functions implemented as AMDP methods.
|
- Therefore, all objects in the `USING` list of AMDP methods must be client-safe, including CDS table functions implemented as AMDP methods.
|
||||||
- Additions and annotations are available, ensuring client safety by restricting access to data of the current client only.
|
- Additions and annotations are available, ensuring client safety by restricting access to data of the current client only.
|
||||||
|
|
||||||
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
### Restrictions for AMDP Methods in ABAP for Cloud Development
|
### Restrictions for AMDP Methods in ABAP for Cloud Development
|
||||||
|
|
||||||
- The AMDP procedure implementation must be restricted to reads. The relevant additions are `AMDP OPTIONS READ-ONLY` in AMDP method declarations and `OPTIONS READ-ONLY` in AMDP method implementations.
|
- The AMDP procedure implementation must be restricted to reads. The relevant additions are `AMDP OPTIONS READ-ONLY` in AMDP method declarations and `OPTIONS READ-ONLY` in AMDP method implementations.
|
||||||
@@ -416,7 +418,9 @@ You can then use the CDS table function as source for a
|
|||||||
- The data sources accessed must be released for ABAP for Cloud Development.
|
- The data sources accessed must be released for ABAP for Cloud Development.
|
||||||
- AMDP methods must be client-safe.
|
- AMDP methods must be client-safe.
|
||||||
|
|
||||||
### Making AMDP Methods Client-Safe in ABAP for Cloud Development
|
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||||
|
|
||||||
|
### Making AMDP Methods Client-Safe
|
||||||
|
|
||||||
To ensure client safety, the following prerequisites must be met.
|
To ensure client safety, the following prerequisites must be met.
|
||||||
|
|
||||||
@@ -457,7 +461,6 @@ To ensure client safety, the following prerequisites must be met.
|
|||||||
> - The table in [this topic](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/ABENAMDP_CALL_MATRICES.html) shows an overview of specification options regarding client safety.
|
> - The table in [this topic](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/ABENAMDP_CALL_MATRICES.html) shows an overview of specification options regarding client safety.
|
||||||
> - [Client Handling in CDS Table Functions](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/ABENCDS_FUNC_CLIENT_HANDLING.html)
|
> - [Client Handling in CDS Table Functions](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/ABENCDS_FUNC_CLIENT_HANDLING.html)
|
||||||
|
|
||||||
|
|
||||||
<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
|
||||||
|
|||||||
@@ -3040,7 +3040,7 @@ DATA str TYPE string.
|
|||||||
DATA ref9 LIKE REF TO str.
|
DATA ref9 LIKE REF TO str.
|
||||||
DATA ref10 LIKE REF TO struc_like_line.
|
DATA ref10 LIKE REF TO struc_like_line.
|
||||||
|
|
||||||
"--- Reference table based on existing data object using LIKE TABLE REF TO ---
|
"--- Reference table based on existing data object using LIKE TABLE OF REF TO ---
|
||||||
DATA ref11 LIKE TABLE OF REF TO str.
|
DATA ref11 LIKE TABLE OF REF TO str.
|
||||||
DATA ref12 LIKE TABLE OF REF TO struc_like_line.
|
DATA ref12 LIKE TABLE OF REF TO struc_like_line.
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ DATA(utc_date) = cl_abap_context_info=>get_system_date( ).
|
|||||||
"The following three examples:
|
"The following three examples:
|
||||||
"- do not specify the optional importing parameter for the 'date' method. In
|
"- do not specify the optional importing parameter for the 'date' method. In
|
||||||
" this case, the user time zone is used implicitly.
|
" this case, the user time zone is used implicitly.
|
||||||
"- specify an specific format in the 'as' method.
|
"- specify a specific format in the 'as' method.
|
||||||
|
|
||||||
"e.g. 20250101
|
"e.g. 20250101
|
||||||
DATA(date_abap) = xco_cp=>sy->date( )->as( xco_cp_time=>format->abap )->value.
|
DATA(date_abap) = xco_cp=>sy->date( )->as( xco_cp_time=>format->abap )->value.
|
||||||
@@ -515,7 +515,7 @@ DATA(utc_time) = cl_abap_context_info=>get_system_time( ).
|
|||||||
"The following three examples
|
"The following three examples
|
||||||
"- do not specify the optional importing parameter for the 'time' method. In
|
"- do not specify the optional importing parameter for the 'time' method. In
|
||||||
" this case, the user time zone is used implicitly.
|
" this case, the user time zone is used implicitly.
|
||||||
"- specify an specific format in the 'as' method.
|
"- specify a specific format in the 'as' method.
|
||||||
|
|
||||||
"e.g. 160907
|
"e.g. 160907
|
||||||
DATA(time_abap) = xco_cp=>sy->time( )->as( xco_cp_time=>format->abap )->value.
|
DATA(time_abap) = xco_cp=>sy->time( )->as( xco_cp_time=>format->abap )->value.
|
||||||
@@ -797,7 +797,7 @@ DATA(ts1) = utclong_current( ).
|
|||||||
"The following three examples
|
"The following three examples
|
||||||
"- do not specify the optional importing parameter for the 'moment' method. In
|
"- do not specify the optional importing parameter for the 'moment' method. In
|
||||||
" this case, the user time zone is used implicitly.
|
" this case, the user time zone is used implicitly.
|
||||||
"- specify an specific format in the 'as' method.
|
"- specify a specific format in the 'as' method.
|
||||||
|
|
||||||
"e.g. 20250101162319
|
"e.g. 20250101162319
|
||||||
DATA(ts_abap) = xco_cp=>sy->moment( )->as( xco_cp_time=>format->abap )->value.
|
DATA(ts_abap) = xco_cp=>sy->moment( )->as( xco_cp_time=>format->abap )->value.
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ This cheat sheet explores various aspects of numeric operations and calculations
|
|||||||
|
|
||||||
- Used to store binary floating point numbers, which are binary representations of numbers with mantissas and exponents.
|
- Used to store binary floating point numbers, which are binary representations of numbers with mantissas and exponents.
|
||||||
- Can represent decimal numbers with up to 17 decimal places in the mantissa (one before the decimal point, 16 after), and allow a three-digit exponent.
|
- Can represent decimal numbers with up to 17 decimal places in the mantissa (one before the decimal point, 16 after), and allow a three-digit exponent.
|
||||||
- Expect a scientific notation for the numeric value assigned, or interpret it as such.
|
- Expect a scientific notation for the numeric value assigned, or interpretable it as such.
|
||||||
- Represented internally as binary fractions, so not every decimal number can be represented exactly.
|
- Represented internally as binary fractions, so not every decimal number can be represented exactly.
|
||||||
- The type may be used in exceptional cases when precision is less important and fast calculations are crucial. Comparisons and calculations with this type and other numeric types might yield unexpected results due to imprecision and possible rounding effects. Consider decimal floating point types for greater precision.
|
- The type may be used in exceptional cases when precision is less important and fast calculations are crucial. Comparisons and calculations with this type and other numeric types might yield unexpected results due to imprecision and possible rounding effects. Consider decimal floating point types for greater precision.
|
||||||
|
|
||||||
|
|||||||
@@ -584,7 +584,7 @@ SELECT tab2~key_field, tab1~char2
|
|||||||
|
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
Dynamic `WHERE` condition specified as parenthesized data objects. This data objects should contain the syntax of a logical expression. As `dynamic_where_clause`, a character-like data object or a standard table with character-like line type is expected. The syntax is not case-sensitive. For more information, see the [Dynamic Programming cheat sheet](06_Dynamic_Programming.md), also with respect to potential security risks regarding dynamic specifications.
|
Dynamic `WHERE` condition specified as parenthesized data objects. These data objects should contain the syntax of a logical expression. As `dynamic_where_clause`, a character-like data object or a standard table with character-like line type is expected. The syntax is not case-sensitive. For more information, see the [Dynamic Programming cheat sheet](06_Dynamic_Programming.md), also with respect to potential security risks regarding dynamic specifications.
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
|||||||
18
README.md
18
README.md
@@ -85,7 +85,7 @@ ABAP cheat sheets[^1] ...
|
|||||||
|[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)|
|
|[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)|
|
|[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)|The cheat sheet provides references to information on ABAP CDS. Find a feature table for available language elements in ABAP CDS in the [ABAP Keyword Documentation](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/abencds_language_elements.html) with links to detailed topics. 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 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 <br> 💡 Several statements covered in the cheat sheet and the executable example are only 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`|
|
|[SAP LUW](17_SAP_LUW.md)|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 <br> 💡 Several statements covered in the cheat sheet and the executable example are only relevant to [classic ABAP](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenclassic_abap_glosry.htm).|Program `ZDEMO_ABAP_SAP_LUW`|
|
||||||
|[Dynpro](18_Dynpro.md)|Provides a high-level overview of dynpro topics with a focus on dynpro-related statements <br> 💡 The content of this cheat sheet and the executable example are only 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`|
|
|[Dynpro](18_Dynpro.md)|Provides a high-level overview of dynpro topics with a focus on dynpro-related statements <br> 💡 The content of this cheat sheet and the executable example are only 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`|
|
||||||
|[Selection Screens and Classic Lists](20_Selection_Screens_Lists.md)|Provides a high-level overview of selection screens and classic lists with a focus on related statements. It includes an excursion into the SAP List Viewer (ALV). <br> 💡 The content of this cheat sheet and the executable examples are only 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_SELSCR_LISTS_INTRO` (the "intro" program, from which the other related example programs can be started)|
|
|[Selection Screens and Classic Lists](20_Selection_Screens_Lists.md)|Provides a high-level overview of selection screens and classic lists with a focus on related statements. It includes an excursion into the SAP List Viewer (ALV). <br> 💡 The content of this cheat sheet and the executable examples are only 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_SELSCR_LISTS_INTRO` (the "intro" program, from which the other related example programs can be started)|
|
||||||
@@ -236,12 +236,22 @@ Use the standalone version of the abapGit report to import the demo examples of
|
|||||||
|
|
||||||
## ℹ️ More Information
|
## ℹ️ More Information
|
||||||
- For the system-internal version of the ABAP Keyword Documentation in
|
- For the system-internal version of the ABAP Keyword Documentation in
|
||||||
- ... **classic ABAP**: Access the documentation in the SAP GUI via the transactions `ABAPDOCU` (opens the documentation directly) and `ABAPHELP` (opens an input field with which you can search the documentation content, for example, you can search for a keyword such as `SELECT`). Or, of course, choose `F1` on a keyword in your code. If you are in the SAP GUI (e.g. in `SE80`), the system-internal version opens. If you are in ADT, the documentation opens in the *ABAP Language Help* view.
|
|
||||||
- ... **ABAP Cloud**: In ADT, the documentation is in the *ABAP Language Help* view, where you can also search. If you choose `F1` on a keyword in your code, the documentation opens there.
|
- ... **ABAP Cloud**: In ADT, the documentation is in the *ABAP Language Help* view, where you can also search. If you choose `F1` on a keyword in your code, the documentation opens there.
|
||||||
|
- ... **classic ABAP**: Access the documentation in the SAP GUI via the transactions `ABAPDOCU` (opens the documentation directly) and `ABAPHELP` (opens an input field with which you can search the documentation content, for example, you can search for a keyword such as `SELECT`). Or, of course, choose `F1` on a keyword in your code. If you are in the SAP GUI (e.g. in `SE80`), the system-internal version opens. If you are in ADT, the documentation opens in the *ABAP Language Help* view.
|
||||||
- Links to the online version of the ABAP Keyword Documentation for:
|
- Links to the online version of the ABAP Keyword Documentation for:
|
||||||
- **Standard ABAP**: Unrestricted ABAP language scope 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).
|
- **Standard ABAP**: Unrestricted ABAP language scope for [classic ABAP](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenclassic_abap_glosry.htm):
|
||||||
|
- [Latest version (i.e. version 7.58 currently)](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap.htm)
|
||||||
|
- [Version 7.58](https://help.sap.com/doc/abapdocu_758_index_htm/7.58/en-US/index.htm)
|
||||||
|
- [Version 7.57](https://help.sap.com/doc/abapdocu_757_index_htm/7.57/en-US/index.htm)
|
||||||
|
- [Version 7.56](https://help.sap.com/doc/abapdocu_756_index_htm/7.56/en-US/index.htm)
|
||||||
|
- [Version 7.55](https://help.sap.com/doc/abapdocu_755_index_htm/7.55/en-US/index.htm)
|
||||||
|
- [Version 7.54](https://help.sap.com/doc/abapdocu_754_index_htm/7.54/en-US/index.htm)
|
||||||
|
- [Version 7.53](https://help.sap.com/doc/abapdocu_753_index_htm/7.53/en-US/index.htm)
|
||||||
|
- [Version 7.52](https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/index.htm)
|
||||||
|
- [Version 7.51](https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/index.htm)
|
||||||
|
- [Version 7.50](https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/index.htm)
|
||||||
- **ABAP for Cloud Development**: Restricted ABAP language scope for developments, for example, in the SAP BTP ABAP environment → [Online version of the documentation](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm)
|
- **ABAP for Cloud Development**: Restricted ABAP language scope for developments, for example, in the SAP BTP ABAP environment → [Online version of the documentation](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm)
|
||||||
- For demonstration examples of the ABAP Keyword Documentation in classic ABAP, see the `SABAPDEMOS` package. This package contains all the examples used in the ABAP Keyword Documentation. For the context, class/program name, etc., see the [example page](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap_examples.htm), which is also available in the system-internal SAP GUI version as a node in the topic tree and which summarizes the executable examples. Of course, you can also find the example topics in the context of the individual topic of the ABAP keyword documentation. The example topics are marked with a ⚙️ icon:
|
- For demonstration examples of the ABAP Keyword Documentation, see the `SABAPDEMOS` package. This package contains all the examples used in the ABAP Keyword Documentation. For the context, class names, etc., see the example page ([Cloud](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/abenabap_examples.html)/[Classic](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap_examples.htm)), which is also available in the system-internal version as a node in the topic tree and which summarizes the executable examples. Of course, you can also find the example topics in the context of the individual topic of the ABAP keyword documentation. The example topics are marked with a ⚙️ icon:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user