This commit is contained in:
danrega
2024-04-17 17:41:29 +02:00
parent 0db36495aa
commit 0dc0891180
7 changed files with 200 additions and 112 deletions

View File

@@ -8,13 +8,23 @@
- [Table Keys in Internal Tables (Primary, Secondary, Standard, Empty)](#table-keys-in-internal-tables-primary-secondary-standard-empty)
- [Creating Internal Tables and Types](#creating-internal-tables-and-types)
- [Filling and Copying Internal Tables](#filling-and-copying-internal-tables)
- [Excursions with Internal Tables](#excursions-with-internal-tables)
- [Reading from Internal Tables](#reading-from-internal-tables)
- [Using INSERT and APPEND Statements](#using-insert-and-append-statements)
- [Creating and Filling Internal Tables Using Constructor Expressions](#creating-and-filling-internal-tables-using-constructor-expressions)
- [Excursion: Using Internal Tables in ABAP SQL Statements](#excursion-using-internal-tables-in-abap-sql-statements)
- [Reading Single Lines from Internal Tables](#reading-single-lines-from-internal-tables)
- [Determining the Target Area when Reading Single Lines](#determining-the-target-area-when-reading-single-lines)
- [Reading a Single Line by Index](#reading-a-single-line-by-index)
- [Reading a Single Line Using Table Keys](#reading-a-single-line-using-table-keys)
- [Reading a Single Line Using a Free Key](#reading-a-single-line-using-a-free-key)
- [Addressing Individual Components of Read Lines](#addressing-individual-components-of-read-lines)
- [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)
- [Processing Multiple Internal Table Lines Sequentially](#processing-multiple-internal-table-lines-sequentially)
- [Iteration Expressions](#iteration-expressions)
- [Sorting Internal Tables](#sorting-internal-tables)
- [Modifying Internal Table Content](#modifying-internal-table-content)
- [Deleting Internal Table Content](#deleting-internal-table-content)
- [Deleting Adjacent Duplicate Lines](#deleting-adjacent-duplicate-lines)
- [Deleting the Entire Internal Table Content](#deleting-the-entire-internal-table-content)
- [Excursions](#excursions)
- [Improving Read Performance with Secondary Table Keys](#improving-read-performance-with-secondary-table-keys)
- [Searching and Replacing Substrings in Internal Tables with Character-Like Data Types](#searching-and-replacing-substrings-in-internal-tables-with-character-like-data-types)
@@ -372,22 +382,32 @@ FINAL(it_final) = it_inline1.
"Using the VALUE operator and an internal table type
DATA(it_inline3) = VALUE tt_loc_str( ( ... ) ).
"Not providing any table lines means the table is initial
"and has the same effect as the declaration of
"itab_a1 above.
DATA(it_inline4) = VALUE tt_loc_str( ).
"Table declared inline in the context of a SELECT statement;
"a prior extra declaration of an internal table is not needed.
SELECT * FROM zdemo_abap_fli INTO TABLE @DATA(it_inline4).
SELECT * FROM zdemo_abap_fli INTO TABLE @DATA(it_inline5).
"Instead of
DATA it_sel TYPE TABLE OF zdemo_abap_fli WITH EMPTY KEY.
SELECT * FROM zdemo_abap_fli INTO TABLE @it_sel.
"Using FINAL
SELECT * FROM zdemo_abap_fli INTO TABLE @FINAL(it_inline5).
SELECT * FROM zdemo_abap_fli INTO TABLE @FINAL(it_inline6).
```
> **💡 Note**<br>
> Internal tables can also be created dynamically. Find more information in the [Dynamic Programming cheat sheet](06_Dynamic_Programming.md).
<p align="right"><a href="#top">⬆️ back to top</a></p>
## Filling and Copying Internal Tables
### Using INSERT and APPEND Statements
You can use the ABAP keywords
[`INSERT`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapinsert_itab.htm)
and [`APPEND`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapappend.htm)
@@ -497,7 +517,7 @@ INSERT LINES OF itab2 INTO itab INDEX i.
<p align="right"><a href="#top">⬆️ back to top</a></p>
**Adding lines using constructor expressions**
### Creating and Filling Internal Tables Using Constructor Expressions
As mentioned above, table lines that are constructed inline as
arguments to the `VALUE` operator, for example, can be added to
@@ -530,6 +550,16 @@ TYPES it_type LIKE itab.
"cannot be derived from the context.
DATA(it_in) = VALUE it_type( ( comp1 = a comp2 = b ... )
( comp1 = c comp2 = d ... ) ).
"Creating string tables
DATA(str_tab_a) = VALUE string_table( ( `Hallo` ) ( `World` ) ).
DATA(str_tab_b) = VALUE string_table( ).
"In the previous statement, the internal table is declared
"inline, however, no content, no table lines are provided.
"This means that an initial string table was created. This
"way, the statement has the same effect as the following
"statement.
DATA str_tab_c TYPE string_table.
```
When you use the above assignments (`itab = ...`), the internal table is initialized and the existing content is deleted. To add new lines **without deleting existing content**, use the [`BASE`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenvalue_constructor_params_itab.htm) addition.
@@ -618,9 +648,83 @@ MOVE-CORRESPONDING itab_nested1 TO itab_nested2 EXPANDING NESTED TABLES.
MOVE-CORRESPONDING itab_nested1 TO itab_nested2 EXPANDING NESTED TABLES KEEPING TARGET LINES.
```
**Using the `FILTER` operator**
To create an internal table by copying data from another internal table and
filtering out lines that do not meet the `WHERE` condition, you can use the [`FILTER`
operator](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenconstructor_expression_filter.htm).
- The
`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 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:
|Addition |Details |
|---|---|
|`USING KEY` | Specifies the [table key](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abentable_key_glosry.htm "Glossary Entry") used to evaluate the `WHERE` condition: either a [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"). If the internal table does not have either of these, it must have 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"), which must be specified after `USING KEY`. |
| `EXCEPT` | Specifying `EXCEPT` means that those lines of the existing table are used that do not meet the condition specified in the `WHERE` clause. If `EXCEPT` is not specified, those lines of the existing table that meet the condition are used. |
Examples:
```abap
"FILTER on conditions based on single values
"Assumption: The component num is of type i.
DATA itab1 TYPE SORTED TABLE OF struc WITH NON-UNIQUE KEY num.
DATA itab2 TYPE STANDARD TABLE OF struc WITH NON-UNIQUE SORTED KEY sec_key COMPONENTS num.
DATA itab3 TYPE HASHED TABLE OF struc WITH UNIQUE KEY num.
"The lines meeting the condition are respected.
"Note: The source table must have at least one sorted or hashed key.
"Here, the primary key is used
DATA(f1) = FILTER #( itab1 WHERE num >= 3 ).
"USING KEY primary_key explicitly specified; same as above
DATA(f2) = FILTER #( itab1 USING KEY primary_key WHERE num >= 3 ).
"EXCEPT addition
DATA(f3) = FILTER #( itab1 EXCEPT WHERE num >= 3 ).
DATA(f4) = FILTER #( itab1 EXCEPT USING KEY primary_key WHERE num >= 3 ).
"Secondary table key specified after USING KEY
DATA(f5) = FILTER #( itab2 USING KEY sec_key WHERE num >= 4 ).
DATA(f6) = FILTER #( itab2 EXCEPT USING KEY sec_key WHERE num >= 3 ).
"Note: In case of a hash key, exactly one comparison expression for each key component is allowed;
"only = as comparison operator possible.
DATA(f7) = FILTER #( itab3 WHERE num = 3 ).
"Using a filter table
"In the WHERE condition, the columns of source and filter table are compared.
"Those lines in the source table are used for which at least one line in the filter
"table meets the condition. EXCEPT and USING KEY are also possible.
DATA filter_tab1 TYPE SORTED TABLE OF i
WITH NON-UNIQUE KEY table_line.
DATA filter_tab2 TYPE STANDARD TABLE OF i
WITH EMPTY KEY
WITH UNIQUE SORTED KEY line COMPONENTS table_line.
DATA(f8) = FILTER #( itab1 IN filter_tab1 WHERE num = table_line ).
"EXCEPT addition
DATA(f9) = FILTER #( itab1 EXCEPT IN filter_tab1 WHERE num = table_line ).
"USING KEY is specified for the filter table
DATA(f10) = FILTER #( itab2 IN filter_tab2 USING KEY line WHERE num = table_line ).
"USING KEY is specified for the source table, including EXCEPT
DATA(f11) = FILTER #( itab2 USING KEY sec_key EXCEPT IN filter_tab2 WHERE num = table_line ).
```
> **💡 Note**<br>
> More constructor expressions are available to deal with internal tables. Find more information and examples in the [Constructor Expression cheat sheet](05_Constructor_Expressions.md).
<p align="right"><a href="#top">⬆️ back to top</a></p>
### Excursions with Internal Tables
### Excursion: Using Internal Tables in ABAP SQL Statements
For more details on ABAP SQL, see the cheat sheet on [ABAP SQL](03_ABAP_SQL.md).
**Adding multiple lines from a database table to an internal table** using
@@ -723,91 +827,9 @@ IF itab IS NOT INITIAL.
ENDIF.
```
**Using the `FILTER` operator**
To create an internal table by copying data from another internal table and
filtering out lines that do not meet the `WHERE` condition, you can use the [`FILTER`
operator](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenconstructor_expression_filter.htm).
- The
`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 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:
|Addition |Details |
|---|---|
|`USING KEY` | Specifies the [table key](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abentable_key_glosry.htm "Glossary Entry") used to evaluate the `WHERE` condition: either a [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"). If the internal table does not have either of these, it must have 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"), which must be specified after `USING KEY`. |
| `EXCEPT` | Specifying `EXCEPT` means that those lines of the existing table are used that do not meet the condition specified in the `WHERE` clause. If `EXCEPT` is not specified, those lines of the existing table that meet the condition are used. |
Examples:
```abap
"FILTER on conditions based on single values
"Assumption: The component num is of type i.
DATA itab1 TYPE SORTED TABLE OF struc WITH NON-UNIQUE KEY num.
DATA itab2 TYPE STANDARD TABLE OF struc WITH NON-UNIQUE SORTED KEY sec_key COMPONENTS num.
DATA itab3 TYPE HASHED TABLE OF struc WITH UNIQUE KEY num.
"The lines meeting the condition are respected.
"Note: The source table must have at least one sorted or hashed key.
"Here, the primary key is used
DATA(f1) = FILTER #( itab1 WHERE num >= 3 ).
"USING KEY primary_key explicitly specified; same as above
DATA(f2) = FILTER #( itab1 USING KEY primary_key WHERE num >= 3 ).
"EXCEPT addition
DATA(f3) = FILTER #( itab1 EXCEPT WHERE num >= 3 ).
DATA(f4) = FILTER #( itab1 EXCEPT USING KEY primary_key WHERE num >= 3 ).
"Secondary table key specified after USING KEY
DATA(f5) = FILTER #( itab2 USING KEY sec_key WHERE num >= 4 ).
DATA(f6) = FILTER #( itab2 EXCEPT USING KEY sec_key WHERE num >= 3 ).
"Note: In case of a hash key, exactly one comparison expression for each key component is allowed;
"only = as comparison operator possible.
DATA(f7) = FILTER #( itab3 WHERE num = 3 ).
"Using a filter table
"In the WHERE condition, the columns of source and filter table are compared.
"Those lines in the source table are used for which at least one line in the filter
"table meets the condition. EXCEPT and USING KEY are also possible.
DATA filter_tab1 TYPE SORTED TABLE OF i
WITH NON-UNIQUE KEY table_line.
DATA filter_tab2 TYPE STANDARD TABLE OF i
WITH EMPTY KEY
WITH UNIQUE SORTED KEY line COMPONENTS table_line.
DATA(f8) = FILTER #( itab1 IN filter_tab1 WHERE num = table_line ).
"EXCEPT addition
DATA(f9) = FILTER #( itab1 EXCEPT IN filter_tab1 WHERE num = table_line ).
"USING KEY is specified for the filter table
DATA(f10) = FILTER #( itab2 IN filter_tab2 USING KEY line WHERE num = table_line ).
"USING KEY is specified for the source table, including EXCEPT
DATA(f11) = FILTER #( itab2 USING KEY sec_key EXCEPT IN filter_tab2 WHERE num = table_line ).
```
**Collecting values**
Use the
[`COLLECT`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapcollect.htm)
keyword, for example, to add the values of numeric components to the
corresponding values in an internal table. Use it mainly for internal
tables with a unique primary key, especially hashed tables.
``` abap
COLLECT VALUE dtype( comp1 = a comp2 = b ... ) INTO itab.
```
<p align="right"><a href="#top">⬆️ back to top</a></p>
## Reading from Internal Tables
## Reading Single Lines from Internal Tables
There are three different ways to specify the line to read:
@@ -817,9 +839,7 @@ There are three different ways to specify the line to read:
The following code snippets include [`READ TABLE`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapread_table.htm) statements and [table expressions](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abentable_expressions.htm) to read from internal tables.
**Reading single lines**
*Determining the target area*
### Determining the Target Area when Reading Single Lines
- Copying a line to a data object using the addition `INTO`.
After the copying, the line found exists separately in the internal table and
@@ -875,7 +895,7 @@ the `TRANSPORTING` addition to restrict the fields to be copied).
<p align="right"><a href="#top">⬆️ back to top</a></p>
*Reading a single line by index*
### Reading a Single Line by Index
The following example shows `READ TABLE` statements to read a single line from an internal table by specifying the index. You can use the addition `USING KEY` to specify a table key and thus explicitly determine the table index to use. If the table has a sorted secondary
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
@@ -928,7 +948,7 @@ DATA(line2) = VALUE #( itab[ 7 ] DEFAULT itab[ 8 ] ).
<p align="right"><a href="#top">⬆️ back to top</a></p>
*Reading single lines using table keys*
### Reading a Single Line Using Table Keys
Lines can be read by explicitly specifying the table keys or the alias names, if any.
```abap
@@ -990,7 +1010,7 @@ READ TABLE it FROM sec_keys USING KEY sk INTO wa.
<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
The specified components used as keys need not be part of a table key.
``` abap
@@ -999,7 +1019,7 @@ line = it[ b = 2 ].
READ TABLE it INTO wa WITH KEY b = 2.
```
*Addressing individual components*
### Addressing Individual Components of Read Lines
When reading single lines in general, you can also address individual
components of the line using the [component
@@ -1023,7 +1043,7 @@ DATA(comp4) = dref->c.
<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
This is relevant if you are not interested in the content of a table
line, but only want to find out whether a line exists that matches to the
@@ -1433,6 +1453,8 @@ DELETE str_table WHERE table_line CP `Z*`.
"Result: abcZ / gZhi / pqrZ
```
### Deleting Adjacent Duplicate Lines
`DELETE ADJACENT DUPLICATES` statements allow you to delete all adjacent lines except for the first line that have the same content in certain components. You usually need to perform some appropriate sorting before using these statements.
``` abap
"Implicitly using the primary table key
@@ -1454,6 +1476,8 @@ DELETE ADJACENT DUPLICATES FROM it USING KEY sec_key.
> **💡 Note**<br>
> The system field `sy-subrc` is set to `0` if at least one line has been deleted. It is set to `4` if no lines were deleted.
### Deleting the Entire Internal Table Content
The
[`CLEAR`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapclear.htm)
and

View File

@@ -2,9 +2,6 @@
# ABAP Object Orientation
> **💡 Note**<br>
> This ABAP cheat sheet provides an overview on selected syntax options and concepts related to ABAP object orientation. It is supported by code snippets and an executable example. They are **not** suitable as role models for object-oriented design. Their primary focus is on the syntax and functionality. For more details, refer to the respective topics in the ABAP Keyword Documentation. Find an overview in the topic [ABAP Objects - Overview](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabap_objects_oview.htm).
- [ABAP Object Orientation](#abap-object-orientation)
- [Classes and Objects](#classes-and-objects)
- [Creating Classes](#creating-classes)
@@ -31,6 +28,10 @@
- [More Information](#more-information)
- [Executable Example](#executable-example)
> **💡 Note**<br>
> This ABAP cheat sheet provides an overview on selected syntax options and concepts related to ABAP object orientation. It is supported by code snippets and an executable example. They are **not** suitable as role models for object-oriented design. Their primary focus is on the syntax and functionality. For more details, refer to the respective topics in the ABAP Keyword Documentation. Find an overview in the topic [ABAP Objects - Overview](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabap_objects_oview.htm).
## Classes and Objects
Object-oriented programming in ABAP means dealing with
@@ -71,8 +72,8 @@ Classes ...
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
<p align="right"><a href="#top">⬆️ back to top</a></p>
<p align="right"><a href="#top">⬆️ back to top</a></p>
### Creating Classes

View File

@@ -1999,7 +1999,7 @@ DATA(a) = cl_abap_typedescr=>describe_by_data( some_struc ).
DATA(b) = CAST cl_abap_structdescr( a ).
DATA(c) = b->components.
"get_included_view method: Getting type information for included
"get_included_view method: Getting type information of included
"components, e.g. in case of deep structures
TYPES: BEGIN OF st,
a TYPE i, "elementary type
@@ -2048,14 +2048,14 @@ CREATE OBJECT oref4abs TYPE ('\CLASS=ZCL_DEMO_ABAP_DYNAMIC_PROG').
### Dynamically Creating Data Types at Runtime
You can create data types at program runtime using methods of the type description classes of RTTS.
These types are only valid locally in the program. They are also anonymous, i.e. they are only accessible through type description objects.
As shown above, you can get a reference to a type description object of a type using the static methods of the class `CL_ABAP_TYPEDESCR`.
As shown above, you can get a reference to a type description object of a type using the static methods of the class `CL_ABAP_TYPEDESCR`. You can use type description objects such as `type_descr_obj` of the example to create data objects dynamically with `CREATE DATA` statements and the `TYPE HANDLE` addition as shown further down.
```abap
"For example, a structured type
DATA(type_descr_obj) = CAST cl_abap_structdescr(
cl_abap_typedescr=>describe_by_name( 'SOME_STRUC_TYPE' ) ).
```
The focus here is on using RTTC methods such as `get...`. It is recommended that you use the `get` method instead of the `create` method.
The focus of the following snippets is on using RTTC methods such as `get` to create type description objects. For more information, check the class documentation. It is recommended that you use the `get` method instead of the `create` method.
```abap
"----------------------------------------------------------------------
@@ -2144,7 +2144,9 @@ DATA(tdo_tab_2) = cl_abap_tabledescr=>get(
p_key = VALUE #( ( name = 'CARRID' ) ( name = 'CONNID' ) )
p_unique = cl_abap_typedescr=>true ).
" ... reference types
"----------------------------------------------------------------------
"--- Creating type description objects using reference types ----
"----------------------------------------------------------------------
"Reference types such as the following shall be created using a
"type description object.
TYPES some_ref_type2t TYPE REF TO t.

View File

@@ -292,8 +292,8 @@ DATA(s5) = |{ dobj1 }{ dobj2 }|.
DATA(s6) = |{ COND #( WHEN s5 IS INITIAL THEN `INITIAL` ELSE `NOT INITIAL` ) }|.
"Functional method calls, built-in functions
"Your user alias: XXXX...
DATA(s7) = |Your user alias: { cl_abap_context_info=>get_user_alias( ) }|.
"User alias: XXXX...
DATA(s7) = |User alias: { cl_abap_context_info=>get_user_alias( ) }|.
"Some random number: 39 (example)
DATA(s8) = |Some random number: { cl_abap_random_int=>create( seed = cl_abap_random=>seed( ) min = 1 max = 100 )->get_next( ) }|.
@@ -565,7 +565,7 @@ transform characters of a string to either lowercase or uppercase and
store the result in a target variable.
- 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.
statements.
Syntax examples:
``` abap
@@ -577,6 +577,11 @@ s1 = to_lower( `SOME_FILE.Txt` ). "some_file.txt
s1 = `Hallo`.
TRANSLATE s1 TO UPPER CASE. "HALLO
TRANSLATE s1 TO LOWER CASE. "hallo
"For the transformation of the source directly, you can
"also specify an existing, changeable data object as
"the source in a simple assignment as follows.
s1 = to_upper( s1 ).
```
<p align="right"><a href="#top">⬆️ back to top</a></p>
@@ -1808,6 +1813,7 @@ 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>
## More String Functions
As also covered in the [Misc Built-in Functions cheat sheet](24_Misc_Builtin_Functions.md), the following sections show more string functions available.
### Checking the Similarity of Strings
@@ -2038,7 +2044,7 @@ IF s8 NP `*c#D*`. ... "false; sy-fdpos: 2
<p align="right"><a href="#top">⬆️ back to top</a></p>
### Miscellaneous Classes for String Processing
The following list shows a selected set of classes that support string processing.
The following list (as also covered in the [Misc ABAP Classes cheat sheet](22_Misc_ABAP_Classes.md)) shows a selected set of classes that support string processing.
- `CL_ABAP_CHAR_UTILITIES`: As previously mentioned, this class provides utilities for string processing, such as attributes that represent new lines and horizontal tabs.

View File

@@ -10,6 +10,7 @@
- [RAP Saver Class and Saver Methods](#rap-saver-class-and-saver-methods)
- [BDEF Derived Types](#bdef-derived-types)
- [Components of BDEF Derived Types](#components-of-bdef-derived-types)
- [Secondary Table Keys of BDEF Derived Types](#secondary-table-keys-of-bdef-derived-types)
- [EML Syntax](#eml-syntax)
- [EML Syntax for Modifying Operations](#eml-syntax-for-modifying-operations)
- [EML Syntax for Reading Operations](#eml-syntax-for-reading-operations)
@@ -298,7 +299,7 @@ authorization master ( instance )
//Operations for associations (many specification options are possible)
//The following example means enabling create-by-association operations for associations
//Assumption: _child is specified in the the underlying CDS data model.
//Assumption: _child is specified in the underlying CDS data model.
association _child { create; }
//Non-standard operations (check the specification options in the documentation, e.g. feature
@@ -841,6 +842,48 @@ Bullet points on selected `%` components:
<p align="right"><a href="#top">⬆️ back to top</a></p>
### Secondary Table Keys of BDEF Derived Types
- Internal tables typed with BDEF derived types (`TYPE TABLE FOR ...`) are standard tables with an empty [primary table key](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenprimary_table_key_glosry.htm) (`primary_key`).
- Predefined [secondary table key](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensecondary_table_key_glosry.htm) are available for many types.
- These secondary table keys are always [sorted keys](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensorted_key_glosry.htm).
- Currently available secondary table keys (as also visibile in one of the images above when using the F2 help in ADT):
- `entity`: Includes `%key`
- `cid`: Includes `%cid` or `%cid_ref`, and can - depending on the type - also include `%key` and `%pid`
- `draft`: Available in draft scenarios; includes `%is_draft`; can also include `%key` and `%pid`
- `pid` (alias name `id`): Available in late numbering scenarios; includes `%pid`; can also include `%tmp` and `%key`
```abap
DATA itab_cr TYPE TABLE FOR CREATE zdemo_abap_rap_ro_m.
itab_cr = VALUE #( %control-key_field = if_abap_behv=>mk-on
%control-field1 = if_abap_behv=>mk-on
%control-field2 = if_abap_behv=>mk-on
%control-field3 = if_abap_behv=>mk-on
%control-field4 = if_abap_behv=>mk-on
( %cid = `cid1`
%key-key_field = 1
field1 = 'aaa'
field2 = 'bbb'
field3 = 11
field4 = 111 ) ).
"Secondary table keys available in the example table: cid, entity
"The statements demonstrate the secondary table keys using table expressions.
"The statements commented out raise a syntax warning. The secondary table key
"should be specified explicitly.
"DATA(line_a) = itab_cr[ %cid = `cid1` ].
"DATA(line_b) = itab_cr[ %cid = `cid1` %key = VALUE #( key_field = 1 ) ].
DATA(line_c) = itab_cr[ KEY cid COMPONENTS %cid = `cid1`
%key = VALUE #( key_field = 1 ) ].
"DATA(line_d) = itab_cr[ %key = VALUE #( key_field = 1 ) ].
"The COMPONENTS addition is optional.
DATA(line_e) = itab_cr[ KEY entity %key = VALUE #( key_field = 1 ) ].
```
<p align="right"><a href="#top">⬆️ back to top</a></p>
## EML Syntax
The focus is here on selected EML statements. These statements can be

View File

@@ -1504,7 +1504,7 @@ xco_cp_json=>data->from_string( json_created_xco )->apply( VALUE #(
<td> Class </td> <td> Details/Code Snippet </td>
</tr>
<tr>
<td> <code>XCO_CP_ABAP_REPOSITORY</code> </td>
<td> <code>XCO_CP_ABAP</code><br><code>XCO_CP_ABAP_REPOSITORY</code> </td>
<td>
<ul>
@@ -1568,6 +1568,9 @@ DATA(handler_cl) = xco_cp_abap=>class( 'ZCL_DEMO_ABAP_UNIT_TEST' ).
DATA(subcl) = xco_cp_abap=>class( 'CL_ABAP_TYPEDESCR' )->subclasses->all->get( ).
"Getting the names of the subclasses
DATA(subcl_names) = xco_cp_abap=>class( 'CL_ABAP_TYPEDESCR' )->subclasses->all->get_names( ).
"Getting the direct superclass
DATA(direct_super_class) = xco_cp_abap=>class( 'CL_ABAP_DATADESCR' )->definition->content(
)->get_superclass( )->name.
"Taking an XCO handler for a database table as an example, see some of the
"details you can retrieve. The method names should be self-explanatory.
@@ -1945,6 +1948,10 @@ TRY.
cl_bali_log_db=>get_instance( )->delete_log( log = log_del ).
ENDLOOP.
CATCH cx_bali_runtime.
ENDTRY.
TRY.
"Creating new application log entries
"Creating a free text and adding it to the application log
DATA(free_txt) = cl_bali_free_text_setter=>create( severity = if_bali_constants=>c_category_free_text

View File

@@ -536,6 +536,7 @@ Search functions
<br><br>
``` abap
"---------------- find ----------------
"The find function searches for the substring specified and returns the offset
"7
DATA(find1) = find( val = str sub = `of` ).
@@ -567,6 +568,7 @@ DATA(find8) = find( val = str sub = `es` occ = 3 ).
"15
DATA(find9) = find( val = str pcre = `\.` ).
"---------------- find_end ----------------
"find_end returns the sum of the offset of the occurrence plus the length of the match
"9 (7 + 2)
DATA(find_end1) = find_end( val = str sub = `of` ).
@@ -574,6 +576,7 @@ DATA(find_end1) = find_end( val = str sub = `of` ).
"7 (6 + 1)
DATA(find_end2) = find_end( val = str pcre = `\s` ).
"---------------- find_any_of ----------------
"find_any_of returns the offset of the occurrence of any character contained
"in a substring. The search is always case-sensitive.
"2 (character e is found)
@@ -582,6 +585,7 @@ DATA(find_any_of1) = find_any_of( val = str sub = `x523z4e` ).
"-1
DATA(find_any_of2) = find_any_of( val = str sub = `zwq85t` ).
"---------------- find_any_not_of ----------------
"find_any_not_of is the negation of find_any_of
"0 (very first character in the searched string)
DATA(find_any_not_of1) = find_any_not_of( val = str sub = `ieces` ).
@@ -1319,6 +1323,7 @@ DATA(line_index5) = line_index( itab_sec[ KEY sk comp2 = 'a' ] ).
"Specifying the pseudo component table_line
"1
DATA(line_index6) = line_index( itab_str[ table_line = `aaa` ] ).
"0
DATA(line_index7) = line_index( itab_str[ table_line = `zzz` ] ).
```
@@ -1693,7 +1698,7 @@ SELECT SINGLE
uuid( ) AS uuid
FROM zdemo_abap_carr
WHERE carrid = 'LH'
WHERE carrid = char`LH`
INTO @DATA(special_functions).
```