Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
danrega committed Dec 21, 2023
1 parent 990647a commit 3290f1f
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 46 deletions.
2 changes: 1 addition & 1 deletion 03_ABAP_SQL.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ SELECT FROM dbtab
- If the row is found, the system field `sy-subrc` is set to `0`.
- The loop must be closed using `ENDSELECT`.
- To terminate the loop completely, you can use the statement [`EXIT`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapexit_loop.htm).
- Note: As touched on further down, when using the addition `PACKAGE SIZE` and storing the result in a table, a loop is opened, too.
- Note: As covered further down, when using the addition `PACKAGE SIZE` and storing the result in a table, a loop is opened, too.

``` abap
SELECT FROM dbtab
Expand Down
10 changes: 6 additions & 4 deletions 04_ABAP_Object_Orientation.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ kinds of components are to be distinguished when, for example, looking at declar
- [Instance components](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abeninstance_component_glosry.htm "Glossary Entry"):
Components that exist separately for each instance and can only be accessed in instances of a class.
- [Static components](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenstatic_component_glosry.htm "Glossary Entry") (the declarations with `CLASS-`):
Components that exist only once per class. They do no not exist for specific instances. They can be addressed using the name of the class.
Components that exist only once per class. They do no not exclusively exist for specific instances. They can be addressed using the name of the class.

**Attributes**

Expand Down Expand Up @@ -314,7 +314,7 @@ In the simplest form, methods can have no parameter at all. Apart from that, met
|`IMPORTING`|Defines one or more input parameters to be imported by the method. |
|`EXPORTING`|Defines one or more output parameters to be exported by the method. |
|`CHANGING`|Defines one or more input or output parameters, i. e. that can be both imported and exported. |
|`RETURNING`|For [functional methods](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenfunctional_method_glosry.htm "Glossary Entry"), i. e. such methods have only one `RETURNING` parameter that can be defined. As an output parameter like the `EXPORTING` parameter, `RETURNING` parameters pass back values (note that the formal parameters of returning parameters must be passed by value as touched on below). In contrast to `EXPORTING` for which multiple parameters can be specified, only one `RETURNING` parameter can be specified in a method. If you only need one output parameter, you can benefit from using a `RETURNING` parameter by shortening the method call and enabling method chaining. Another big plus is that such functional methods can, for example, be used in expressions. In case of standalone method calls, the returned value can be accessed using the addition `RECEIVING`. |
|`RETURNING`|For [functional methods](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenfunctional_method_glosry.htm "Glossary Entry"), i. e. such methods have only one `RETURNING` parameter that can be defined. As an output parameter like the `EXPORTING` parameter, `RETURNING` parameters pass back values (note that the formal parameters of returning parameters must be passed by value as covered below). In contrast to `EXPORTING` for which multiple parameters can be specified, only one `RETURNING` parameter can be specified in a method. If you only need one output parameter, you can benefit from using a `RETURNING` parameter by shortening the method call and enabling method chaining. Another big plus is that such functional methods can, for example, be used in expressions. In case of standalone method calls, the returned value can be accessed using the addition `RECEIVING`. |
|`RAISING` | Used to declare the [class-based exceptions](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenclass_based_exception_glosry.htm "Glossary Entry") that can be propagated from the method to the caller. |


Expand Down Expand Up @@ -537,7 +537,7 @@ ENDDO.
**Clearing object references**: You can use
[`CLEAR`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapclear.htm)
statements to explicitly clear a reference variable.
```
```abap
CLEAR ref.
```

Expand Down Expand Up @@ -1156,7 +1156,7 @@ SET HANDLER handler3.

### Excursion: Factory Methods and Singletons as Design Patterns

In object-oriented programming, there a plenty of design patterns. Touching on these ones here to get a rough idea: factory methods and singletons. Both are relevant if you want to restrict or control the instantiation of a class by external users of this class.
In object-oriented programming, there a plenty of design patterns. Covering these ones here to get a rough idea: factory methods and singletons. Both are relevant if you want to restrict or control the instantiation of a class by external users of this class.

A singleton is a design pattern in which it is only up to the class to create objects. In doing so, the class ensures that only one object exists for every internal session that is made available to consumers.

Expand Down Expand Up @@ -1222,8 +1222,10 @@ obj_factory = class=>factory_method( par = ... ).

## More Information
You can check the subtopics of

- [ABAP Objects - Overview](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabap_objects_oview.htm)
- [Programming Guidlines - Object-Oriented Programming (F1 docu for standard ABAP)](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenobj_oriented_gdl.htm)

in the ABAP Keyword Documentation.

## Executable Example
Expand Down
53 changes: 21 additions & 32 deletions 06_Dynamic_Programming.md
Original file line number Diff line number Diff line change
Expand Up @@ -714,10 +714,9 @@ ASSIGN COMPONENT 3 OF STRUCTURE st TO <fs>.
"------- Assigning attributes of classes or interfaces dynamically ------
"The following syntax pattern shows the possible specifications.
"clif stands for the name of a class or interface.
"... cref->(attr_name) ...
"... iref->(attr_name) ...
"... (clif_name)=>(attr_name) ...
"... cref->(attr_name) ... "object reference variable
"... iref->(attr_name) ... "interface reference variable
"... (clif_name)=>(attr_name) ... "class/interface name
"... (clif_name)=>attr ...
"... clif=>(attr_name) ...
Expand All @@ -743,13 +742,13 @@ ASSIGN iref->('IN_STR') TO <fs>.
ASSIGN zcl_demo_abap_objects=>('PUBLIC_STRING') TO <fs>.
ASSIGN zdemo_abap_objects_interface=>('CONST_INTF') TO <fs>.
"Specifying a class or interface dynamically, and attributes dynamically
ASSIGN ('zcl_demo_abap_objects')=>public_string TO <fs>.
ASSIGN ('zdemo_abap_objects_interface')=>const_intf TO <fs>.
"Specifying a class or interface dynamically, and attributes statically
ASSIGN ('ZCL_DEMO_ABAP_OBJECTS')=>public_string TO <fs>.
ASSIGN ('ZDEMO_ABAP_OBJECTS_INTERFACE')=>const_intf TO <fs>.
"Specifying a class or interface as well as attributes dynamically
ASSIGN ('zcl_demo_abap_objects')=>('PUBLIC_STRING') TO <fs>.
ASSIGN ('zdemo_abap_objects_interface')=>('CONST_INTF') TO <fs>.
ASSIGN ('ZCL_DEMO_ABAP_OBJECTS')=>('PUBLIC_STRING') TO <fs>.
ASSIGN ('ZDEMO_ABAP_OBJECTS_INTERFACE')=>('CONST_INTF') TO <fs>.
"Further dynamic syntax options are possible, for example,
"specifying the memory area after ASSIGN with a writable expressions
Expand Down Expand Up @@ -883,8 +882,8 @@ DATA itab TYPE TABLE OF demo_struct
TYPES itab_type LIKE itab.
DATA itab_ref TYPE TABLE OF REF TO demo_struct WITH EMPTY KEY.
itab_ek = VALUE #( ( col1 = 1 col2 = `aaa` col3 = `zzz` )
( col1 = 2 col2 = `bbb` col3 = `yyy` )
( col1 = 3 col2 = `ccc` col3 = `xxx` ) ).
( col1 = 2 col2 = `bbb` col3 = `yyy` )
( col1 = 3 col2 = `ccc` col3 = `xxx` ) ).
itab = itab_ek.
itab_ref = VALUE #( ( NEW demo_struct( col1 = 1 col2 = `aaa` col3 = `zzz` ) ) ).
Expand Down Expand Up @@ -912,7 +911,7 @@ READ TABLE itab FROM wa_read USING KEY ('SK') REFERENCE INTO DATA(read_ref).
"The component names can also be specified dynamically (which is done in most of the
"following examples for demonstration purposes).
READ TABLE itab WITH TABLE KEY ('SK') COMPONENTS ('COL2') = `aaa` REFERENCE INTO read_ref.
"Specifying the predefined name primary_key explicitly
"Specifying the predefined name primary_key explicitly and dynamically
READ TABLE itab WITH TABLE KEY ('PRIMARY_KEY') COMPONENTS ('COL1') = 1 REFERENCE INTO read_ref.
"If the addition COMPONENTS is not specified, the primary table key is used by default.
READ TABLE itab WITH TABLE KEY ('COL1') = 1 REFERENCE INTO read_ref.
Expand Down Expand Up @@ -958,7 +957,7 @@ DATA(wa_te2) = itab[ ('COL2') = `bbb` ('COL3') = `yyy` ].
"In the following example, the component names are also specified dynamically.
DATA(wa_te3) = itab[ KEY ('SK') ('COL2') = `ccc` ].
"Specifying the COMPONENTS addition explicitly
DATA(wa_te4) = itab[ KEY ('primary_key') COMPONENTS ('col1') = 1 ].
DATA(wa_te4) = itab[ KEY ('PRIMARY_KEY') COMPONENTS ('col1') = 1 ].
"Accessing components
"As shown abobe, chaininings with the (object) component selector are possible.
Expand Down Expand Up @@ -997,7 +996,7 @@ ENDLOOP.
"- secondary table key: order of itab entries 5 ... /4 ... /...
"- primary table key: order of itab entries 4 ... /5 ... /...
INSERT LINES OF VALUE itab_type( ( col1 = 4 col2 = `eee` col3 = `www` )
( col1 = 5 col2 = `ddd` col3 = `vvv` ) )
( col1 = 5 col2 = `ddd` col3 = `vvv` ) )
USING KEY ('SK')
"USING KEY ('PRIMARY_KEY')
INTO itab INDEX 1.
Expand All @@ -1019,31 +1018,23 @@ LOOP AT itab INTO DATA(wa_pk) USING KEY ('PRIMARY_KEY').
ENDLOOP.
"------- MODIFY ------
"specified using a table key or a table index.
"the statement MODIFY assigns the content of
"In the following example, a line is modified based on a work area and a table key.
"The component col1 is left out from the work area intentionally.
"If the primary table key was used, the value of sy-subrc would be 4, and no modification was done.
"The optional addition transporting is specified to denote what should be modified. In this example,
"the component is also specified dynamically.
MODIFY TABLE itab FROM VALUE #( col2 = `bbb` col3 = `uuu` )
USING KEY ('SK')
TRANSPORTING ('COL3').
MODIFY TABLE itab FROM VALUE #( col2 = `bbb` col3 = `uuu` ) USING KEY ('SK') TRANSPORTING ('COL3').
"In the following example, a line is modified based on a work area, an index specification and a
"table key.
"INDEX can also be positioned after FROM.
MODIFY itab INDEX 2 USING KEY ('SK')
FROM VALUE #( col3 = `ttt` )
TRANSPORTING ('COL3').
MODIFY itab INDEX 2 USING KEY ('SK') FROM VALUE #( col3 = `ttt` ) TRANSPORTING ('COL3').
"Dynamic WHERE clause (only to be used with the TRANSPORTING addition)
"The USING KEY addition is also possible. Check the ABAP Keyword Documentation
"for special rules that apply.
DATA(cond_mod) = `COL1 < 3`.
MODIFY itab FROM VALUE #( col3 = `sss` )
TRANSPORTING ('COL3')
WHERE (cond_mod).
MODIFY itab FROM VALUE #( col3 = `sss` ) TRANSPORTING ('COL3') WHERE (cond_mod).
"------- DELETE ------
"A single line or multipled lines can be deleted.
Expand All @@ -1054,12 +1045,10 @@ MODIFY itab FROM VALUE #( col3 = `sss` )
"The values can be declared either implicitly in a work area after FROM or explicitly
"by listing the components of the table key after TABLE KEY.
"If the USING KEY addition is not specified, the primary table key is used by default.
DELETE TABLE itab FROM VALUE #( col2 = `eee` col3 = `www` )
USING KEY ('SK').
DELETE TABLE itab FROM VALUE #( col2 = `eee` col3 = `www` ) USING KEY ('SK').
"Each component of the table key must be listed.
DELETE TABLE itab WITH TABLE KEY ('SK')
COMPONENTS ('COL2') = `ddd`.
DELETE TABLE itab WITH TABLE KEY ('SK') COMPONENTS ('COL2') = `ddd`.
"Deleting based on the table index
DELETE itab INDEX 1 USING KEY ('SK').
Expand All @@ -1076,7 +1065,7 @@ DELETE itab WHERE (condition_tab).

### Dynamic ABAP SQL Statements

```
```abap
"Dynamic SELECT list
DATA(select_list) = `CARRID, CONNID, FLDATE`.
DATA fli_tab TYPE TABLE OF zdemo_abap_fli WITH EMPTY KEY.
Expand Down Expand Up @@ -1124,8 +1113,8 @@ SELECT *
"The example includes a WHERE clause that is created as an internal
"table with a character-like row type.
DATA(where_clause) = VALUE string_table( ( `CARRID = 'LH'` )
( `OR` )
( `CARRID = 'AA'` ) ).
( `OR` )
( `CARRID = 'AA'` ) ).
SELECT *
FROM zdemo_abap_fli
Expand Down
11 changes: 7 additions & 4 deletions 08_EML_ABAP_for_RAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
## RAP Terms

[ABAP Entity Manipulation Language](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenaeml_glosry.htm) (or EML for short) is a subset of ABAP that allows you to access the data of [RAP](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenarap_glosry.htm) business objects in an ABAP program.
The following points touch on RAP-related terms such as *RAP business objects* and others for setting the context:
The following points cover RAP-related terms such as *RAP business objects* and others for setting the context:

- RAP business objects (RAP BO)
- A RAP BO is based on a special, tree-like hierarchical structure
Expand Down Expand Up @@ -162,10 +162,10 @@ The following points touch on RAP-related terms such as *RAP business objects* a
of the behavior pool. These classes are called by the [RAP
runtime
engine](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_runtime_engine_glosry.htm "Glossary Entry")
when the RAP BO is accessed. This is touched on in more detail
when the RAP BO is accessed. This is covered in more detail
further down.
- Usually, saver classes are not needed in managed RAP BOs (except
for special variants of managed RAP BOs which are not touched on
for special variants of managed RAP BOs which are not covered
here). Local handler classes are, as mentioned above, usually
needed in managed RAP BOs if implementations are required that
go beyond standard operations.
Expand All @@ -179,6 +179,8 @@ The following points touch on RAP-related terms such as *RAP business objects* a
pools can be assigned to a BDEF allowing applications a
structuring into multiple units.


Find more terms in the [RAP Glossary](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_glossary.htm) of the ABAP Keyword Documentation.
There are more artifacts and concepts related to RAP that go way beyond
the scope of this cheat sheet. For example, a RAP BO can be exposed as a
[business
Expand Down Expand Up @@ -298,7 +300,7 @@ METHODS some_action FOR MODIFY
are followed by parameters.
- Nearly all parameters are typed with [BDEF derived
types](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_derived_type_glosry.htm "Glossary Entry")
that have special RAP-related components as touched on further down.
that have special RAP-related components as covered further down.
- The parameters' names can be chosen freely. This is also true for
the method names except for some predefined names.
- Each handler method must have at least one importing parameter. The
Expand Down Expand Up @@ -1359,6 +1361,7 @@ The following restrictions apply to operations and/or statements in the individu
- Section [ABAP for RAP Business
Objects](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabap_for_rap_bos.htm)
in the ABAP Keyword Documentation including EML
- [RAP Glossary](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_glossary.htm)
- [Development guide for the ABAP RESTful Application Programming
Model](https://help.sap.com/docs/ABAP_PLATFORM_NEW/fc4c71aa50014fd1b43721701471913d/289477a81eec4d4e84c0302fb6835035.html)
- [RAP
Expand Down
2 changes: 1 addition & 1 deletion 12_AMDP.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Note:
version](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenunrestricted_version_glosry.htm "Glossary Entry")
scope, more syntax options are allowed for AMDP method declaration
and implementation parts. Check the ABAP Keyword Documentation for
more details as touched on further down.
more details as covered further down.

<p align="right"><a href="#top">⬆️ back to top</a></p>

Expand Down
2 changes: 1 addition & 1 deletion 13_Program_Flow_Logic.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ ENDWHILE.
<p align="right"><a href="#top">⬆️ back to top</a></p>

#### Loops Across Tables
Further keywords for defining loops are as follows. They are not dealt with here since they are touched on in other ABAP cheat sheets.
Further keywords for defining loops are as follows. They are not dealt with here since they are covered in other ABAP cheat sheets.

- [`LOOP ... ENDLOOP`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaploop_at_itab.htm) statements are meant for loops across internal tables. See also the cheat sheet on internal tables.
- In contrast to the loops above, the system field `sy-index` is not set. Instead, the system field `sy-tabix` is set and which contains the table index of the current table line in the loop pass.
Expand Down
2 changes: 1 addition & 1 deletion 19_ABAP_for_Cloud_Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- [Executable Example](#executable-example)


This ABAP cheat sheet briefly touches on the terms ABAP Cloud and classic ABAP to get an idea about [ABAP for Cloud Development](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabap_for_cloud_dev_glosry.htm).
This ABAP cheat sheet briefly outlines the terms ABAP Cloud and classic ABAP to get an idea about [ABAP for Cloud Development](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabap_for_cloud_dev_glosry.htm).
It provides references to more detailed information on the topic.

# Terms
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ABAP cheat sheets[^1] ...

| Cheat Sheet | Topics Covered | Demo Example |
| ------------- | ------------- | ----- |
|[ABAP for Cloud Development](19_ABAP_for_Cloud_Development.md)| Briefly touches on the terms ABAP Cloud and classic ABAP to set the context for ABAP for Cloud Development | [zcl_demo_abap_cloud_excursion](./src/zcl_demo_abap_cloud_excursion.clas.abap) (see the notes in the cheat sheet) |
|[ABAP for Cloud Development](19_ABAP_for_Cloud_Development.md)| Briefly outlines the terms ABAP Cloud and classic ABAP to set the context for ABAP for Cloud Development | [zcl_demo_abap_cloud_excursion](./src/zcl_demo_abap_cloud_excursion.clas.abap) (see the notes in the cheat sheet) |
|[Data Types and Data Objects](16_Data_Types_and_Objects.md)| Contains basic information about data types and data objects in ABAP | [zcl_demo_abap_dtype_dobj](./src/zcl_demo_abap_dtype_dobj.clas.abap) |
|[Internal Tables](01_Internal_Tables.md)| Creating, filling, reading from, sorting, modifying internal tables | [zcl_demo_abap_internal_tables](./src/zcl_demo_abap_internal_tables.clas.abap) |
|[Structures](02_Structures.md)| Some basics when working with structures | [zcl_demo_abap_structures](./src/zcl_demo_abap_structures.clas.abap) |
Expand Down
2 changes: 1 addition & 1 deletion src/zcl_demo_abap_prog_flow_logic.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ CLASS zcl_demo_abap_prog_flow_logic IMPLEMENTATION.
"define conditions for operands. The result of such an expression is either true or false.
"The example demonstrates a selection of possible expressions and operands of such expressions
"using a big IF statement. It includes multiple expressions combined by AND to demonstrate
"different options. Here, it is just meant to touch on many syntax options in one go
"different options. Here, it is just meant to cover many syntax options in one go
"for demonstration purposes.

"Data declarations to be used in the IF statement below
Expand Down

0 comments on commit 3290f1f

Please sign in to comment.