From bc653258a92984e855d5df2de429adeb90031943 Mon Sep 17 00:00:00 2001 From: danrega <16720986+danrega@users.noreply.github.com> Date: Mon, 20 Mar 2023 09:43:13 +0100 Subject: [PATCH] Update content --- 07_String_Processing.md | 4 ++-- 15_CDS_view_entities.md | 5 ++--- README.md | 10 +++++----- src/zcl_demo_abap_cds_ve.clas.abap | 12 +++++------- src/zdemo_abap_cds_ve_assoc.ddls.asddls | 6 +++--- src/zdemo_abap_cds_ve_joins.ddls.asddls | 2 +- src/zdemo_abap_cds_ve_sel.ddls.asddls | 4 +--- 7 files changed, 19 insertions(+), 24 deletions(-) diff --git a/07_String_Processing.md b/07_String_Processing.md index 29b14f2..9ef5528 100644 --- a/07_String_Processing.md +++ b/07_String_Processing.md @@ -963,7 +963,7 @@ ENDIF. "Addition FIRST OCCURRENCE OF: Explicit specification to search for the first occurrence FIND FIRST OCCURRENCE OF `se` IN str - MATCH COUNT DATA(cnt2) "1 (always 1 when searching and find the first occurrence) + MATCH COUNT DATA(cnt2) "1 (always 1 when searching and finding the first occurrence) MATCH OFFSET DATA(off2). "4 "Omitting FIRST OCCURRENCE OF and ALL OCCURRENCES OF addition means searching for the @@ -1490,7 +1490,7 @@ Character Sets, Ranges, Subgroups and Lookarounds | `(?!...)` | Negative lookahead, returns characters that are not followed by a specified pattern without including this pattern | `a(?!b)` | abc ade | abc **a**de | **a**bc ade | | `(?<=...)` | Positive lookbehind, returns characters that are preceded by a specified pattern without including this pattern | `(?<=\s)c` | ab c abcd | ab **c** abcd (it is preceded by a blank) | ab c ab**c**d | | `(?**c**d (it is not preceded by a blank) | ab **c** abcd | -| `\n` | Backreference, refers to a previous capturing group; n represents the number of the group index that starts with 1 | `(a.)(\w*)\1` | abcdefabghij | **abcdefab**ghij
Note: Capturing group 1 holds `ab` in the example. The second capturing group captures all word characters up to `ab` is found. | **ab**cdefabghij | +| `\n` | Backreference, refers to a previous capturing group; n represents the number of the group index that starts with 1 | `(a.)(\w*)\1` | abcdefabghij | **abcdefab**ghij
Note: Capturing group 1 holds `ab` in the example. The second capturing group captures all word characters until `ab` is found. | **ab**cdefabghij | | `\K` | Resets the starting point of a match, i.e. findings are excluded from the final match | `a.\Kc` | abcd | ab**c**d | **abc**d | > **💡 Note**
diff --git a/15_CDS_view_entities.md b/15_CDS_view_entities.md index 8e6467d..5328ce5 100644 --- a/15_CDS_view_entities.md +++ b/15_CDS_view_entities.md @@ -1,11 +1,10 @@ -# CDS view entities +# CDS View Entities -- [CDS view entities](#cds-view-entities) +- [CDS View Entities](#cds-view-entities) - [More Information](#more-information) - [Executable Example](#executable-example) Core data services (CDS) are an infrastructure for defining and consuming semantically rich data models on the [standard database](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenstandard_db_glosry.htm) of an [AS ABAP](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenas_abap_glosry.htm). -CDS basically is an enhancement of ABAP SQL to reduce the rich variety of syntax. > **💡 Note**
> - For cheat sheet content on CDS views, check out [this blog](https://blogs.sap.com/2022/10/24/feature-matrix-data-modeling-with-abap-core-data-services/). diff --git a/README.md b/README.md index 60a9240..8964cef 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ ABAP cheat sheets[^1] ... - [ABAP for Cloud Development](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap_for_sap_cloud_glosry.htm): Restricted ABAP language scope for developments in the [SAP BTP ABAP environment](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abensap_btp_abap_env_glosry.htm) → [Online version of the documentation](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm) - [Standard ABAP](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenstandard_abap_glosry.htm): Unrestricted ABAP language scope, for example, for developments in an on-premise ABAP system → [Online version of the documentation (latest version)](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap.htm) - Check the [Known Issues](#-known-issues) and [Disclaimer](#%EF%B8%8F-disclaimer). -- The cheat sheets provide links to glossary entries and topics in the ABAP Keyword Documentation. Note that in most case, these links refer to the ABAP for Cloud Development version. +- The cheat sheets provide links to glossary entries and topics in the ABAP Keyword Documentation. Note that in most cases, these links refer to the ABAP for Cloud Development version.
@@ -71,13 +71,13 @@ ABAP cheat sheets[^1] ... |[A Glimpse on AMDP](12_AMDP.md)|Covers ABAP Managed Database Procedures (AMDP): AMDP Procedures and AMDP Functions (including CDS Table Functions)|[zcl_demo_abap_amdp](./src/zcl_demo_abap_amdp.clas.abap)| |[Program Flow Logic](13_Program_Flow_Logic.md)|Deals with control structures (`IF`, `CASE`), loops (`DO`, `WHILE`) and exception handling|[zcl_demo_abap_prog_flow_logic](./src/zcl_demo_abap_prog_flow_logic.clas.abap)| |[A Glimpse on ABAP Unit Tests](14_ABAP_Unit_Tests.md)|Contains basic information about unit testing in ABAP|[zcl_demo_abap_unit_test](./src/zcl_demo_abap_unit_test.clas.abap)| -|[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)|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)|
## 🎬 Getting Started with the Examples -The executable examples are designed to be imported into the SAP BTP ABAP environment, but they are basically suitable for both on-premise systems and the SAP BTP ABAP environment (hence there are no ABAP reports included). Therefore, check the information in the following collapsible sections for your system environment and perform the required steps. +The executable examples are designed to be imported into the SAP BTP ABAP environment, but they are basically suitable for both on-premise systems (ABAP release > 7.56; especially the RAP examples) and the SAP BTP ABAP environment (hence there are no ABAP reports included). Therefore, check the information in the following collapsible sections for your system environment and perform the required steps.
1) General info @@ -137,7 +137,7 @@ https://github.com/SAP-samples/abap-cheat-sheets.git
**Prerequisites** -- [x] It is assumed that you are running the latest [ABAP release](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abennews-75.htm). The content has also been tested with release 7.56. Note that the RAP examples require at least ABAP version 7.56. +- [x] It is assumed that you are running the latest [ABAP release](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abennews-75.htm). Note that the RAP examples, for example, require at least ABAP version 7.56. - [x] Before importing the code, you have performed a system-wide search for classes named `ZCL_DEMO_ABAP*`, for example, to avoid errors when you try to import the code. If someone has already imported the content into the system, you can simply check out that imported version and proceed to the step *3) Run the code*. - [x] You have downloaded and installed the ABAP Development Tools (ADT). Make sure that you are using the latest version, as indicated on the [installation page](https://tools.hana.ondemand.com/#abap). - [x] You have created an ABAP project in ADT that allows you to access your application server as mentioned above. Your login language is English. @@ -188,7 +188,7 @@ Use the standalone version of the abapGit report to import the demo examples of - Only one user on the system can import this repository because all object names must be globally unique. If you get an error that the objects already exist when you try to import, search the system for classes named `ZCL_DEMO_ABAP*`. Someone has already imported the content into the system and you can simply check out that imported version. - Since the repository contains self-contained examples, i.e. some of them work with demo database tables included in the repository (note that these tables are populated during method executions), all demo artifacts must be imported for all examples to work. - When importing into an on-premise system, note the following: The demos cover ABAP syntax regardless of the ABAP release to avoid scattering information and to get the information in one go. Therefore, there may be syntax that is not yet available in the ABAP version of your on-premise system. In this case, you may want to comment out the affected code sections and/or ignore the affected artifacts if an activation fails. Note that the RAP examples in particular require at least ABAP version 7.56. -- Regarding possible code check warnings, e.g. for the many strings in the code, not using an `ORDER BY` clause, or messages regarding using `SELECT *`, the code deliberately avoids pragmas and pseudo comments in order to keep the code simple and to focus on the available ABAP syntax. See also the [Disclaimer](#%EF%B8%8F-disclaimer). +- Regarding possible code check warnings, e.g. for the many strings in the code, not using an `ORDER BY` clause, or messages regarding using `SELECT *`, the code deliberately avoids [pragmas](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenpragma_glosry.htm) and [pseudo comments](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenpseudo_comment_glosry.htm) in order to focus on the available ABAP syntax. See also the [Disclaimer](#%EF%B8%8F-disclaimer).
diff --git a/src/zcl_demo_abap_cds_ve.clas.abap b/src/zcl_demo_abap_cds_ve.clas.abap index b24baa0..8e48a8d 100644 --- a/src/zcl_demo_abap_cds_ve.clas.abap +++ b/src/zcl_demo_abap_cds_ve.clas.abap @@ -159,9 +159,6 @@ CLASS zcl_demo_abap_cds_ve IMPLEMENTATION. output->next_section( `4) Excursion: ABAP SQL and joins` ). - "The following ABAP SQL SELECT statements uses a CDS view entity as - "the data source. The sample CDS view entity contains multiple - "joins. "The following ABAP SQL SELECT statements are intended to reproduce "the different joins that are performed by the CDS view entity. "Inner, left and right outer, and cross joins are covered. The data @@ -170,8 +167,8 @@ CLASS zcl_demo_abap_cds_ve IMPLEMENTATION. "- The prefix ~ is used in the ABAP SQL statements instead of . in " the CDS view entity. "- To demonstrate the handling of null values, some SELECT statements - "contain the coalesce function and CASE expressions similar to the - "CDS view entity. + " contain the coalesce function and CASE expressions similar to the + " CDS view entity. output->display( `----- Inner join -----` ). @@ -299,6 +296,7 @@ CLASS zcl_demo_abap_cds_ve IMPLEMENTATION. " is used in the SELECT list of an ABAP SQL SELECT statement (where " fields are specified), a LEFT OUTER JOIN is used by default. "- The coalesce function is included for a field to handle null values. + SELECT carrier, \_carr3-carrname, coalesce( \_carr3-url, '###' ) AS cityto_lo @@ -388,12 +386,12 @@ CLASS zcl_demo_abap_cds_ve IMPLEMENTATION. "Without specifying the cardinality, the following warning "occurs: Using association "_FLI" can increase the cardinality "of the results set - "\_fli-fldate + "\_fli-fldate AS flightdate \_fli[ (*) ]-fldate AS flightdate "The specification above corresponds to the following specification "that includes an explicit specification of LEFT OUTER - "\_fli[ (*) LEFT OUTER ]-fldate + "\_fli[ (*) LEFT OUTER ]-fldate AS flightdate FROM zdemo_abap_cds_ve_assoc_e ORDER BY carrid, connid, flightdate INTO TABLE @DATA(assoc_attr_card). diff --git a/src/zdemo_abap_cds_ve_assoc.ddls.asddls b/src/zdemo_abap_cds_ve_assoc.ddls.asddls index e119644..b09ce4d 100644 --- a/src/zdemo_abap_cds_ve_assoc.ddls.asddls +++ b/src/zdemo_abap_cds_ve_assoc.ddls.asddls @@ -28,8 +28,8 @@ define view entity zdemo_abap_cds_ve_assoc // 1) One use case of assocations, which is not covered here, can be the use in the FROM clause. // - That is, you can use an association as data source by specifying a path expression. // - For example, the CDS view entity zdemo_abap_cds_ve_assoc_e exposes an association - // _carr_exp1. Therefore, a FROM clause as follows is possible: - // ... as select from zdemo_abap_cds_ve_assoc_e._carr_exp1 as _flsch ... + // _carr_exp. Therefore, a FROM clause as follows is possible: + // ... as select from zdemo_abap_cds_ve_assoc_e._carr_exp as _flsch ... // 2) Adding fields of an association target to the element list (of the same CDS view entity) // - In this case, since data is requested, a join is carried out. @@ -141,4 +141,4 @@ define view entity zdemo_abap_cds_ve_assoc // - Maximum values greater than 1 can lead to syntax errors or warnings. Generally, a non-matching cardinality // usually produces a warning. // - If the cardinality is not specified, it is to one by default [x..1]. -// - Compositions and to-parent associations are special kinds of CDS associations. They are not covered in the example. +// - Compositions and to-parent associations are special kinds of CDS associations. See the ABAP Keyword Documentation. diff --git a/src/zdemo_abap_cds_ve_joins.ddls.asddls b/src/zdemo_abap_cds_ve_joins.ddls.asddls index 4bf94f5..7129317 100644 --- a/src/zdemo_abap_cds_ve_joins.ddls.asddls +++ b/src/zdemo_abap_cds_ve_joins.ddls.asddls @@ -14,7 +14,7 @@ // respective code sections (select the lines and choose CTRL + 7). // - The example for inner joins is commented in by default. The relevant // code sections are marked with "COMMENT IN/OUT ... START" and -// "COMMENT IN/OUT ... START" in both SELECT and element list +// "COMMENT IN/OUT ... END" in both SELECT and element list // (inner joins -> 1a / 1b). To test the left outer joins, for example, // comment out the respective sections of the inner join and comment in // the sections for left outer joins (2a, 2b), and so on. diff --git a/src/zdemo_abap_cds_ve_sel.ddls.asddls b/src/zdemo_abap_cds_ve_sel.ddls.asddls index b95a0f7..fd28f11 100644 --- a/src/zdemo_abap_cds_ve_sel.ddls.asddls +++ b/src/zdemo_abap_cds_ve_sel.ddls.asddls @@ -28,7 +28,7 @@ @AccessControl.authorizationCheck: #NOT_REQUIRED // Example for an entity annotation (annotations that can be used in all CDS entities) -// The following annotation provdes a translatable short text of the CDS entity. +// The following annotation provides a translatable short text of the CDS entity. @EndUserText.label: 'CDS view entity: Operands/Expressions' define view entity zdemo_abap_cds_ve_sel with parameters @@ -107,8 +107,6 @@ define view entity zdemo_abap_cds_ve_sel // The following example uses the prefix $projection. which defines reuse expressions. // That is, you can refer to an element defined previously in the SELECT list of the same CDS view entity. // Note that this is only possible in dedicated positions. One of them is a cast expression. - //cast( $projection.date_lit as abap.int4 ) as cast_dats, - //cast( $projection.curr as abap.int4 ) as cast_curr, cast( $projection.date_lit as abap.char(8) ) as cast_dats2c, // -------- Arithmetic expressions --------