This commit is contained in:
danrega
2024-07-23 16:48:34 +02:00
parent 4c0fd846e5
commit 62ba5f78ac
4 changed files with 1084 additions and 24 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1671,6 +1671,36 @@ LOOP AT itab INTO DATA(wa3).
ENDLOOP.
ENDLOOP.
"The objective of the following example is to extract the content of the segments that
"are positioned within /.../ in a URL. The segments are stored in an internal table.
DATA(url) = `https://help.sap.com/docs/abap-cloud/abap-concepts/controlled-sap-luw/`.
FIND ALL OCCURRENCES OF PCRE `(?<=/)([^/]+)(?=/)` IN url RESULTS DATA(res).
"Details on the regular expression:
"- Positive lookbehind (?<=/) that determines that the content is preceded by `/`
"- Positive lookahead (?=/) that determines that the content is followed by `/
"- ([^/]+) in between determines that any sequence of characters that are not `/` are matched
"- The match is put in parentheses to store the submatch
"The RESULTS addition stores findings in an internal table of type match_result_tab.
"Submatches (i.e. length and offset values of the submatches) are stored in internal
"tables themselves. Therefore, the example uses nested loops and the substring function
"to retrieve the strings.
DATA(url_parts_for_loop) = VALUE string_table( FOR wa1 IN res
FOR wa2 IN wa1-submatches
( substring( val = url off = wa2-offset len = wa2-length ) ) ).
*Content:
*help.sap.com
*docs
*abap-cloud
*abap-concepts
*controlled-sap-luw
"More additions can be specified such as WHERE, USING KEY, FROM/TO, STEP
"WHERE condition

View File

@@ -1770,6 +1770,45 @@ DATA(itab) = value string_table( ( `Cathy's black cat on the mat played with the
"Pattern: 't' at the beginning of a word followed by another character
FIND FIRST OCCURRENCE OF PCRE `\bt.` IN TABLE itab
IGNORING CASE MATCH LINE DATA(d) MATCH OFFSET DATA(e) MATCH LENGTH DATA(f). "d: 1, e: 21, f: 2
"The objective of the following example is to extract the content of the segments that
"are positioned within /.../ in a URL. The segments are stored in an internal table.
DATA(url) = `https://help.sap.com/docs/abap-cloud/abap-concepts/controlled-sap-luw/`.
DATA url_parts TYPE string_table.
FIND ALL OCCURRENCES OF PCRE `(?<=/)([^/]+)(?=/)` IN url RESULTS DATA(res).
"Details on the regular expression:
"- Positive lookbehind (?<=/) that determines that the content is preceded by `/`
"- Positive lookahead (?=/) that determines that the content is followed by `/
"- ([^/]+) in between determines that any sequence of characters that are not `/` are matched
"- The match is put in parentheses to store the submatch
"The RESULTS addition stores findings in an internal table of type match_result_tab.
"Submatches (i.e. length and offset values of the submatches) are stored in internal
"tables themselves. Therefore, the example uses nested loops and the substring function
"to retrieve the strings.
LOOP AT res INTO DATA(finding).
LOOP AT finding-submatches INTO DATA(sub).
DATA(url_part) = substring( val = url off = sub-offset len = sub-length ).
APPEND url_part TO url_parts.
ENDLOOP.
ENDLOOP.
"The following statement uses nested iteration expressions with FOR instead of nested
"LOOP statements.
DATA(url_parts_for_loop) = VALUE string_table( FOR wa1 IN res
FOR wa2 IN wa1-submatches
( substring( val = url off = wa2-offset len = wa2-length ) ) ).
ASSERT url_parts = url_parts_for_loop.
*Content:
*help.sap.com
*docs
*abap-cloud
*abap-concepts
*controlled-sap-luw
```
<p align="right"><a href="#top">⬆️ back to top</a></p>

View File

@@ -696,7 +696,7 @@ Expand the following collapsible section to view the code of two simplified exam
**Example 1:**
- The example class implements the `IF_SERIALIZABLE_OBJECT` interface, using the standard behavior to serialize and deserialize all instance attributes (i.e. the helper methods mentioned below are not implemented).
- The values of of all deserialized instance attributes are displayed.
- The values of all deserialized instance attributes are displayed.
```abap
CLASS zcl_some_class DEFINITION