diff --git a/01_Internal_Tables.md b/01_Internal_Tables.md
index 994b269..f779c5d 100644
--- a/01_Internal_Tables.md
+++ b/01_Internal_Tables.md
@@ -491,7 +491,7 @@ DATA it_elem_6 TYPE TABLE OF ty_c3 WITH EMPTY KEY.
"Apart from the globally available elementary built-in ABAP types, you can
"also use elementary types from the DDIC such as data elements that are
"visible anywhere. You can also refer to CDS simple types that
-"constitute elemenary data types.
+"constitute elementary data types.
DATA it_elem_7 TYPE TABLE OF timestamp WITH EMPTY KEY.
DATA it_elem_8 TYPE TABLE OF timestampl WITH EMPTY KEY.
@@ -1125,7 +1125,7 @@ MOVE-CORRESPONDING itab_nested1 TO itab_nested2 EXPANDING NESTED TABLES KEEPING
> **💡 Note**
-> The `CL_ABAP_CORRESPONDING` class can be used for assignments. Find an example in the [Misc ABAP Classes](22_Misc_ABAP_Classes.md) cheat sheet.
+> The `CL_ABAP_CORRESPONDING` class can be used for assignments. Find an example in the [Released ABAP Classes](22_Released_ABAP_Classes.md) cheat sheet.
)(.|\n)*?(<\/p>)` IN html_b WITH `$1Hi$3`.
## 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. +As also covered in the [Built-In Functions](24_Builtin_Functions.md), the following sections show more string functions available. ### Checking the Similarity of Strings @@ -2049,7 +2060,7 @@ IF s8 NP `*c#D*`. ... "false; sy-fdpos: 2 ### Miscellaneous Classes for String Processing -As also covered in the [Misc ABAP Classes](22_Misc_ABAP_Classes.md) cheat sheet, the following list shows a selected set of classes that support string processing. +As also covered in the [Released ABAP Classes](22_Released_ABAP_Classes.md) cheat sheet, the following list 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. diff --git a/08_EML_ABAP_for_RAP.md b/08_EML_ABAP_for_RAP.md index f5997cc..3865da8 100644 --- a/08_EML_ABAP_for_RAP.md +++ b/08_EML_ABAP_for_RAP.md @@ -159,7 +159,7 @@ The following points cover RAP-related terms such as *RAP business objects* and - The [global class](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenglobal_class_glosry.htm "Glossary Entry") of a behavior pool does not implement the behavior itself. It is - (initially) empty apart from the declaration and implementation part skeletons. The behavior implementation is coded in local + empty on creation apart from the declaration and implementation part skeletons. The behavior implementation is coded in local [RAP handler classes](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabp_handler_class_glosry.htm "Glossary Entry") and a [RAP saver @@ -1101,7 +1101,7 @@ derived_type = CORRESPONDING #( some_other_type CHANGING CONTROL ). #### ABAP SQL Statements with BDEF Derived Types -The ABAP SQL statements `INSERT`, `UPDATE`, `MODIFY`, and `DELETE` offer the [`MAPPING FROM ENTITY`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapmapping_from_entity.htmaddition) addition to handle BDEF derived types. +The ABAP SQL statements `INSERT`, `UPDATE`, `MODIFY`, and `DELETE` offer the [`MAPPING FROM ENTITY`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapmapping_from_entity.htm) addition to handle BDEF derived types. ```abap "--------------- INSERT --------------- diff --git a/13_Program_Flow_Logic.md b/13_Program_Flow_Logic.md index 831b97f..9090736 100644 --- a/13_Program_Flow_Logic.md +++ b/13_Program_Flow_Logic.md @@ -86,7 +86,7 @@ ENDIF. - The components of such relational expressions can be [comparisons](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencomparison_glosry.htm) or [predicates](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenpredicate_glosry.htm). Note that for [comparison expressions](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencomparison_expression_glosry.htm), the comparisons are carried out according to [comparison rules](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenlogexp_rules.htm). -The following code snippet shows a selection of possible expressions and operands of such expressions using a big `IF` statement. Certainly, such a huge statement is far from ideal. Here, the intention is to just cover many syntax options in one go for demonstration purposes. For more information on built-in functions, you can refer to the [Misc Built-In Functions](/24_Misc_Builtin_Functions.md) cheat sheet. +The following code snippet shows a selection of possible expressions and operands of such expressions using a big `IF` statement. Certainly, such a huge statement is far from ideal. Here, the intention is to just cover many syntax options in one go for demonstration purposes. For more information on built-in functions, you can refer to the [Built-In Functions](24_Builtin_Functions.md) cheat sheet. ```abap "Some declarations to be used in the IF statement below @@ -601,7 +601,7 @@ CALL FUNCTION func params. - `params`: Parameter list or table - Incorrectly provided function module names or parameters are not checked until runtime - Unlike method calls, you cannot specify inline declarations as actual parameters. -- Regarding dynamic function module calls: Static and dynamic function module calls are syntactically identical. In a static call, the function module is specified as a character literal or a constant, with parameters passed statically. Conversely, in a dynamic call, the function module's name is specified in a variable, with parameters passed dynamically. For dynamic calls, you can utilize the `CL_ABAP_DYN_PRG` as shown in the [Misc ABAP Classes cheat sheet](22_Misc_ABAP_Classes.md). +- Regarding dynamic function module calls: Static and dynamic function module calls are syntactically identical. In a static call, the function module is specified as a character literal or a constant, with parameters passed statically. Conversely, in a dynamic call, the function module's name is specified in a variable, with parameters passed dynamically. For dynamic calls, you can utilize the `CL_ABAP_DYN_PRG` as shown in the [Released ABAP Classes](22_Released_ABAP_Classes.md). - When a function module call is made, the system field `sy-subrc` is set to 0. If a non-class-based exception is raised and a value is assigned to handle it, this value updates `sy-subrc`. Example function module calls with parameter passing and exception handling: diff --git a/21_XML_JSON.md b/21_XML_JSON.md index be50e93..4934106 100644 --- a/21_XML_JSON.md +++ b/21_XML_JSON.md @@ -1478,7 +1478,7 @@ ENDCLASS. ### Converting string <-> xstring In the code snippets above and in the executable example, many operations are performed using binary data. This excursion shows the conversion of string <-> xstring using a codepage. The examples use UTF-8. -For example, you can use the `cl_abap_conv_codepage` class and the [XCO library](https://help.sap.com/docs/btp/sap-business-technology-platform/xco-library?version=Cloud). Using the `xco_cp` class of the XCO library, you can also process Base64 representations of raw binary data (see the snippet for `xco_cp` in the [String Processing](/22_Misc_ABAP_Classes.md#string-processing) section of the Misc ABAP Classes cheat sheet). +For example, you can use the `cl_abap_conv_codepage` class and the [XCO library](https://help.sap.com/docs/btp/sap-business-technology-platform/xco-library?version=Cloud). Using the `xco_cp` class of the XCO library, you can also process Base64 representations of raw binary data (see the snippet for `xco_cp` in the [String Processing](/22_Released_ABAP_Classes.md#string-processing) section of the *Regular ABAP Classes* cheat sheet). ```abap DATA(xml_string) = `CL_ABAP_REGEX CL_ABAP_MATCHER CREATE_PCRE method creates instances of regular expressions with PCRE syntax.CL_ABAP_MATCHER class, which applies the regular expressions.| Class | Details/Code Snippet | + CL_ABAP_REGEX CL_ABAP_MATCHER |
+
+
+ +``` abap +"Example string +DATA(str) = `a1 # B2 ? cd . E3`. + +"----------- Creating an instance of a regular expression ----------- + +"Creating an instance of a regular expression with PCRE syntax +"using cl_abap_regex + +"Example pattern: Any-non digit followed by a digit +DATA(regex) = cl_abap_regex=>create_pcre( pattern = `\D\d` + ignore_case = abap_true ). + +"----------- Creating matchers ----------- + +"Two ways are possible (both ways return references of type +"ref to cl_abap_matcher): +"- create_matcher method of the cl_abap_regex class +"- create_pcre method of the cl_abap_matcher class +"Note that several importing parameters are available to enable +"further settings of the regular expression, e.g. ignoring the +"case, using the extended mode, etc. The example pass a string +"to the 'text' parameter. You can also specify internal tables +"with the 'table' parameter and more. + +"Creating a matcher using the create_matcher method of the cl_abap_regex class +DATA(matcher_1) = regex->create_matcher( text = str ). +"Creating a matcher in one go using method chaining +DATA(matcher_2) = cl_abap_regex=>create_pcre( pattern = `\D\d` + ignore_case = abap_true + )->create_matcher( text = str ). + +"Creating a matcher using the create_pcre method of the cl_abap_matcher class +DATA(matcher_3) = cl_abap_matcher=>create_pcre( pattern = `\D\d` + text = str + ignore_case = abap_true ). + +"----------- Exploring searching and replacing ----------- + +"--- Finding all occurrences using the find_all method --- +"In the example, result has the type match_result_tab containing the findings. +DATA(result_fa1) = matcher_1->find_all( ). + +*LINE OFFSET LENGTH SUBMATCHES +*0 0 2 OFFSET LENGTH +* +*0 5 2 OFFSET LENGTH +* +*0 15 2 OFFSET LENGTH + +DATA(result_fa2) = matcher_2->find_all( ). +ASSERT result_fa2 = result_fa1. + +"Getting the result in one go using method chaining with cl_abap_matcher +DATA(result_fa3) = cl_abap_matcher=>create_pcre( pattern = `\D\d` + text = str + ignore_case = abap_true + )->find_all( ). +ASSERT result_fa3 = result_fa1. + +"--- Example with submatches --- + +str = `XabcdXXefgXXhXXijklmnXX`. + +DATA(result_fa4) = cl_abap_matcher=>create_pcre( pattern = `X(.*?)X` + text = str + ignore_case = abap_true + )->find_all( ). + +*LINE OFFSET LENGTH SUBMATCHES +*0 0 6 OFFSET LENGTH +* 1 4 +*0 6 5 OFFSET LENGTH +* 7 3 +*0 11 3 OFFSET LENGTH +* 12 1 +*0 14 8 OFFSET LENGTH +* 15 6 + +"--- Replacing all occurrences using the 'replace_all' method --- + +DATA(matcher_repl_1) = cl_abap_regex=>create_pcre( pattern = `X(.*?)X` + )->create_matcher( text = str ). + +"4 +DATA(repl_count_1) = matcher_repl_1->replace_all( newtext = `#$1#` ). + +"#abcd##efg##h##ijklmn#X +DATA(repl_result_1) = matcher_repl_1->text. + +"Using cl_abap_matcher +DATA(matcher_repl_2) = cl_abap_matcher=>create_pcre( pattern = `X(.*?)X` + text = str ). +DATA(repl_count_2) = matcher_repl_2->replace_all( newtext = `#$1#` ). +DATA(repl_result_2) = matcher_repl_2->text. + +"---- Sequential processing of the regular expression --- +"---- using the find_next method ------------------------ +"The example explores various other methods, and writes +"information to a string table. + +str = `a1bc2def3ghij45klm67opqr8stuvwx90yz`. + +DATA(matcher_fn) = cl_abap_matcher=>create_pcre( pattern = `\d(\D.)` + text = str ). + +DATA strtab TYPE string_table. +WHILE matcher_fn->find_next( ) = abap_true. + APPEND |---- Finding { sy-index } -----| TO strtab. + + "Type match_result + DATA(match_result) = matcher_fn->get_match( ). + + DATA(offset) = matcher_fn->get_offset( ). + DATA(length) = matcher_fn->get_length( ). + DATA(matched_content) = str+offset(length). + + APPEND |Match offset: { offset }| TO strtab. + APPEND |Match length: { length }| TO strtab. + APPEND |Match content: { matched_content }| TO strtab. + + "Type match_result + DATA(subgroup) = matcher_fn->get_match( )-submatches. + + LOOP AT subgroup INTO DATA(wa). + DATA(sub_tabix) = sy-tabix. + DATA(submatch_line) = wa. + DATA(submatch_offset) = wa-offset. + DATA(submatch_length) = wa-length. + DATA(submatch) = matcher_fn->get_submatch( sub_tabix ). + APPEND |Submatch { sub_tabix } offset: { submatch_offset }| TO strtab. + APPEND |Submatch { sub_tabix } length: { submatch_length }| TO strtab. + APPEND |Submatch { sub_tabix } content: { submatch }| TO strtab. + ENDLOOP. + +ENDWHILE. + +"---- Using an object of type cl_abap_regex in ABAP --- +"---- statements with the REGEX addition -------------- + +DATA(result_find_all_1) = cl_abap_matcher=>create_pcre( pattern = `\d(\D.)` + text = str + )->find_all( ). +DATA(result_find_all_2) = cl_abap_regex=>create_pcre( pattern = `\d(\D.)` + )->create_matcher( text = str + )->find_all( ). + +DATA(reg_expr) = cl_abap_regex=>create_pcre( pattern = `\d(\D.)` ). + +FIND ALL OCCURRENCES OF REGEX reg_expr IN str RESULTS DATA(result_find_all_3). + +*LINE OFFSET LENGTH SUBMATCHES +*0 1 3 OFFSET LENGTH +* 2 2 +*0 4 3 OFFSET LENGTH +* 5 2 +*0 8 3 OFFSET LENGTH +* 9 2 +*0 14 3 OFFSET LENGTH +* 15 2 +*0 19 3 OFFSET LENGTH +* 20 2 +*0 24 3 OFFSET LENGTH +* 25 2 +*0 32 3 OFFSET LENGTH +* 33 2 + +ASSERT result_find_all_3 = result_find_all_1. +ASSERT result_find_all_3 = result_find_all_2. + +"Note that the REGEX addition is obsolete when using (POSIX) syntax patterns +"A syntax warning is displayed for the following example. +"FIND ALL OCCURRENCES OF REGEX `\d(\D.)` IN str RESULTS DATA(result_8). + +"The syntax warning can be suppressed using a pragma +FIND ALL OCCURRENCES OF REGEX `\d(\D.)` IN str RESULTS DATA(result_find_all_4) ##REGEX_POSIX. + +"Using PCRE instead +FIND ALL OCCURRENCES OF PCRE `\d(\D.)` IN str RESULTS DATA(result_find_all_5). +ASSERT result_find_all_5 = result_find_all_3. + +"---------------- Exploring more parameters of the create_pcre method ---------------- +"See the class documentation for more parameters and information. + +"--- enable_multiline parameter --- + +str = |abc\ndef\nghi\njkl|. + +DATA(matcher_no_ml) = cl_abap_matcher=>create_pcre( pattern = `^` + text = str ). +"1 +DATA(repl_count_no_ml) = matcher_no_ml->replace_all( newtext = `#` ). +"|#abc\ndef\nghi\njkl| +DATA(repl_result_no_ml) = matcher_no_ml->text. + +DATA(matcher_w_ml) = cl_abap_matcher=>create_pcre( pattern = `^` + text = str + enable_multiline = abap_true ). +"4 +DATA(repl_count_w_ml) = matcher_w_ml->replace_all( newtext = `#` ). +"|#abc\n#def\n#ghi\n#jkl| +DATA(repl_result_w_ml) = matcher_w_ml->text. + +"--- table/ignore_case parameters --- + +data(str_table) = VALUE string_table( ( `abZdez` ) ( `zZfghZ` ) ( `ijkZZz` ) ( `zzzzZ` ) ). + +DATA(matcher_tab) = cl_abap_matcher=>create_pcre( pattern = `z+` + table = str_table + ignore_case = abap_true ). +"6 +DATA(repl_count_tab) = matcher_tab->replace_all( newtext = `#` ). +"ab#de# / #fgh# / ijk# / # +DATA(repl_result_tab) = matcher_tab->table. + +"--- extended parameter --- + +str = `abc def`. + +DATA(matcher_w_extended) = cl_abap_matcher=>create_pcre( pattern = `abc def` + text = str ). + +"No replacement in the following example as the extended mode is +"enabled by default. +"0 +DATA(repl_count_w_extended) = matcher_w_extended->replace_all( newtext = `#` ). +"abc def +DATA(repl_result_w_extended) = matcher_w_extended->text. + +"Disabling the extended mode so that whitespaces are not ignored +DATA(matcher_not_extended) = cl_abap_matcher=>create_pcre( pattern = `abc def` + text = str + extended = abap_false ). + +"1 +DATA(repl_count_not_extended) = matcher_not_extended->replace_all( newtext = `#` ). +"# +DATA(repl_result_not_extended) = matcher_not_extended->text. +``` + + |
+
+
+
count countcount_any_ofcount_any_not_of