diff --git a/04_ABAP_Object_Orientation.md b/04_ABAP_Object_Orientation.md index a97977a..1f556d8 100644 --- a/04_ABAP_Object_Orientation.md +++ b/04_ABAP_Object_Orientation.md @@ -86,7 +86,7 @@ classes > **💡 Note**
> - If a class is only used in one ABAP program, creating a local class is enough. However, if you choose to create a global class, you must bear in mind that such a class can be used everywhere. Consider the impact on the users of the global class when you change, for example, the visibility section of a component or you delete it. -> - Apart from ADT, global classes can also be created in the ABAP Workbench (`SE80`) or with transaction `SE24` in on-premise systems. +> - Apart from ADT, global classes can also be created in the ABAP Workbench (`SE80`) or with transaction `SE24` in [classic ABAP](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenclassic_abap_glosry.htm). Basic structure of classes: - [Declaration part](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abendeclaration_part_glosry.htm "Glossary Entry") that includes declarations of the class components. @@ -409,9 +409,9 @@ CLASS local_class DEFINITION. constructor IMPORTING j TYPE i. "instance constructor with importing parameter - CLASS-METHODS: stat_meth1, + CLASS-METHODS: stat_meth1, "static methods - stat_meth2 IMPORTING k TYPE i "static methods + stat_meth2 IMPORTING k TYPE i EXPORTING l TYPE i, class_constructor, "static constructor diff --git a/06_Dynamic_Programming.md b/06_Dynamic_Programming.md index f0bb556..fbcb4b7 100644 --- a/06_Dynamic_Programming.md +++ b/06_Dynamic_Programming.md @@ -290,7 +290,7 @@ DATA(ref3) = REF some_type( ... ). [Anonymous data objects](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenanonymous_data_object_glosry.htm "Glossary Entry") ... - are dynamically created at runtime. - are relevant if the data type is only known when the program is executed. -- cannot be addressed by a name (-> "anonymous"). +- cannot be addressed by a name ("anonymous"). - expect a data reference variable when declared. The content of an anonymous data object can only be accessed using dereferenced variables as shown below or field symbols. - can be created using the statement [`CREATE DATA`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapcreate_data.htm), the instance operator [`NEW`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenconstructor_expression_new.htm), or the addition [`NEW`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapselect_into_target.htm) of the `INTO` clause in a `SELECT` statement. @@ -361,7 +361,7 @@ DATA(dref_6) = NEW zdemo_abap_carr( carrid = 'AB' "ABAP SQL SELECT statements "Using the NEW addition in the INTO clause, an anonymous data -"object with a suitable type can be created in place. +"object can be created in place. SELECT * FROM zdemo_abap_carr INTO TABLE NEW @DATA(dref_7). "internal table diff --git a/10_ABAP_SQL_Hierarchies.md b/10_ABAP_SQL_Hierarchies.md index 59c3d09..94bded9 100644 --- a/10_ABAP_SQL_Hierarchies.md +++ b/10_ABAP_SQL_Hierarchies.md @@ -46,7 +46,7 @@ offers a lot of helpful features. Among other things, you will find a set of hierarchy functions there that allow you to deal with hierarchical data directly on the database and that you can look up in the [SAP HANA -documentation](https://help.sap.com/http.svc/ahp2/DRAFT/SAP_S4HANA_ON-PREMISE/2022.000/EN/20/ff532c751910148657c32fe3431a9/frameset.htm). +documentation](https://help.sap.com/docs/SAP_HANA_PLATFORM/4fe29514fd584807ac9f2a04f6754767/2969da89b87f4abd85fd0b5f9f5bc395.html?version=2.0.06&locale=en-US). Now you might expect that you must use [AMDP](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenamdp.htm) in order to access these functions from your ABAP programs, but no need @@ -57,7 +57,7 @@ modern features. All you have to do, is to understand some concepts and learn some additional syntax and then you can start right away. > **💡 Note**
-> The examples in this cheat sheet are only relevant for [standard ABAP](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenstandard_abap_glosry.htm), i. e. the unrestricted ABAP language scope. Find the artifacts used in the code snippets in your on-premise system. +> The examples in this cheat sheet are only relevant for [standard ABAP](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenstandard_abap_glosry.htm), i. e. the unrestricted ABAP language scope. Find the artifacts used in the code snippets in your on-premise ABAP system.

âŦ†ī¸ back to top

diff --git a/12_AMDP.md b/12_AMDP.md index 6e75800..2f6e6f6 100644 --- a/12_AMDP.md +++ b/12_AMDP.md @@ -408,7 +408,7 @@ AMDP methods ... As mentioned above and hinted in the bullet points above, AMDP has more options regarding the unrestricted language version. Check the subtopics [here](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenamdp.htm). -A fundamental question in on-premise ABAP systems with an unrestricted +A fundamental question in [classic ABAP](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenclassic_abap_glosry.htm) with an unrestricted language scope can be whether AMDP is supported at all. The constant `CALL_AMDP_METHOD` of the class `CL_ABAP_DBFEATURES` can be used to query diff --git a/16_Data_Types_and_Objects.md b/16_Data_Types_and_Objects.md index 5b0854e..f9a4bea 100644 --- a/16_Data_Types_and_Objects.md +++ b/16_Data_Types_and_Objects.md @@ -864,8 +864,7 @@ DATA dref_13_ddic_tab TYPE REF TO zdemo_abap_carr. dref_13_ddic_tab = NEW #( carrid = 'AB' carrname = 'AB Airlines' ). "ABAP SQL SELECT statement -"Using the NEW addition in the INTO clause, an anonymous data object with -"suitable type can be created in place. +"Using the NEW addition in the INTO clause, an anonymous data object can be created in place. SELECT * FROM zdemo_abap_carr INTO TABLE NEW @DATA(dref_14_inline). diff --git a/17_SAP_LUW.md b/17_SAP_LUW.md index 544ee51..48e5f76 100644 --- a/17_SAP_LUW.md +++ b/17_SAP_LUW.md @@ -14,7 +14,7 @@ ## Introduction -âš ī¸ The concept is relevant to both ABAP Cloud and classic ABAP, but some of the statements covered in the cheat sheet and executable example are only relevant to [classic ABAP](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenclassic_abap_glosry.htm). +âš ī¸ The concept is relevant to both ABAP Cloud and classic ABAP, but some of the statements covered in the cheat sheet and the executable example are only relevant to [classic ABAP](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenclassic_abap_glosry.htm). This cheat sheet 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, supported by an executable example to check the syntax in action. @@ -185,8 +185,10 @@ The following bundling techniques are available for classic ABAP. This means tha ... - "The update will be synchronous. + "The update will be synchronous no matter if you use the COMMIT WORK + "statement with or without the addition AND WAIT. COMMIT WORK. + "COMMIT WORK AND WAIT. ``` > **💡 Note**
@@ -199,6 +201,7 @@ The following bundling techniques are available for classic ABAP. This means tha - More information: - [SAP Help Portal documentation about RFC](https://help.sap.com/docs/ABAP_PLATFORM_NEW/753088fc00704d0a80e7fbd6803c8adb/4888068AD9134076E10000000A42189D) - [`CALL FUNCTION ... IN BACKGROUND UNIT`](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abapcall_function_background_unit.htm) + - Note the [background processing framework (bgPF)](https://help.sap.com/docs/abap-cloud/abap-concepts/background-processing-framework) as a successor technology **Using [subroutines](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abensubroutine_glosry.htm)** - Subroutines that are no longer recommended for use can be registered for later execution. @@ -269,7 +272,7 @@ The following concepts are related to the SAP LUW to ensure transactional consis - At the end of an SAP LUW, all locks should be released, either automatically during the database update or explicitly when you call the corresponding dequeue function module. - More information: - [SAP Locks](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abensap_lock.htm) - - Also note the information on the [`CL_ABAP_LOCK_OBJECT_FACTORY`](https://help.sap.com/docs/sap-btp-abap-environment/abap-environment/lock-objects) class + - Note the information on the `CL_ABAP_LOCK_OBJECT_FACTORY` class that is related to this context [here](https://help.sap.com/docs/sap-btp-abap-environment/abap-environment/lock-objects). > **💡 Note**
> RAP comes with its own implementation features to cover these concepts. See the topics [Authorization Control](https://help.sap.com/docs/SAP_S4HANA_CLOUD/e5522a8a7b174979913c99268bc03f1a/375a8124b22948688ac1c55297868d06.html) and [Concurrency Control](https://help.sap.com/docs/SAP_S4HANA_CLOUD/e5522a8a7b174979913c99268bc03f1a/d315c13677d94a6891beb3418e3e02ed.html) in the *Development guide for the ABAP RESTful Application Programming Model*. @@ -287,17 +290,22 @@ And RAP comes with a well-defined transactional model and follows the rules of t There are RAP-specific [ABAP EML](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap_eml_glosry.htm) statements for commit and rollback: - [`COMMIT ENTITIES`](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abapcommit_entities.htm) implicitly triggers `COMMIT WORK`. Furthermore, `COMMIT ENTITIES` provides RAP-specific functionality with various additions. These EML statements implicitly enforce local updates with `COMMIT WORK`, or `COMMIT WORK AND WAIT` if the local update fails. Therefore, the update is either a local update or a synchronous update, but never an asynchronous update. - [`ROLLBACK ENTITIES`](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abaprollback_entities.htm): Resets all changes of the current transaction and clears the transactional buffer. The statement triggers `ROLLBACK WORK`. +- Find more information in the [ABAP cheat sheet about EML](08_EML_ABAP_for_RAP.md). ## More Information - [The RAP Transactional Model and the SAP LUW](https://help.sap.com/docs/SAP_S4HANA_CLOUD/e5522a8a7b174979913c99268bc03f1a/ccda1094b0f845e28b88f9f50a68dfc4.html) (Development guide for the ABAP RESTful Application Programming Model) - [The SAP LUW in ABAP Cloud](https://blogs.sap.com/2022/12/05/the-sap-luw-in-abap-cloud/) (blog) - [SAP LUW in the ABAP Keyword Documentation](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensap_luw.htm) +- [Controlled SAP LUW](https://help.sap.com/docs/abap-cloud/abap-concepts/controlled-sap-luw) as an enhancement of the SAP LUW concept

âŦ†ī¸ back to top

## Executable Example -After importing, find the program in ADT using search: Press `CTRL+SHIFT+A` and enter `zdemo_abap_sap_luw`. Open the program and run it by pressing `F8`. +After the import of the repository, proceed as follows: +- Find the program in ADT using the search by choosing `CTRL + SHIFT + A`. +- Enter `zdemo_abap_sap_luw` and open the program. +- Run the program by choosing `F8`. > **💡 Note**
> - The steps about how to import and run the code are outlined [here](README.md#-getting-started-with-the-examples). diff --git a/18_Dynpro.md b/18_Dynpro.md index 13c4179..e0ee502 100644 --- a/18_Dynpro.md +++ b/18_Dynpro.md @@ -85,7 +85,7 @@ This cheat sheet provides a high-level overview of classic dynpro topics with a - Dialog modules can be called at the PBO event. They are mainly used to prepare the dynpro display, for example, by pre-populating input/output fields. - When the dynpro is presented to the user, and the user has made entries and wants to leave the dynpro, the PAI event is triggered, for example, when a button is clicked. - - `PROCESS AFTER INPUT` (PAI), + - `PROCESS AFTER INPUT` (PAI): - Processed after a user action on the dynpro - The dialog modules called at PAI evaluate the user entries and process them. - When the processing is complete, the processing of the current dynpro ends and the next dynpro is called. @@ -718,7 +718,10 @@ PROCESS AFTER INPUT. ## Executable Example -After importing, find the program in ADT using the search: Choose `CTRL + SHIFT + A` and enter `zdemo_abap_dynpro`. Open the program and run it by choosing `F8`. +After the import of the repository, proceed as follows: +- Find the program in ADT using the search by choosing `CTRL + SHIFT + A`. +- Enter `zdemo_abap_dynpro` and open the program. +- Run the program by choosing `F8`. > **💡 Note**
> - The steps about how to import and run the code are outlined [here](README.md#-getting-started-with-the-examples). diff --git a/19_ABAP_for_Cloud_Development.md b/19_ABAP_for_Cloud_Development.md index e488700..8ff5c0b 100644 --- a/19_ABAP_for_Cloud_Development.md +++ b/19_ABAP_for_Cloud_Development.md @@ -45,11 +45,11 @@ It provides references to more detailed information on the topic. 1) If available to you, you have accessed an SAP BTP ABAP environment using ADT. - Access to SAP-provided repository objects is restricted to objects that have been released for ABAP for Cloud Development (released APIs). You can find the released APIs in the *Project Explorer* view in ADT under *Released Objects*: + Access to SAP-provided repository objects is restricted to objects that have been released for ABAP for Cloud Development (released APIs). You can find the released repository objects in the *Project Explorer* view in ADT under *Released Objects*: ![Released APIs](./files/released_APIs.png) - As an example of a released API, consider the `CL_ABAP_RANDOM_INT` class (computes random integers). In ADT, once you have opened the class, check the *Properties* tab. Click *API State* on the left to display information about the release contracts. In this case, it is C1. As mentioned above, see [here](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabap_versions_and_apis.htm#@@ITOC@@ABENABAP_VERSIONS_AND_APIS_2) for more information on C1, and so on. This is also true for ABAP repository objects in on-premise systems. + As an example of a released API, consider the `CL_ABAP_RANDOM_INT` class (computes random integers). In ADT, once you have opened the class, check the *Properties* tab. Click *API State* on the left to display information about the release contracts. In this case, it is C1. As mentioned above, see [here](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabap_versions_and_apis.htm#@@ITOC@@ABENABAP_VERSIONS_AND_APIS_2) for more information on C1, and so on. This is also true for ABAP repository objects in classic ABAP. ![Release contract](./files/release_contract.png) @@ -59,9 +59,9 @@ It provides references to more detailed information on the topic. > **💡 Note**
> - The `IF_OO_ADT_CLASSRUN` interface is a released API. As the name implies, you can implement this interface to run an ABAP class. In ADT you can do this with *F9*. Of course, the example below will not run. The class cannot be activated because of the syntax errors. Note: To output the content of data objects, you can use `out->write( ... ).` in the `main` method. > - About the errros/warnings: - > - The first two ABAP SQL statements select from demo database tables. The first is a demo table provided by SAP. This table is not directly accessible in ABAP Cloud (unlike in on-premise systems) and therefore cannot be used as a data source to select from. The second one is a database table from the ABAP cheat sheet GitHub repository. If you have imported the repository into the system, you can use it as a data source. + > - The first two ABAP SQL statements select from demo database tables. The first is a demo table provided by SAP. This table is not directly accessible in ABAP Cloud (unlike in classic ABAP) and therefore cannot be used as a data source to select from. The second one is a database table from the ABAP cheat sheet GitHub repository. If you have imported the repository into the system, you can use it as a data source. > - The next set of ABAP SQL statements are dynamic statements. This is just to emphasize that you should be careful with dynamic statements. You will not get a syntax error at compile time. You can try out the following: Comment out all code except the lines with the dynamic statements, activate the code and run the class with `F9`. The result is a [runtime error](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenruntime_error_glosry.htm) because you cannot select from the data source. - > - The examples for deprecated and invalid syntax in ABAP for Cloud Development include the invalid statement `MOVE ... TO` and others. To set breakpoints in ADT, double-click the area to the left of the code line number. + > - Examples for deprecated and invalid syntax in ABAP for Cloud Development are included. Among them, the invalid statement `MOVE ... TO` and others which are just included for demonstration purposes. To set breakpoints in ADT, double-click the area to the left of the code line number. ```abap CLASS zcl_demo_abap_temp DEFINITION @@ -84,12 +84,12 @@ It provides references to more detailed information on the topic. SELECT carrid, connid FROM zdemo_abap_fli WHERE carrid = 'LH' INTO TABLE @DATA(it2). "Dynamic ABAP SQL statements - "In ABAP Cloud, no syntax error will be displayed. However, a runtime error - "will occur when running the class. + "No syntax error will be displayed for the dynamic statements. + "However, a runtime error will occur when running the class (in ABAP Cloud). "Note: Check out the CL_ABAP_DYN_PRG class, which supports dynamic programming "by checking the validity of dynamic specifications. SELECT SINGLE carrid, connid FROM ('SPFLI') WHERE carrid = 'LH' INTO NEW @DATA(ref_a). - "No runtime error if you have imported the ABAP cheat sheet repository objects + "No runtime error if you have imported the ABAP cheat sheet repository objects. SELECT SINGLE carrid, connid FROM ('ZDEMO_ABAP_FLI') WHERE carrid = 'LH' INTO NEW @DATA(ref_b). "Examples for deprecated and invalid syntax in ABAP for Cloud Development @@ -133,20 +133,20 @@ It provides references to more detailed information on the topic. - Create a global class and insert the code from above. Depending on the name of the class you created, replace the class name in the snippet. - If you have not imported the ABAP cheat sheet GitHub repository, remove the lines of code using artifacts from that repository, i.e. change the `SELECT` and `READ REPORT` statemnets. You should not see any syntax errors. Activate the class. - Run the class with *F9*. The code should have been processed up to the `BREAK-POINT` statement and the debugger should have started. You may want to check the content of the variables in the debugger. Choose *Terminate* to exit the debugger. - - So, unlike in the case of ABAP Cloud above, the code should work without restrictions. + - So, unlike in the case of ABAP Cloud above, the code should not cause any problems (other than the fact that it does not make a lot of sense). - For the example class created, check the information in the *Properties* tab. Choose *General*. The *ABAP Language Version* is maintained as *Standard ABAP*: ![Standard ABAP](./files/standard.png) - c) Verify that your code in an on-premise ABAP system is cloud-ready + c) Verify that your code in classic ABAP is cloud-ready - You have walked through b), created a class, inserted the code from above, and activated the class. The *ABAP Language Version* is maintained as *Standard ABAP* in the *Properties* tab. - Verifying if your code is cloud-ready - You can use ATC check variant `ABAP_CLOUD_READINESS` for this purpose. - For example, in your class, right-click and choose *Run As* → *4 ABAP Test Cockpit With...*. Enter `ABAP_CLOUD_READINESS` in the pop-up window and choose *Ok*. The ATC check run is started. - As a result of the ATC check run (note that it may take a while to complete), the *ATC Problems* tab in ADT should display results. In this case, these are the errors and warnings mentioned above, indicating that the code is not cloud-ready in various places. Double-click on the findings for more detailed information. - d) Develop in an on-premise ABAP system in a cloud-ready manner + d) Develop in clasic ABAP in a cloud-ready manner - You have walked through b), created a class, inserted the code from above, and activated the class. The *ABAP Language Version* is maintained as *Standard ABAP* in the *Properties* tab under *General*. - - Suppose you want to develop in a cloud-ready way and use ABAP for Cloud Development, i.e. the restricted ABAP language version, in an on-premise ABAP system that allows the unrestricted ABAP language version. + - Suppose you want to develop in a cloud-ready manner and use ABAP for Cloud Development, i.e. the restricted ABAP language version, in classic ABAP (e.g. an on-premise ABAP system that allows the unrestricted ABAP language version). - Open the *Properties* tab and choose *General* for this purpose. - Choose the *Edit...* button to the right of the *ABAP Language Version* property. - Select *ABAP for Cloud Development* in the pop-up window and choose *Ok*. diff --git a/README.md b/README.md index 0797ea1..ab5ed5e 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ ABAP cheat sheets[^1] ... - provide a **collection of information on selected ABAP topics** in a nutshell for your reference. - focus on **ABAP syntax**. - include **code snippets**. -- are supported by easy-to-consume **demonstration examples** that you can import into your [SAP BTP ABAP environment](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensap_btp_abap_env_glosry.htm) (*main* branch) or on-premise ABAP system (other branches) using [abapGit](https://abapgit.org/) to run and check out ABAP syntax in action in simple contexts. +- are supported by easy-to-consume **demonstration examples** that you can import into your [SAP BTP ABAP environment](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensap_btp_abap_env_glosry.htm) (*main* branch) or [classic ABAP](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenclassic_abap_glosry.htm) (on-premise ABAP system) (other branches) using [abapGit](https://abapgit.org/) to run and check out ABAP syntax in action in simple contexts. - are enriched by links to glossary entries and chapters of the **ABAP Keyword Documentation** (the *F1 help*) for you to deep dive into the respective ABAP topics and get more comprehensive information.
@@ -75,8 +75,8 @@ ABAP cheat sheets[^1] ... |[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)| |[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)| -|[SAP LUW](17_SAP_LUW.md)|Provides a high-level overview on 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
💡 The content of the cheat sheet is mostly 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
💡 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`| +|[SAP LUW](17_SAP_LUW.md)|Provides a high-level overview on 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
💡 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
💡 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`|
@@ -138,7 +138,7 @@ https://github.com/SAP-samples/abap-cheat-sheets.git
- 2b) Application Server ABAP On-Premise + 2b) Classic ABAP (on-premise ABAP systems)
**Prerequisites** @@ -203,18 +203,18 @@ Use the standalone version of the abapGit report to import the demo examples of ## ⚡ Known Issues - Only one user on the system can import this repository because all object names must be globally unique. Before importing the code, you should perform a system-wide search for classes named *ZCL_DEMO_ABAP**, for example. If someone has already imported the content into the system, you can simply check out that imported code. - 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). -- Regarding the examples to be imported into on-premise systems, note the following: The cheat sheet documents cover ABAP syntax regardless of the ABAP release to avoid scattering information and to have the information in one place. Therefore, the lower the release, the fewer syntax options and examples are available. For example, the RAP examples in particular require at least ABAP version 7.56. +- Regarding the examples to be imported into on-premise ABAP systems, note the following: The cheat sheet documents cover ABAP syntax regardless of the ABAP release to avoid scattering information and to have the information in one place. Therefore, the lower the release, the fewer syntax options and examples are available. For example, the RAP examples in particular require at least ABAP version 7.56.
## â„šī¸ More Information -- For the system-internal version of the ABAP Keyword Documentation in your - - ... **on-premise system**: 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. - - ... **SAP BTP ABAP environment**: 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. +- 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. - Links to the online version of the ABAP Keyword Documentation for: - - **Standard ABAP**: Unrestricted ABAP language scope 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). To access the online documentation for a specific ABAP version, e.g. 7.54, you can select the version from the drop-down list [here](https://help.sap.com/docs/ABAP?locale=en-US) (*latest* is preselected). The *ABAP* link under *Development* will take you to the documentation of choice. + - **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). To access the online documentation for a specific ABAP version, e.g. 7.54, you can select the version from the drop-down list [here](https://help.sap.com/docs/ABAP?locale=en-US) (*latest* is preselected). The *ABAP* link under *Development* will take you to the documentation of choice. - **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) -- Regarding demonstration examples of the ABAP Keyword Documentation in your on-premise system: Have you ever checked out the package `SABAPDEMOS`? This package contains all the examples used in the ABAP Keyword Documentation. To get the context, program names, etc., see the [example page](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap_examples.htm) (also available in the system-internal SAP GUI version as a node in the topic tree), which summarizes the executable examples. Of course, you can also find the example topics in the context of the individual ABAP Keyword Documentation topic. The example topics are marked with a âš™ī¸ icon: +- Regarding demonstration examples of the ABAP Keyword Documentation in classic ABAP: Have you ever checked out the package `SABAPDEMOS`? This package contains all the examples used in the ABAP Keyword Documentation. To get the context, program names, etc., see the [example page](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenabap_examples.htm) (also available in the system-internal SAP GUI version as a node in the topic tree), which summarizes the executable examples. Of course, you can also find the example topics in the context of the individual ABAP Keyword Documentation topic. The example topics are marked with a âš™ī¸ icon: ![](./files/example_topics.png) diff --git a/src/zcl_demo_abap_amdp.clas.abap b/src/zcl_demo_abap_amdp.clas.abap index 58d4ea3..1d5770e 100644 --- a/src/zcl_demo_abap_amdp.clas.abap +++ b/src/zcl_demo_abap_amdp.clas.abap @@ -15,7 +15,7 @@ * environment. For example, in SAP BTP ABAP environment only * read-only operations are possible. In general, there are more * syntax options available in the unrestricted ABAP language scope -* in on-premise ABAP systems. Check the ABAP Keyword Documentation +* in classic ABAP. Check the ABAP Keyword Documentation * for more details and examples. * * ----------------------- GETTING STARTED ----------------------------- diff --git a/src/zcl_demo_abap_cloud_excursion.clas.abap b/src/zcl_demo_abap_cloud_excursion.clas.abap index a3935f0..0af7bc4 100644 --- a/src/zcl_demo_abap_cloud_excursion.clas.abap +++ b/src/zcl_demo_abap_cloud_excursion.clas.abap @@ -94,8 +94,8 @@ CLASS zcl_demo_abap_cloud_excursion IMPLEMENTATION. "displayed. "Notes about the errors/warnings: "- Using ABAP SQL statements, data is retrieved from database tables. The first table - " is a demo table provided by SAP. This table cannot be accessed directly (unlike in on-premise - " systems) and therefore cannot be used as a data source from which to select. The second + " is a demo table provided by SAP. This table cannot be accessed directly (unlike in classic + " ABAP) and therefore cannot be used as a data source from which to select. The second " is a database table from the ABAP Cheat Sheet GitHub repository. If you have imported " the repository into the system, you can use it as a data source. "- The example includes dynamic ABAP SQL statements. This is just to emphasize that such @@ -984,12 +984,11 @@ CLASS zcl_demo_abap_cloud_excursion IMPLEMENTATION. "3) You have provided suitable names for the demo objects. Check and, if need be, " change the constant values for gen_dtel, gen_doma, gen_tabl. " - "4) To "enable" the generation, assign the constant "generation_ok" the value + "4) To enable the generation, assign the constant "generation_ok" the value " "abap_true". " "The generation of the objects is only carried out if all of the mentioned - "prerequisites are met. Find more code snippets about repository object - "generation in the SAP Help Portal documentation. + "prerequisites are met. "Checking validity of the specified transport request ID TRY. diff --git a/src/zcl_demo_abap_dtype_dobj.clas.abap b/src/zcl_demo_abap_dtype_dobj.clas.abap index 7062054..3534da1 100644 --- a/src/zcl_demo_abap_dtype_dobj.clas.abap +++ b/src/zcl_demo_abap_dtype_dobj.clas.abap @@ -1085,7 +1085,7 @@ CLASS ZCL_DEMO_ABAP_DTYPE_DOBJ IMPLEMENTATION. "ABAP SQL SELECT statement "As shown above, using the NEW addition in the INTO clause, an anonymous data - "object with suitable type can be created in place. + "object can be created in place. SELECT * FROM zdemo_abap_carr INTO TABLE NEW @DATA(dref_14_inline). diff --git a/src/zcl_demo_abap_dynamic_prog.clas.abap b/src/zcl_demo_abap_dynamic_prog.clas.abap index dbac8b3..1d7d322 100644 --- a/src/zcl_demo_abap_dynamic_prog.clas.abap +++ b/src/zcl_demo_abap_dynamic_prog.clas.abap @@ -601,8 +601,8 @@ CLASS zcl_demo_abap_dynamic_prog IMPLEMENTATION. DATA(dref_c6) = NEW zdemo_abap_carr( carrid = 'AB' carrname = 'AB Airlines' ). "ABAP SQL SELECT statements - "Using the NEW addition in the INTO clause, an anonymous data object with - "suitable type can be created in place. + "Using the NEW addition in the INTO clause, an anonymous data object + "can be created in place. SELECT * FROM zdemo_abap_carr INTO TABLE NEW @DATA(dref_c7) "Internal table diff --git a/src/zcl_demo_abap_internal_tables.clas.abap b/src/zcl_demo_abap_internal_tables.clas.abap index babc887..ef822c7 100644 --- a/src/zcl_demo_abap_internal_tables.clas.abap +++ b/src/zcl_demo_abap_internal_tables.clas.abap @@ -1,6 +1,6 @@ *********************************************************************** * -* ABAP cheat sheet: Internal tables +* ABAP cheat sheet: Internal tables * * -------------------------- PURPOSE ---------------------------------- * - Example to demonstrate various syntactical options for working with @@ -45,12 +45,9 @@ CLASS zcl_demo_abap_internal_tables DEFINITION PUBLIC SECTION. INTERFACES: if_oo_adt_classrun. - CLASS-METHODS: class_constructor. -protected section. PRIVATE SECTION. - "Creating structured data types. TYPES: "Line types for internal tables BEGIN OF struc1, @@ -107,81 +104,9 @@ protected section. CLASS-METHODS: fill_dbtabs, fill_itabs_for_corresponding. - ENDCLASS. - - -CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. - - - METHOD class_constructor. - fill_dbtabs( ). - ENDMETHOD. - - - METHOD fill_dbtabs. - "Initializing and filling of database tables to have data to work with - - DELETE FROM zdemo_abap_tab1. - DELETE FROM zdemo_abap_tab2. - - MODIFY zdemo_abap_tab1 FROM TABLE @( VALUE #( - ( key_field = 100 char1 = 'aaa' char2 = 'bbb' num1 = 1 num2 = 2 ) - ( key_field = 200 char1 = 'ccc' char2 = 'ddd' num1 = 3 num2 = 4 ) - ( key_field = 300 char1 = 'eee' char2 = 'fff' num1 = 5 num2 = 6 ) - ( key_field = 400 char1 = 'ggg' char2 = 'hhh' num1 = 7 num2 = 8 ) - ) ). - MODIFY zdemo_abap_tab2 FROM TABLE @( VALUE #( - ( key_field = 500 char1 = 'iii' num1 = 10 numlong = 1000 ) - ( key_field = 600 char1 = 'kkk' num1 = 12 numlong = 2000 ) - ( key_field = 700 char1 = 'mmm' num1 = 14 numlong = 3000 ) - ( key_field = 800 char1 = 'ooo' num1 = 15 numlong = 4000 ) - ) ). - - ENDMETHOD. - - - METHOD fill_itabs_for_corresponding. - tab1 = VALUE #( ( a = 1 b = 'aaa' c = 'aaa' d = 'A' ) - ( a = 2 b = 'bbb' c = 'bbb' d = 'B' ) ). - - tab2 = VALUE #( ( a = 3 b = 'ccc' e = 'ccc' f = `CCC` ) - ( a = 4 b = 'ddd' e = 'ddd' f = `DDD` ) ). - - tab3 = VALUE #( ( LINES OF tab1 ) ). - - tab4 = VALUE #( ( a = 1 b = 'xxx' e = 'yyy' f = `ZZZ` ) - ( LINES OF tab2 ) ). - - itab_nested1 = VALUE #( - ( key_field = 1 char1 = 'aaa' - tab = VALUE #( ( key_field = 1 num1 = 2 num2 = 3 ) - ( key_field = 2 num1 = 3 num2 = 4 ) - ( key_field = 3 num1 = 4 num2 = 5 ) ) ) - ( key_field = 2 char1 = 'bbb' - tab = VALUE #( ( key_field = 4 num1 = 5 num2 = 6 ) - ( key_field = 5 num1 = 6 num2 = 7 ) - ( key_field = 6 num1 = 7 num2 = 8 ) ) ) ). - - itab_nested2 = VALUE #( - ( key_field = 99 char2 = 'yyy' tab = VALUE #( - ( key_field = 10 char1 = 'aaa' - char2 = 'bbb' num1 = 100 num2 = 200 ) - ( key_field = 20 char1 = 'ccc' - char2 = 'ddd' num1 = 300 num2 = 400 ) - ( key_field = 30 char1 = 'eee' - char2 = 'fff' num1 = 500 num2 = 600 ) ) ) - ( key_field = 100 char2 = 'zzz' tab = VALUE #( - ( key_field = 40 char1 = 'ggg' - char2 = 'hhh' num1 = 700 num2 = 800 ) - ( key_field = 50 char1 = 'iii' - char2 = 'jjj' num1 = 900 num2 = 1000 ) - ( key_field = 60 char1 = 'kkk' - char2 = 'lll' num1 = 1100 num2 = 1200 ) ) ) ). - - ENDMETHOD. - +CLASS zcl_demo_abap_internal_tables IMPLEMENTATION. METHOD if_oo_adt_classrun~main. @@ -235,7 +160,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** output->next_section( `3) Adding mutliple lines of an internal table to` && - ` another one` ). + ` another one` ). "No additions: All lines are added to the target internal table APPEND LINES OF it_so TO it_st. @@ -256,7 +181,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** output->next_section( `4) Adding lines of an internal table to` && - ` another one by specifying the index range.` ). + ` another one by specifying the index range.` ). "When using only FROM, all lines are respected until the final "table entry. When using only TO, all lines are respected @@ -272,7 +197,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** output->next_section( `5) Inserting lines of an internal table` && - ` into another one at a specific position` ). + ` into another one at a specific position` ). "Inserting a single line INSERT VALUE #( a = 10 b = 'ggg' c = 'hhh' d = 'iii' ) @@ -292,7 +217,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. "Table on the right is constructed inline using VALUE and assigned "Note: This way, existing table content is cleared. - it_st = VALUE #( ( line ) + it_st = VALUE #( ( line ) ( a = 2 b = 'ddd' c = 'eee' d = 'fff' ) ). output->display( input = it_st name = `it_st` ). @@ -300,7 +225,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** output->next_section( `7) Creating a new table inline and adding lines` && - ` using a constructor expression` ). + ` using a constructor expression` ). "Internal table type TYPES it_type LIKE it_st. @@ -316,7 +241,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** output->next_section( `8) Adding lines using constructor expressions ` && - `and keeping existing table content` ). + `and keeping existing table content` ). "BASE addition: existing table content is not removed it_st = VALUE #( BASE it_st ( a = 5 b = 'mmm' c = 'nnn' d = 'ooo' ) @@ -328,13 +253,13 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** output->next_section( `9) Adding lines from other internal tables using` && - ` constructor expressions` ). + ` constructor expressions` ). "With LINES OF itab specified within the pair of parentheses, "all lines of the internal table are added; here, in the same "expression another line is added as well it_st = VALUE #( BASE it_st ( LINES OF it_st2 ) - ( a = 7 b = 'sss' c = 'ttt' d = 'uuu' ) + ( a = 7 b = 'sss' c = 'ttt' d = 'uuu' ) ). output->display( input = it_st name = `it_st` ). @@ -342,7 +267,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** output->next_section( `10) Copying table content (without constructor ` && - `expression)` ). + `expression)` ). "Assignment of a table to another one having a matching line type it_st = it_st2. @@ -366,9 +291,9 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** output->next_section( `Copying content from another table that has ` && - `a different line type ...` ). - output->display( `11a) ... and deleting existing table content ` && - `using the CORRESPONDING operator` ). + `a different line type ...` ). + output->display( `12) ... and deleting existing table content ` && + `using the CORRESPONDING operator` ). tab1 = CORRESPONDING #( tab2 ). @@ -378,8 +303,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `11b) ... and deleting existing table content ` && - `using MOVE-CORRESPONDING` ). + output->next_section( `13) ... and deleting existing table content ` && + `using MOVE-CORRESPONDING` ). MOVE-CORRESPONDING tab2 TO tab1. @@ -389,8 +314,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `11c) ... and keeping existing table ` && - `content using the CORRESPONDING operator` ). + output->next_section( `14) ... and keeping existing table ` && + `content using the CORRESPONDING operator` ). tab1 = CORRESPONDING #( BASE ( tab1 ) tab2 ). @@ -400,8 +325,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `11d) ... and keeping existing table ` && - `content using MOVE-CORRESPONDING` ). + output->next_section( `15) ... and keeping existing table ` && + `content using MOVE-CORRESPONDING` ). MOVE-CORRESPONDING tab2 TO tab1 KEEPING TARGET LINES. @@ -411,8 +336,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `11e) ... respecting component ` && - `mapping` ). + output->next_section( `16) ... respecting component ` && + `mapping` ). "Specifying components of a source table that are assigned to the "components of a target table in mapping relationships @@ -424,7 +349,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `11f) ... excluding components` ). + output->next_section( `17) ... excluding components` ). "Excluding components from the assignment tab1 = CORRESPONDING #( tab2 EXCEPT b ). @@ -433,7 +358,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `11g) ... excluding components and using MAPPING` ). + output->next_section( `18) ... excluding components and using MAPPING` ). "EXCEPT * means that all components remain initial not specified "for mapping @@ -445,7 +370,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `11h) ... discarding duplicates` ). + output->next_section( `19) ... discarding duplicates` ). "Preventing runtime errors if duplicate lines are assigned to "target table that is defined to only accept unique keys. @@ -463,8 +388,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `11i) Copying data from a deep ` && - `internal table to another deep internal table` ). + output->next_section( `20) Copying data from a deep ` && + `internal table to another deep internal table` ). output->display( `Original table content` ). output->display( input = itab_nested1 name = `itab_nested1` ). @@ -472,8 +397,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `11j) ... deleting ` && - `existing content (CORRESPONDING operator)` ). + output->next_section( `21) ... deleting ` && + `existing content (CORRESPONDING operator)` ). itab_nested2 = CORRESPONDING #( DEEP itab_nested1 ). @@ -483,8 +408,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `11k) ... deleting ` && - `existing content (MOVE-CORRESPONDING)` ). + output->next_section( `22) ... deleting ` && + `existing content (MOVE-CORRESPONDING)` ). MOVE-CORRESPONDING itab_nested1 TO itab_nested2 EXPANDING NESTED TABLES. @@ -495,8 +420,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `11l) ... keeping ` && - `existing content (CORRESPONDING operator)` ). + output->next_section( `23) ... keeping ` && + `existing content (CORRESPONDING operator)` ). itab_nested2 = CORRESPONDING #( DEEP BASE ( itab_nested2 ) itab_nested1 ). @@ -507,8 +432,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `11m) ... keeping ` && - `existing content (MOVE-CORRESPONDING)` ). + output->next_section( `24) ... keeping ` && + `existing content (MOVE-CORRESPONDING)` ). MOVE-CORRESPONDING itab_nested1 TO itab_nested2 EXPANDING NESTED TABLES KEEPING TARGET LINES. @@ -518,8 +443,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** output->next_section( `Filling internal tables: Excursions` ). - output->display( `12) Selecting multiple rows from a database ` && - `table into an internal table` ). + output->display( `25) Selecting multiple rows from a database ` && + `table into an internal table` ). SELECT FROM zdemo_abap_tab1 FIELDS key_field, char1, char2, num1, num2 @@ -530,8 +455,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `13) Sequentially adding multiple rows from ` && - `a database table to an internal table` ). + output->next_section( `26) Sequentially adding multiple rows from ` && + `a database table to an internal table` ). DATA itab TYPE TABLE OF zdemo_abap_tab1 WITH NON-UNIQUE KEY client key_field. @@ -554,9 +479,9 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `14) Adding multiple rows from a database table ` && - `to an internal table that has a different line type than the ` && - `database table and keeping existing table content` ). + output->next_section( `27) Adding multiple rows from a database table ` && + `to an internal table that has a different line type than the ` && + `database table and keeping existing table content` ). SELECT FROM zdemo_abap_tab2 FIELDS * @@ -567,9 +492,9 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `15) Adding multiple rows from a database table ` && - `to an internal table that has a different line type than the ` && - `database table and deleting existing table content` ). + output->next_section( `28) Adding multiple rows from a database table ` && + `to an internal table that has a different line type than the ` && + `database table and deleting existing table content` ). SELECT FROM zdemo_abap_tab2 FIELDS * @@ -580,8 +505,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `16) Adding multiple rows from an internal table ` && - `to an internal table using SELECT` ). + output->next_section( `29) Adding multiple rows from an internal table ` && + `to an internal table using SELECT` ). SELECT key_field, char1, char2, num1, num2 FROM @itab AS itab_alias @@ -591,14 +516,14 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `17) Combining data of multiple tables into an` && - ` internal table using an inner join` ). + output->next_section( `30) Combining data of multiple tables into an` && + ` internal table using an inner join` ). "Filling table to be selected from itab = VALUE #( ( key_field = 500 char1 = 'uuu' char2 = 'vvv' - num1 = 501 num2 = 502 ) + num1 = 501 num2 = 502 ) ( key_field = 600 char1 = 'www' char2 = 'xxx' - num1 = 601 num2 = 602 ) ). + num1 = 601 num2 = 602 ) ). "SELECT list includes fields from both tables "If there are no equivalent entries in the first or second table, @@ -614,8 +539,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `18) Filling internal table ` && - `using a subquery (1)` ). + output->next_section( `31) Filling internal table ` && + `using a subquery (1)` ). "A subquery is specified in the WHERE clause "Here, data is selected from a database table depending on @@ -630,8 +555,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `19) Filling internal table ` && - `using a subquery (2)` ). + output->next_section( `32) Filling internal table ` && + `using a subquery (2)` ). "A subquery using EXISTS in the WHERE clause. "In the example, data is selected from a database table depending @@ -649,9 +574,9 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `20) Filling an internal table from a table ` && - `depending on the existence of data in another internal table ` && - `using the addition FOR ALL ENTRIES` ). + output->next_section( `33) Filling an internal table from a table ` && + `depending on the existence of data in another internal table ` && + `using the addition FOR ALL ENTRIES` ). "In the example, data is selected from a database table depending "on the existence of data in an internal table. Only if a line @@ -670,8 +595,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `21) Adding content from a database to internal` && - ` table by using alias names in the SELECT list` ). + output->next_section( `34) Adding content from a database to internal` && + ` table by using alias names in the SELECT list` ). DATA itab2 TYPE TABLE OF zdemo_abap_tab2 WITH EMPTY KEY. @@ -688,7 +613,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `22) FILTER: Filtering internal table by condition` ). + output->next_section( `35) FILTER: Filtering internal table by condition` ). "This section covers multiple examples demonstrating the syntactical variety "of the FILTER operator. @@ -707,11 +632,11 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. DATA fi_tab3 TYPE HASHED TABLE OF fi_str WITH UNIQUE KEY a. "Filling internal tables - fi_tab1 = VALUE #( ( a = 1 b = 'aaa' c = 'abc' ) - ( a = 2 b = 'bbb' c = 'def' ) - ( a = 3 b = 'ccc' c = 'hij' ) - ( a = 4 b = 'ddd' c = 'klm' ) - ( a = 5 b = 'eee' c = 'nop' ) ). + fi_tab1 = VALUE #( ( a = 1 b = 'aaa' c = 'abc' ) + ( a = 2 b = 'bbb' c = 'def' ) + ( a = 3 b = 'ccc' c = 'hij' ) + ( a = 4 b = 'ddd' c = 'klm' ) + ( a = 5 b = 'eee' c = 'nop' ) ). fi_tab2 = fi_tab1. fi_tab3 = fi_tab1. @@ -789,8 +714,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `25) Inserting data into an internal table ` && - `using a COLLECT statement` ). + output->next_section( `36) Inserting data into an internal table ` && + `using a COLLECT statement` ). "Internal table to work with DATA itab_num TYPE SORTED TABLE OF l_type2 @@ -809,7 +734,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `Reading from internal tables` ). + output->next_section( `37) Reading from internal tables` ). "Filling internal tables it_st = VALUE #( ( a = 1 b = 'aaa' c = 'bbb' d = 'ccc' ) @@ -843,7 +768,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `26) Reading a single line into target area` ). + output->next_section( `38) Reading a single line into target area` ). "The examples anticipate the reading of a line by index since the "syntax requires to specify the reading via index or key. Both @@ -880,7 +805,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** output->next_section( `Reading a single line via index ...` ). - output->display( `27) ... using READ TABLE` ). + output->display( `39) ... using READ TABLE` ). "Primary table index used implicitly READ TABLE it_so_sec INTO DATA(wa3) INDEX 1. @@ -910,7 +835,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `28) ... table expressions (1)` ). + output->next_section( `40) ... table expressions (1)` ). "Reading via index; primary table index is used implicitly DATA(lv1) = it_so_sec[ 2 ]. @@ -949,7 +874,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `29) ... table expressions (2)` ). + output->next_section( `41) ... table expressions (2)` ). "Copying a table line via table expression and embedding in "a constructor expression @@ -973,7 +898,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** output->next_section( `Reading a single line via table keys ...` ). - output->display( `30) ... using READ TABLE (1)` ). + output->display( `42) ... using READ TABLE (1)` ). "Primary table key (COMPONENTS addition is optional) READ TABLE it_so_sec INTO DATA(wa9) @@ -1001,7 +926,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `31) ... using READ TABLE (2)` ). + output->next_section( `43) ... using READ TABLE (2)` ). "Reading a line based on keys specified in a work area "Here, the work area contains primary and secondary key values. @@ -1029,7 +954,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `32) ... using table expressions` ). + output->next_section( `44) ... using table expressions` ). "Primary table key (COMPONENTS addition is optional) DATA(lv9) = it_so_sec[ KEY primary_key COMPONENTS a = 1 ]. @@ -1050,7 +975,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `33) Reading a single line via free key` ). + output->next_section( `45) Reading a single line via free key` ). "Note: If there a multiple matching entries, the first found "is returned. READ TABLE it_so_sec INTO DATA(wa17) WITH KEY c = '###'. @@ -1062,7 +987,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `34) Excursion: Addressing individual components` ). + output->next_section( `46) Excursion: Addressing individual components` ). "Addressing a component using the component selector DATA(comp1) = it_so_sec[ 1 ]-b. @@ -1084,7 +1009,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `35) Checking if a line exists in an internal table` ). + output->next_section( `47) Checking if a line exists in an internal table` ). "Defining the key DATA(key1) = 2. @@ -1109,8 +1034,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `36) Checking the index of a ` && - `specific line` ). + output->next_section( `48) Checking the index of a ` && + `specific line` ). DATA(key2) = 4. @@ -1166,8 +1091,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. |in the internal table.| ). ENDIF. - output->next_section( `37) Checking how many lines are in an` && - ` internal table` ). + output->next_section( `49) Checking how many lines are in an` && + ` internal table` ). DATA(itab_lines) = lines( it_so_sec ). output->display( |The internal table consists of { itab_lines } | && @@ -1176,9 +1101,9 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** output->next_section( `Processing multiple internal table lines ` && - `sequentially` ). - output->display( `38a) Reading a complete table by sequentially ` && - `reading all lines` ). + `sequentially` ). + output->display( `50) Reading a complete table by sequentially ` && + `reading all lines` ). "No further addition: All lines are respected. LOOP AT it_so_sec ASSIGNING FIELD-SYMBOL(). @@ -1190,7 +1115,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->display( `38b) LOOP AT statements with different targets` ). + output->display( `51) LOOP AT statements with different targets` ). "The following examples demonstrate the different targets that "are possible for LOOP AT statements. In the example above, @@ -1265,7 +1190,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `39) Reading multiple lines by an index range` ). + output->next_section( `52) Reading multiple lines by an index range` ). "Specific lines in an index range are respected "Note: FROM/TO alone can specified, too. @@ -1278,7 +1203,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `40) Reading multiple lines by condition` ). + output->next_section( `53) Reading multiple lines by condition` ). LOOP AT it_so_sec ASSIGNING FIELD-SYMBOL() WHERE a < 3. "Modifying a component to visualize the reading of specific lines. @@ -1289,8 +1214,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `41) Looping across a table without an interest` && - ` in the table content` ). + output->next_section( `54) Looping across a table without an interest` && + ` in the table content` ). "Here, only the system fields are set. LOOP AT it_so_sec TRANSPORTING NO FIELDS WHERE a < 3. @@ -1302,7 +1227,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `42) Loop with table key specification` ). + output->next_section( `55) Loop with table key specification` ). DATA it_st_em TYPE TABLE OF struc1 WITH EMPTY KEY. @@ -1317,12 +1242,54 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. output->display( input = it_st_em name = `it_st_em` ). +********************************************************************** + + output->next_section( `STEP addition in LOOP AT statements` ). + output->display( `56) Reversing loop order` ). + + DATA(it_abc) = VALUE string_table( ( `a` ) ( `b` ) ( `c` ) ( `d` ) ( `e` ) ( `f` ) ). + DATA it_abc_result TYPE string_table. + + "Reversing the loop order with the addition STEP + "Each line is read indicated by absolute value 1 + LOOP AT it_abc ASSIGNING FIELD-SYMBOL() STEP -1. + APPEND TO it_abc_result. + ENDLOOP. + + output->display( input = it_abc_result name = `it_abc_result` ). + +********************************************************************** + + output->next_section( `57) Forward loop and defining step size` ). + + "Forward loop indicated by positive integer, every second line is processed + CLEAR it_abc_result. + LOOP AT it_abc ASSIGNING FIELD-SYMBOL() STEP 2. + APPEND TO it_abc_result. + ENDLOOP. + + output->display( input = it_abc_result name = `it_abc_result` ). + +********************************************************************** + + output->next_section( `58) STEP addition combined with FROM/TO` ). + + "Combining the STEP addition with other additions, e.g. FROM and TO + "Note: If the value after STEP is negative, the value after FROM + "must be greater than the value after TO. + CLEAR it_abc_result. + LOOP AT it_abc ASSIGNING FIELD-SYMBOL() FROM 6 TO 3 STEP -2. + APPEND TO it_abc_result. + ENDLOOP. + + output->display( input = it_abc_result name = `it_abc_result` ). + ********************************************************************** output->next_section( `Creating and filling tables using table ` && - `iterations with FOR and VALUE` ). - output->display( `43) Retrieving values of one column in ` && - `an internal table.` ). + `iterations with FOR and VALUE` ). + output->display( `59) Retrieving values of one column in ` && + `an internal table.` ). "Creating internal table type TYPES ty_numbers TYPE TABLE OF i WITH EMPTY KEY. @@ -1331,14 +1298,14 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. "evaluating a table using a table iteration with an iteration "expressions within a constructor expression. DATA(lv_num_a) = VALUE ty_numbers( FOR ls1 IN it_ha_sec - ( ls1-a ) ). + ( ls1-a ) ). output->display( input = lv_num_a name = `lv_num_a` ). ********************************************************************** - output->next_section( `44) Retrieving values of one column in ` && - `an internal table based on conditions` ). + output->next_section( `60) Retrieving values of one column in ` && + `an internal table based on conditions` ). DATA(lv_num_b) = VALUE ty_numbers( FOR ls2 IN it_ha_sec WHERE ( a < 3 ) ( ls2-a ) ). @@ -1347,30 +1314,31 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `45) Looping across 2 tables ` && - `and retrieving values based on conditions` ). + output->next_section( `61) Looping across 2 tables ` && + `and retrieving values based on conditions` ). "Internal table type TYPES tabtype LIKE it_so_sec. DATA(itab_for_2tab) = VALUE tabtype( - FOR ls3 IN it_ha_sec - FOR ls4 IN it_so_sec WHERE ( a = ls3-a ) - ( a = ls3-a b = ls4-b c = ls3-c d = ls4-d ) ). + FOR ls3 IN it_ha_sec + FOR ls4 IN it_so_sec WHERE ( a = ls3-a ) + ( a = ls3-a b = ls4-b c = ls3-c d = ls4-d ) ). output->display( input = itab_for_2tab name = `itab_for_2tab` ). ********************************************************************** - output->next_section( `46) Retrieving and changing values from an ` && - `internal tables sequentially` ). + output->next_section( `62) Retrieving and changing values from an ` && + `internal tables sequentially` ). DATA(it_changed) = VALUE tabtype( FOR ls5 IN it_so_sec - ( a = ls5-a b = 'WWW' c = 'VVV' d = 'UUU' ) ). + ( a = ls5-a b = 'WWW' c = 'VVV' d = 'UUU' ) ). output->display( input = it_changed name = `it_changed` ). +********************************************************************** - output->next_section( `Sorting internal tables` ). + output->next_section( `63) Sorting internal tables` ). "Creating structured data types TYPES: BEGIN OF s1, @@ -1401,14 +1369,14 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. it2 = it1. output->display( `Original internal table content ` && - `(it1 and it2 have the same content)` ). + `(it1 and it2 have the same content)` ). output->display( input = it1 name = `it1` ). output->display( input = it2 name = `it2` ). ********************************************************************** - output->next_section( `47) Sorting by primary table key` ). + output->next_section( `64) Sorting by primary table key` ). "Primary key: component a SORT it1. @@ -1417,8 +1385,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `48) Sorting by primary table key in ascending` && - ` order` ). + output->next_section( `65) Sorting by primary table key in ascending` && + ` order` ). "The sorting result is the same as above (where ASCENDING is used "implicitly). Here, it is explicitly specified. @@ -1428,8 +1396,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `49) Sorting by primary table key respecting all ` && - `non-numeric fields` ). + output->next_section( `66) Sorting by primary table key respecting all ` && + `non-numeric fields` ). "Primary key: standard table key (all non-numeric fields) SORT it2. @@ -1444,8 +1412,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `50) Sorting by primary table key in ` && - `descending order` ). + output->next_section( `67) Sorting by primary table key in ` && + `descending order` ). "Sorting in descending order and by primary table key SORT it1 DESCENDING. @@ -1454,7 +1422,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `51) Sorting by explicitly specified component (1)` ). + output->next_section( `68) Sorting by explicitly specified component (1)` ). "Here, the component is the primary table key. "The sorting result is the same as above. SORT it1 BY a DESCENDING. @@ -1463,7 +1431,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `52) Sorting by explicitly specified component (2)` ). + output->next_section( `69) Sorting by explicitly specified component (2)` ). "Sorting by arbitrary, non-key field SORT it1 BY d DESCENDING. @@ -1472,8 +1440,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `53) Sorting by multiple explicitly specified` && - ` components` ). + output->next_section( `70) Sorting by multiple explicitly specified` && + ` components` ). "Sorting by multiple components and specifying the sort order SORT it1 BY b ASCENDING c DESCENDING. @@ -1482,8 +1450,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `54) Sorting by respecting the values of all` && - ` components` ). + output->next_section( `71) Sorting by respecting the values of all` && + ` components` ). "Sorting by considering the values of each field of the table line SORT it1 BY table_line. @@ -1492,7 +1460,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `Modifying internal table content` ). + output->next_section( `72) Modifying internal table content` ). output->display( `Internal table content before modifications` ). "Standard table @@ -1506,7 +1474,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `55) Directly modifying recently read table lines` ). + output->next_section( `73) Directly modifying recently read table lines` ). "READ TABLE "Reading table line into target area (field symbol) @@ -1525,7 +1493,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `56) Modifying internal table content using MODIFY` ). + output->next_section( `74) Modifying internal table content using MODIFY` ). "Modifying table lines via key values "Line that is used to modify internal table line = VALUE #( a = 2 b = 'zzz' c = 'yyy' ). @@ -1579,7 +1547,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `57) Deleting internal table content using DELETE` ). + output->next_section( `75) Deleting internal table content using DELETE` ). "Deleting via index "Primary table index is used implicitly. DELETE it_st INDEX 1. @@ -1620,9 +1588,9 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `Deleting adjacent duplicate entries` ). + output->next_section( `76) Deleting adjacent duplicate entries` ). output->display( `Original table content (restored before` && - ` each of the following examples)` ). + ` each of the following examples)` ). it_st = VALUE #( ( a = 1 b = 'BBB' c = '###' d = '###' ) ( a = 2 b = '###' c = '###' d = '###' ) @@ -1645,8 +1613,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->display( `58) Deleting adjacent duplicates based on` && - ` primary table key` ). + output->next_section( `77) Deleting adjacent duplicates based on` && + ` primary table key` ). "Note: Using the primary table key can have unexpected consequences "if the primary table key is the standard key or if it is empty. @@ -1658,8 +1626,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `59) Deleting adjacent duplicates by comparing ` && - `all field values` ). + output->next_section( `78) Deleting adjacent duplicates by comparing ` && + `all field values` ). DELETE ADJACENT DUPLICATES FROM it_st2 COMPARING ALL FIELDS. @@ -1669,8 +1637,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `60) Deleting adjacent duplicates by comparing ` && - `specific field values` ). + output->next_section( `79) Deleting adjacent duplicates by comparing ` && + `specific field values` ). DELETE ADJACENT DUPLICATES FROM it_st2 COMPARING a c. @@ -1680,8 +1648,8 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `61) Deleting adjacent duplicates by using a` && - ` table key` ). + output->next_section( `80) Deleting adjacent duplicates by using a` && + ` table key` ). "In this case, the result is the same as in the first example. DELETE ADJACENT DUPLICATES FROM it_st2 USING KEY primary_key. @@ -1690,7 +1658,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `62) Deleting the entire internal table content` ). + output->next_section( `81) Deleting the entire internal table content` ). CLEAR it_st. @@ -1710,7 +1678,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** output->next_section( `Excursions` ). - output->display( `63) Secondary table keys and hashed tables` ). + output->display( `82) Secondary table keys and hashed tables` ). "Declaring a hashed table DATA hashed_tab @@ -1749,7 +1717,7 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. ********************************************************************** - output->next_section( `64) Empty keys in internal table created inline` ). + output->next_section( `83) Empty keys in internal table created inline` ). "This example visualizes the fact that when using an inline "construction like INTO TABLE @DATA(itab) in SELECT statements, the "resulting table has an empty table key. Here, the key information @@ -1785,6 +1753,67 @@ CLASS ZCL_DEMO_ABAP_INTERNAL_TABLES IMPLEMENTATION. )->get_keys( ). output->display( input = k2 name = `k2` ). - ENDMETHOD. -ENDCLASS. + + METHOD class_constructor. + fill_dbtabs( ). + ENDMETHOD. + + METHOD fill_dbtabs. + "Initializing and filling of database tables to have data to work with + + DELETE FROM zdemo_abap_tab1. + DELETE FROM zdemo_abap_tab2. + + MODIFY zdemo_abap_tab1 FROM TABLE @( VALUE #( + ( key_field = 100 char1 = 'aaa' char2 = 'bbb' num1 = 1 num2 = 2 ) + ( key_field = 200 char1 = 'ccc' char2 = 'ddd' num1 = 3 num2 = 4 ) + ( key_field = 300 char1 = 'eee' char2 = 'fff' num1 = 5 num2 = 6 ) + ( key_field = 400 char1 = 'ggg' char2 = 'hhh' num1 = 7 num2 = 8 ) ) ). + MODIFY zdemo_abap_tab2 FROM TABLE @( VALUE #( + ( key_field = 500 char1 = 'iii' num1 = 10 numlong = 1000 ) + ( key_field = 600 char1 = 'kkk' num1 = 12 numlong = 2000 ) + ( key_field = 700 char1 = 'mmm' num1 = 14 numlong = 3000 ) + ( key_field = 800 char1 = 'ooo' num1 = 15 numlong = 4000 ) ) ). + ENDMETHOD. + + + METHOD fill_itabs_for_corresponding. + tab1 = VALUE #( ( a = 1 b = 'aaa' c = 'aaa' d = 'A' ) + ( a = 2 b = 'bbb' c = 'bbb' d = 'B' ) ). + + tab2 = VALUE #( ( a = 3 b = 'ccc' e = 'ccc' f = `CCC` ) + ( a = 4 b = 'ddd' e = 'ddd' f = `DDD` ) ). + + tab3 = VALUE #( ( LINES OF tab1 ) ). + + tab4 = VALUE #( ( a = 1 b = 'xxx' e = 'yyy' f = `ZZZ` ) + ( LINES OF tab2 ) ). + + itab_nested1 = VALUE #( + ( key_field = 1 char1 = 'aaa' + tab = VALUE #( ( key_field = 1 num1 = 2 num2 = 3 ) + ( key_field = 2 num1 = 3 num2 = 4 ) + ( key_field = 3 num1 = 4 num2 = 5 ) ) ) + ( key_field = 2 char1 = 'bbb' + tab = VALUE #( ( key_field = 4 num1 = 5 num2 = 6 ) + ( key_field = 5 num1 = 6 num2 = 7 ) + ( key_field = 6 num1 = 7 num2 = 8 ) ) ) ). + + itab_nested2 = VALUE #( + ( key_field = 99 char2 = 'yyy' tab = VALUE #( + ( key_field = 10 char1 = 'aaa' + char2 = 'bbb' num1 = 100 num2 = 200 ) + ( key_field = 20 char1 = 'ccc' + char2 = 'ddd' num1 = 300 num2 = 400 ) + ( key_field = 30 char1 = 'eee' + char2 = 'fff' num1 = 500 num2 = 600 ) ) ) + ( key_field = 100 char2 = 'zzz' tab = VALUE #( + ( key_field = 40 char1 = 'ggg' + char2 = 'hhh' num1 = 700 num2 = 800 ) + ( key_field = 50 char1 = 'iii' + char2 = 'jjj' num1 = 900 num2 = 1000 ) + ( key_field = 60 char1 = 'kkk' + char2 = 'lll' num1 = 1100 num2 = 1200 ) ) ) ). + ENDMETHOD. +ENDCLASS. \ No newline at end of file diff --git a/src/zdemo_abap_cds_ve_sel.ddls.asddls b/src/zdemo_abap_cds_ve_sel.ddls.asddls index adffe58..ce762d0 100644 --- a/src/zdemo_abap_cds_ve_sel.ddls.asddls +++ b/src/zdemo_abap_cds_ve_sel.ddls.asddls @@ -132,10 +132,10 @@ define view entity zdemo_abap_cds_ve_sel // You can use the ELSE NULL addition that returns the null value. // Note: If ELSE is not specified, the null value is returned as a result. - // case $projection.case1 - // when 'X' then 'A' - // else null - // end as case2, + case $projection.case1 + when 'X' then 'A' + else null + end as case2, // Complex case distinction (searched case) for evaluating conditions case