├── .abapgit.xml ├── 01_Internal_Tables.md ├── 02_Structures.md ├── 03_ABAP_SQL.md ├── 04_ABAP_Object_Orientation.md ├── 05_Constructor_Expressions.md ├── 06_Dynamic_Programming.md ├── 07_String_Processing.md ├── 08_EML_ABAP_for_RAP.md ├── 09_Bits_and_Bytes.md ├── 10_ABAP_SQL_Hierarchies.md ├── 11_Internal_Tables_Grouping.md ├── 12_AMDP.md ├── 13_Program_Flow_Logic.md ├── 14_ABAP_Unit_Tests.md ├── 15_CDS_View_Entities.md ├── 16_Data_Types_and_Objects.md ├── 17_SAP_LUW.md ├── 18_Dynpro.md ├── 19_ABAP_for_Cloud_Development.md ├── 20_Selection_Screens_Lists.md ├── 21_XML_JSON.md ├── 22_Released_ABAP_Classes.md ├── 23_Date_and_Time.md ├── 24_Builtin_Functions.md ├── 25_Authorization_Checks.md ├── 26_ABAP_Dictionary.md ├── 27_Exceptions.md ├── 28_Regular_Expressions.md ├── 29_Numeric_Operations.md ├── 30_Generative_AI.md ├── 31_WHERE_Conditions.md ├── LICENSE ├── LICENSES └── Apache-2.0.txt ├── README.md ├── REUSE.toml ├── files ├── ABAP_Keyword_Documentation.png ├── abapGit_Repositories.png ├── bdef_derived_type_components.png ├── bdef_derived_types.png ├── example_topics.png ├── phases_of_rap_luw.png ├── rap_handler_method_parameters.png ├── release_contract.png ├── released_APIs.png └── standard.png └── src ├── ezdemo_abap_lock.enqu.xml ├── package.devc.xml ├── zbp_demo_abap_rap_draft_m.clas.abap ├── zbp_demo_abap_rap_draft_m.clas.locals_imp.abap ├── zbp_demo_abap_rap_draft_m.clas.xml ├── zbp_demo_abap_rap_ro_m.clas.abap ├── zbp_demo_abap_rap_ro_m.clas.locals_imp.abap ├── zbp_demo_abap_rap_ro_m.clas.xml ├── zbp_demo_abap_rap_ro_m_as.clas.abap ├── zbp_demo_abap_rap_ro_m_as.clas.locals_imp.abap ├── zbp_demo_abap_rap_ro_m_as.clas.xml ├── zbp_demo_abap_rap_ro_u.clas.abap ├── zbp_demo_abap_rap_ro_u.clas.locals_imp.abap ├── zbp_demo_abap_rap_ro_u.clas.xml ├── zcl_demo_abap_amdp.clas.abap ├── zcl_demo_abap_amdp.clas.xml ├── zcl_demo_abap_aux.clas.abap ├── zcl_demo_abap_aux.clas.xml ├── zcl_demo_abap_builtin_func.clas.abap ├── zcl_demo_abap_builtin_func.clas.xml ├── zcl_demo_abap_cds_ve.clas.abap ├── zcl_demo_abap_cds_ve.clas.xml ├── zcl_demo_abap_cloud_excursion.clas.abap ├── zcl_demo_abap_cloud_excursion.clas.xml ├── zcl_demo_abap_constructor_expr.clas.abap ├── zcl_demo_abap_constructor_expr.clas.locals_imp.abap ├── zcl_demo_abap_constructor_expr.clas.xml ├── zcl_demo_abap_date_time.clas.abap ├── zcl_demo_abap_date_time.clas.locals_imp.abap ├── zcl_demo_abap_date_time.clas.xml ├── zcl_demo_abap_dtype_dobj.clas.abap ├── zcl_demo_abap_dtype_dobj.clas.xml ├── zcl_demo_abap_dynamic_prog.clas.abap ├── zcl_demo_abap_dynamic_prog.clas.locals_imp.abap ├── zcl_demo_abap_dynamic_prog.clas.xml ├── zcl_demo_abap_error_handling.clas.abap ├── zcl_demo_abap_error_handling.clas.xml ├── zcl_demo_abap_internal_tables.clas.abap ├── zcl_demo_abap_internal_tables.clas.xml ├── zcl_demo_abap_objects.clas.abap ├── zcl_demo_abap_objects.clas.locals_imp.abap ├── zcl_demo_abap_objects.clas.xml ├── zcl_demo_abap_objects_friend.clas.abap ├── zcl_demo_abap_objects_friend.clas.xml ├── zcl_demo_abap_objects_misc.clas.abap ├── zcl_demo_abap_objects_misc.clas.locals_def.abap ├── zcl_demo_abap_objects_misc.clas.locals_imp.abap ├── zcl_demo_abap_objects_misc.clas.xml ├── zcl_demo_abap_oo_inheritance_1.clas.abap ├── zcl_demo_abap_oo_inheritance_1.clas.xml ├── zcl_demo_abap_oo_inheritance_2.clas.abap ├── zcl_demo_abap_oo_inheritance_2.clas.xml ├── zcl_demo_abap_oo_inheritance_3.clas.abap ├── zcl_demo_abap_oo_inheritance_3.clas.xml ├── zcl_demo_abap_oo_inheritance_4.clas.abap ├── zcl_demo_abap_oo_inheritance_4.clas.xml ├── zcl_demo_abap_prog_flow_logic.clas.abap ├── zcl_demo_abap_prog_flow_logic.clas.locals_def.abap ├── zcl_demo_abap_prog_flow_logic.clas.xml ├── zcl_demo_abap_rap_draft_ln_m.clas.abap ├── zcl_demo_abap_rap_draft_ln_m.clas.xml ├── zcl_demo_abap_rap_evt_handler.clas.abap ├── zcl_demo_abap_rap_evt_handler.clas.locals_imp.abap ├── zcl_demo_abap_rap_evt_handler.clas.xml ├── zcl_demo_abap_rap_ext_num_m.clas.abap ├── zcl_demo_abap_rap_ext_num_m.clas.xml ├── zcl_demo_abap_rap_ext_num_u.clas.abap ├── zcl_demo_abap_rap_ext_num_u.clas.xml ├── zcl_demo_abap_rap_m_as.clas.abap ├── zcl_demo_abap_rap_m_as.clas.xml ├── zcl_demo_abap_regex.clas.abap ├── zcl_demo_abap_regex.clas.xml ├── zcl_demo_abap_sql.clas.abap ├── zcl_demo_abap_sql.clas.xml ├── zcl_demo_abap_sql_group_by.clas.abap ├── zcl_demo_abap_sql_group_by.clas.xml ├── zcl_demo_abap_string_proc.clas.abap ├── zcl_demo_abap_string_proc.clas.xml ├── zcl_demo_abap_structures.clas.abap ├── zcl_demo_abap_structures.clas.xml ├── zcl_demo_abap_unit_dataprov.clas.abap ├── zcl_demo_abap_unit_dataprov.clas.xml ├── zcl_demo_abap_unit_tdf.clas.abap ├── zcl_demo_abap_unit_tdf.clas.xml ├── zcl_demo_abap_unit_test.clas.abap ├── zcl_demo_abap_unit_test.clas.locals_def.abap ├── zcl_demo_abap_unit_test.clas.locals_imp.abap ├── zcl_demo_abap_unit_test.clas.testclasses.abap ├── zcl_demo_abap_unit_test.clas.xml ├── zcl_demo_abap_xml_json.clas.abap ├── zcl_demo_abap_xml_json.clas.xml ├── zcx_demo_abap_error_a.clas.abap ├── zcx_demo_abap_error_a.clas.xml ├── zcx_demo_abap_error_b.clas.abap ├── zcx_demo_abap_error_b.clas.xml ├── zdemo_abap_abstract_ent.ddls.asddls ├── zdemo_abap_abstract_ent.ddls.baseinfo ├── zdemo_abap_abstract_ent.ddls.xml ├── zdemo_abap_carr.tabl.xml ├── zdemo_abap_carr_ve.ddls.asddls ├── zdemo_abap_carr_ve.ddls.baseinfo ├── zdemo_abap_carr_ve.ddls.xml ├── zdemo_abap_cds_ve_agg_exp.ddls.asddls ├── zdemo_abap_cds_ve_agg_exp.ddls.baseinfo ├── zdemo_abap_cds_ve_agg_exp.ddls.xml ├── zdemo_abap_cds_ve_assoc.ddls.asddls ├── zdemo_abap_cds_ve_assoc.ddls.baseinfo ├── zdemo_abap_cds_ve_assoc.ddls.xml ├── zdemo_abap_cds_ve_assoc_e.ddls.asddls ├── zdemo_abap_cds_ve_assoc_e.ddls.baseinfo ├── zdemo_abap_cds_ve_assoc_e.ddls.xml ├── zdemo_abap_cds_ve_joins.ddls.asddls ├── zdemo_abap_cds_ve_joins.ddls.baseinfo ├── zdemo_abap_cds_ve_joins.ddls.xml ├── zdemo_abap_cds_ve_sel.ddls.asddls ├── zdemo_abap_cds_ve_sel.ddls.baseinfo ├── zdemo_abap_cds_ve_sel.ddls.xml ├── zdemo_abap_draft.tabl.xml ├── zdemo_abap_fli.tabl.xml ├── zdemo_abap_fli_ve.ddls.asddls ├── zdemo_abap_fli_ve.ddls.baseinfo ├── zdemo_abap_fli_ve.ddls.xml ├── zdemo_abap_flsch.tabl.xml ├── zdemo_abap_flsch_ve.ddls.asddls ├── zdemo_abap_flsch_ve.ddls.baseinfo ├── zdemo_abap_flsch_ve.ddls.xml ├── zdemo_abap_get_data_itf.intf.abap ├── zdemo_abap_get_data_itf.intf.xml ├── zdemo_abap_messages.msag.xml ├── zdemo_abap_objects_interface.intf.abap ├── zdemo_abap_objects_interface.intf.xml ├── zdemo_abap_rap_calc_sd.srvd.srvdsrv ├── zdemo_abap_rap_calc_sd.srvd.xml ├── zdemo_abap_rap_ch_m.ddls.asddls ├── zdemo_abap_rap_ch_m.ddls.baseinfo ├── zdemo_abap_rap_ch_m.ddls.xml ├── zdemo_abap_rap_ch_u.ddls.asddls ├── zdemo_abap_rap_ch_u.ddls.baseinfo ├── zdemo_abap_rap_ch_u.ddls.xml ├── zdemo_abap_rap_draft_m.bdef.asbdef ├── zdemo_abap_rap_draft_m.bdef.xml ├── zdemo_abap_rap_draft_m.ddls.asddls ├── zdemo_abap_rap_draft_m.ddls.baseinfo ├── zdemo_abap_rap_draft_m.ddls.xml ├── zdemo_abap_rap_ro_m.bdef.asbdef ├── zdemo_abap_rap_ro_m.bdef.xml ├── zdemo_abap_rap_ro_m.ddls.asddls ├── zdemo_abap_rap_ro_m.ddls.baseinfo ├── zdemo_abap_rap_ro_m.ddls.xml ├── zdemo_abap_rap_ro_m_as.bdef.asbdef ├── zdemo_abap_rap_ro_m_as.bdef.xml ├── zdemo_abap_rap_ro_m_as.ddls.asddls ├── zdemo_abap_rap_ro_m_as.ddls.baseinfo ├── zdemo_abap_rap_ro_m_as.ddls.xml ├── zdemo_abap_rap_ro_u.bdef.asbdef ├── zdemo_abap_rap_ro_u.bdef.xml ├── zdemo_abap_rap_ro_u.ddls.asddls ├── zdemo_abap_rap_ro_u.ddls.baseinfo ├── zdemo_abap_rap_ro_u.ddls.xml ├── zdemo_abap_rapt1.tabl.xml ├── zdemo_abap_rapt2.tabl.xml ├── zdemo_abap_st_carrhtml.xslt.source.xml ├── zdemo_abap_st_carrhtml.xslt.xml ├── zdemo_abap_st_strhtml.xslt.source.xml ├── zdemo_abap_st_strhtml.xslt.xml ├── zdemo_abap_tab1.tabl.xml ├── zdemo_abap_tab2.tabl.xml ├── zdemo_abap_tabca.tabl.xml ├── zdemo_abap_table_function.ddls.asddls ├── zdemo_abap_table_function.ddls.baseinfo ├── zdemo_abap_table_function.ddls.xml ├── zdemo_abap_xslt_fl.xslt.source.xml ├── zdemo_abap_xslt_fl.xslt.xml ├── ztcl_demo_abap_unit_tdf_testcl.clas.abap ├── ztcl_demo_abap_unit_tdf_testcl.clas.testclasses.abap └── ztcl_demo_abap_unit_tdf_testcl.clas.xml /.abapgit.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | E 6 | /src/ 7 | FULL 8 | 9 | /.gitignore 10 | /LICENSE 11 | /README.md 12 | /package.json 13 | /.travis.yml 14 | /.gitlab-ci.yml 15 | /abaplint.json 16 | /azure-pipelines.yml 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /09_Bits_and_Bytes.md: -------------------------------------------------------------------------------- 1 | # Excursion Down to Bits and Bytes 2 | 3 | This sheet goes a bit into the technical background of data types and 4 | data objects. It may be helpful for a better understanding of how to 5 | handle data in ABAP including a glance on casting and conversions. 6 | 7 | After its declaration, a [data 8 | object](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abendata_object_glosry.htm "Glossary Entry") 9 | is usable in its context (procedure, class, program) according to its 10 | type. For example, a numeric data object can be assigned the result of a 11 | calculation: 12 | 13 | 14 | > **💡 Note**
15 | > For checking out the code snippets in [ABAP Cloud](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabap_cloud_glosry.htm), you can use the interface `if_oo_adt_classrun` in a class by implementing the method `if_oo_adt_classrun~main`. 16 | 17 | ``` abap 18 | DATA num TYPE i. 19 | 20 | num = 2 * 3 * 5 * 53 * 2267. 21 | 22 | cl_demo_output=>display( num ). 23 | ``` 24 | 25 | After this assignment, the data object `num` contains the 26 | calculated value 3604530, which is also displayed accordingly with a 27 | type-compliant output as, for example, 28 | `cl_demo_output=>display`. And of course the same can be seen 29 | in the display of the variable in the ABAP Debugger when setting a 30 | breakpoint at the last statement. 31 | 32 | The ABAP Debugger also shows the hexadecimal value 32003700 of the data 33 | object. This directly represents the binary value `0011 0010 0000 0000 34 | 0011 0111 0000 0000` stored in the 4 bytes allocated to the 4-byte 35 | integer number in the memory. This value is platform dependent and for 36 | numeric types is defined by the [byte 37 | order](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenbyte_order_glosry.htm "Glossary Entry") 38 | order, where either the most significant (big endian) or least 39 | significant (little endian) byte is written to the first memory 40 | location. The decimal value of the hexadecimal value `32003700` shown here 41 | would be `838874880` and is not the integer value 42 | `3604530` that ABAP deals with. This shows the meaning of 43 | data types. A data object is a sequence of bytes stored in memory at its 44 | address, which is interpreted by the ABAP runtime framework according to 45 | the data type. The hexadecimal value is in most cases irrelevant to the 46 | programmer. 47 | 48 | Let us now consider a character-like field text with a length of two 49 | characters: 50 | 51 | ``` abap 52 | DATA text TYPE c LENGTH 2. 53 | 54 | text = '2' && '7'. 55 | 56 | cl_demo_output=>display( text ). 57 | ``` 58 | This field can be assigned the result of a string operation as shown and 59 | the result shown by `cl_demo_output=>display` as well as in 60 | the ABAP Debugger is the character string `27`. Again, it is 61 | the data type, that derives the value `27` from the actual hexadecimal 62 | content, which is `32003700` as in the previous example! In 63 | this case, `32003700` is the encoding of the string 64 | `27` in the Unicode character representation 65 | [UCS-2](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenucs2_glosry.htm "Glossary Entry"), 66 | which is supported by ABAP in Unicode systems. The Unicode character 67 | representation also depends on the platform-dependent byte order. 68 | 69 | Only for a byte-type data type does the value as interpreted by ABAP 70 | directly correspond to the hexadecimal content. The following lines 71 | modify the bits of a byte string with a bit-operation: 72 | 73 | ``` abap 74 | DATA hex TYPE x LENGTH 4 VALUE 'CDFFC8FF'. 75 | 76 | hex = BIT-NOT hex. 77 | 78 | cl_demo_output=>display( hex ). 79 | ``` 80 | 81 | Here, the output with `cl_demo_output=>display`, the value 82 | display of the ABAP Debugger as well as the hexadecimal value are the 83 | same, namely `32003700`. 84 | 85 | In the above examples, we presented three data objects that all occupy 4 86 | bytes in memory that have the same binary values, but are handled 87 | differently by ABAP due to their data type. The data type is also 88 | responsible for the fact, that different kind of operations (numeric 89 | calculation, string concatenation, bit-operation) can be applied to the 90 | respective data objects. Using these examples we can have now look at 91 | the basic concepts of 92 | [casting](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencast_casting_glosry.htm "Glossary Entry") 93 | and [type 94 | conversion](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abentype_conversion_glosry.htm "Glossary Entry") 95 | and their relation to bits and bytes. 96 | 97 | In ABAP, the term casting means nothing more than treating a data object 98 | according to a different data type than the one that is permanently 99 | assigned to it. This can be done using [field 100 | symbols](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenfield_symbol_glosry.htm "Glossary Entry"), 101 | with which a new (symbolic) name and a new type can be defined for the 102 | memory area of a data object. When the memory area is accessed using a 103 | field symbol, it is handled according to the type of the field symbol. 104 | The following lines show an example. 105 | 106 | ``` abap 107 | DATA hex TYPE x LENGTH 4 VALUE '32003700'. 108 | FIELD-SYMBOLS:   TYPE i, 109 |                TYPE c. 110 | ASSIGN hex TO   CASTING. 111 | ASSIGN hex TO CASTING. 112 | 113 | cl_demo_output=>new( 114 |   )->write_data( hex 115 |   )->write_data( 116 |   )->write_data( )->display( ). 117 | ``` 118 | 119 | The bit string in `hex` is cast to a numeric field when accessed 120 | using the name `` and to a text field when accessed using 121 | the name ``. The outputs are `32003700`, 122 | `3604530` and `27`, clearly showing the effect of 123 | the data type on handling one and the same hexadecimal content. 124 | 125 | In contrast, in a type conversion (or conversion for short), the actual 126 | binary content of a data object is converted so that it fits another 127 | data type. Type conversions usually occur in assignments between data 128 | objects of different data types. The goal of such a conversion is to 129 | preserve the type-specific meaning of the content in the source field as 130 | far as possible for the data type of the target field. For this purpose, 131 | ABAP contains a large set of [conversion 132 | rules](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenconversion_rules.htm). 133 | A simple example is shown here: 134 | 135 | ``` abap 136 | TYPES hex TYPE x LENGTH 4. 137 | FIELD-SYMBOLS: 138 |    TYPE hex, 139 |     TYPE hex. 140 | 141 | DATA: text TYPE c LENGTH 2 VALUE '27', 142 |       num  TYPE i. 143 | 144 | num = text. 145 | 146 | ASSIGN text TO CASTING. 147 | ASSIGN num  TO   CASTING. 148 | 149 | cl_demo_output=>new( 150 |   )->write_data( text 151 |   )->write_data( 152 |   )->write_data( num 153 |   )->write_data( )->display( ). 154 | ``` 155 | 156 | We are assigning the character-like field `text` to the numeric 157 | field `num` and display the result that can also be checked in 158 | the ABAP Debugger. The ABAP runtime framework recognizes that the 159 | character string `27` in text can be interpreted as the 160 | integer number `27`, generates the hexadecimal value 1B000000 161 | in which this number is encoded for the numeric type of `num`, 162 | and assigns it to the memory location of `num`. Thus, the actual 163 | conversion takes place for the original hexadecimal content 164 | `32003700` of `text` to the new hexadecimal content 165 | `1B000000` of `num`. For character strings in text 166 | fields, for which no such meaningful conversion is possible, an 167 | exception occurs. The field symbols `` and 168 | `` are used to show the hexadecimal content of the 169 | fields `text` and `num` by casting them to a byte-like 170 | type. 171 | 172 | > **✔️ Hint**
173 | > For reasons of simplicity this sheet is restricted to named elementary 174 | variables. Note that in particular the same holds for 175 | [literals](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabap_literal_glosry.htm "Glossary Entry") 176 | that are handled internally in such a way as if they were constants of 177 | the data type assigned to the literal. In the preceding example, 178 | `text` can be replaced by a literal `'27'` yielding 179 | the same results. 180 | 181 | 182 | -------------------------------------------------------------------------------- /11_Internal_Tables_Grouping.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Internal Tables: Grouping 4 | 5 | - [Internal Tables: Grouping](#internal-tables-grouping) 6 | - [Introduction](#introduction) 7 | - [Grouping by One Column](#grouping-by-one-column) 8 | - [Grouping by More than One Column](#grouping-by-more-than-one-column) 9 | - [Group Key Binding when Grouping by One Column](#group-key-binding-when-grouping-by-one-column) 10 | - [Group Key Binding when Grouping by More than One Column](#group-key-binding-when-grouping-by-more-than-one-column) 11 | - [Executable Example](#executable-example) 12 | 13 | 14 | ## Introduction 15 | 16 | Similar to SQL's [`GROUP BY`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapgroupby_clause.htm), 17 | there is also a [`GROUP BY`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaploop_at_itab_group_by.htm) 18 | for working with internal tables that can be used behind [`LOOP AT itab`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaploop_at_itab_variants.htm) 19 | or in the form [`IN GROUP`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenfor_in_group.htm) 20 | in a table iteration with 21 | [`FOR`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenfor_itab.htm). 22 | It replaces the clumsy group level processing with statements [`AT NEW ...`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapat_itab.htm) 23 | that relies on the order of table columns and content that is sorted 24 | respectively. 25 | 26 | Thi cheat sheet explains the grouping of internal tables step by step 27 | using a very simple case of an internal table `spfli_tab` that 28 | is filled with data from the database table `SPFLI`. The 29 | following steps show how the content of the internal table can be 30 | grouped using [`LOOP AT GROUP BY`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaploop_at_itab_group_by.htm). 31 | 32 | ## Grouping by One Column 33 | 34 | The simplest form of grouping is by one column without explicitly 35 | specifying the output behavior of the group loop: 36 | 37 | ``` abap 38 | LOOP AT spfli_tab INTO wa 39 |                   GROUP BY wa-carrid. 40 |        ... wa-carrid ... 41 | ENDLOOP. 42 | ``` 43 | 44 | Within the loop, there is access to the work area `wa`, in 45 | particular to the component `wa-carrid` that is used for 46 | grouping. The work area `wa` contains the first line of each 47 | group and represents the group in the loop. This is called 48 | representative binding. 49 | 50 | To access the members of a group, a member loop can be inserted into the 51 | group loop: 52 | ``` abap 53 | LOOP AT spfli_tab INTO wa 54 | GROUP BY wa-carrid. 55 |   ... 56 | LOOP AT GROUP wa INTO DATA(member). 57 |     ... member-... ... 58 | ENDLOOP. 59 |   ... 60 | ENDLOOP. 61 | ``` 62 | 63 | The member loop is executed using the group represented by `wa` 64 | and its members are assigned to `member` and are available in 65 | the member loop. 66 | 67 |

⬆️ back to top

68 | 69 | ## Grouping by More than One Column 70 | 71 | To group by more than just one criterion, a structured group key is 72 | defined as follows. In the simplest case, the grouping criteria are 73 | columns of the internal table: 74 | 75 | ``` abap 76 | LOOP AT spfli_tab INTO wa 77 | GROUP BY ( key1 = wa-carrid key2 = wa-airpfrom ). 78 |   ... wa-carrid ... wa-airpfrom ... 79 | ENDLOOP. 80 | ``` 81 | 82 | This is also a representative binding in which the work area 83 | `wa` is reused in the group loop to access the group key. 84 | 85 | To access the members of the groups, the exact same member loop can be 86 | inserted as when grouping by one column. 87 | 88 |

⬆️ back to top

89 | 90 | ## Group Key Binding when Grouping by One Column 91 | 92 | By explicitly specifying an [output 93 | area](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaploop_at_itab_group_by_binding.htm) 94 | for the group key, a group key binding can be defined explicitly instead 95 | of the representative binding in which the output area of the group loop 96 | is reused: 97 | 98 | ``` abap 99 | LOOP AT spfli_tab INTO wa 100 | GROUP BY wa-carrid 101 | INTO DATA(key). 102 |   ... key ... 103 | ENDLOOP. 104 | ``` 105 | 106 | The difference to the example with representative binding is the 107 | `INTO` addition after `GROUP BY`. Instead of reusing 108 | `wa`, an elementary data object `key` represents the 109 | group. This can be generated inline. The additions [`GROUP 110 | SIZE`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaploop_at_itab_group_by_key.htm), 111 | [`GROUP 112 | INDEX`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaploop_at_itab_group_by_key.htm), 113 | and [`WITHOUT 114 | MEMBERS`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaploop_at_itab_group_by.htm) 115 | can only be used in the group key binding, which gives it more functions 116 | than the representative binding. If these are not required, the 117 | representative binding can be used. The group key binding can also be 118 | used to make the use of the group key in the loop more explicit. 119 | 120 | Inserting a member loop works in the same way as in the representative 121 | binding, with the difference that a group is now addressed by 122 | `key` instead of `wa`. 123 | 124 | ``` abap 125 | LOOP AT spfli_tab INTO wa  126 | GROUP BY wa-carrid  127 | INTO key. 128 |   ... 129 | LOOP AT GROUP key INTO member. 130 |     ... members ... 131 | ENDLOOP. 132 |   ... 133 | ENDLOOP. 134 | ``` 135 | 136 |

⬆️ back to top

137 | 138 | ## Group Key Binding when Grouping by More than One Column 139 | Finally, the group key binding for structured group keys: 140 | 141 | ``` abap 142 | LOOP AT spfli_tab INTO wa 143 | GROUP BY ( key1 = wa-carrid key2 = wa-airpfrom ) 144 | INTO DATA(key). 145 |   ... key-key1 ... key-key2 ... 146 | ENDLOOP. 147 | ``` 148 | 149 | Here, `key` is a structure with the components `key1` 150 | and `key2`. A member loop can be inserted in exactly the same 151 | way as when grouping by one column. 152 | 153 | If the group members are not relevant, the addition [`WITHOUT MEMBERS`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaploop_at_itab_group_by.htm) 154 | can be used to save time and memory. 155 | 156 | ``` abap 157 | LOOP AT spfli_tab INTO wa 158 | GROUP BY ( key1 = wa-carrid key2 = wa-airpfrom 159 | index = GROUP INDEX size = GROUP SIZE ) 160 | WITHOUT MEMBERS 161 | INTO DATA(key). 162 |   ... key-key1 ... key-key2 ... key-index ... key-size ... 163 | ENDLOOP. 164 | ``` 165 | 166 | It is no longer possible to use a member loop here. Instead, the group 167 | key was enriched with optional components for further information using 168 | [`GROUP 169 | INDEX`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaploop_at_itab_group_by_key.htm) 170 | [`GROUP 171 | SIZE`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abaploop_at_itab_group_by_key.htm). 172 | 173 |

⬆️ back to top

174 | 175 | ## Executable Example 176 | 177 | [zcl_demo_abap_sql_group_by](./src/zcl_demo_abap_sql_group_by.clas.abap) 178 | 179 | > **💡 Note**
180 | > - The steps to import and run the code are outlined [here](README.md#-getting-started-with-the-examples). 181 | > - [Disclaimer](./README.md#%EF%B8%8F-disclaimer) -------------------------------------------------------------------------------- /15_CDS_View_Entities.md: -------------------------------------------------------------------------------- 1 | # CDS View Entities 2 | 3 | - [CDS View Entities](#cds-view-entities) 4 | - [A Glimpse on the CDS Syntax](#a-glimpse-on-the-cds-syntax) 5 | - [More Information](#more-information) 6 | - [Executable Example](#executable-example) 7 | 8 | Core data services (CDS) are an infrastructure for defining and consuming semantically rich data models on the [standard database](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenstandard_db_glosry.htm) of an [AS ABAP](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenas_abap_glosry.htm). 9 | 10 | > **💡 Note**
11 | > - The executable example focuses on CDS view entities and covers a selection of features. 12 | > - The sample CDS view entities are designed to demonstrate a selection of features with a limited number of artifacts. They are not intended to be role models for proper CDS view design. They focus on syntax options only. They are not intended to solve concrete programming tasks. You should always work out your own solution for each individual case. For more detailed information, refer to the links in the [More Information](#more-information) section. 13 | > - The [ABAP Dictionary](26_ABAP_Dictionary.md) cheat sheet highlights that several [CDS entities](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencds_entity_glosry.htm) - apart from CDS view entities - represent structured types that are usable in ABAP. 14 | 15 | ## A Glimpse on the CDS Syntax 16 | The following links take you to the source code of the cheat sheet artifacts to get a glimpse on the syntax used. To explore the syntax in action, import the ABAP cheat sheet repository into your system. 17 | 18 | - [zdemo_abap_cds_ve_sel](src/zdemo_abap_cds_ve_sel.ddls.asddls) 19 | - Input parameters 20 | - Specifying fields of the data source 21 | - Typed and untyped literals 22 | - Session variables 23 | - Multiple expressions: 24 | - Cast expressions 25 | - Reuse expressions 26 | - Arithmetic expressions 27 | - Case expressions 28 | - Logical expressions 29 | - Built-in functions 30 | - Numeric functions 31 | - String functions 32 | - Coalesce function 33 | - Date and time functions 34 | - [zdemo_abap_cds_ve_agg_exp](src/zdemo_abap_cds_ve_agg_exp.ddls.asddls) 35 | - Aggregate expressions 36 | - [zdemo_abap_cds_ve_joins](src/zdemo_abap_cds_ve_joins.ddls.asddls) 37 | - Inner joins 38 | - Left outer joins 39 | - Right outer joins 40 | - Cross joins 41 | - [zdemo_abap_cds_ve_assoc](src/zdemo_abap_cds_ve_assoc.ddls.asddls) 42 | - Associations 43 | 44 | ## More Information 45 | 46 | - [ABAP Data Models Guide](https://help.sap.com/docs/abap-cloud/abap-data-models/abap-data-models) 47 | - [ABAP Core Data Services in the ABAP Keyword Documentation](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencds.htm) 48 | - [ABAP CDS Development Tools: User Guide](https://help.sap.com/docs/abap-cloud/abap-cds-tools-user-guide/about-abap-cds-development-tools-user-guide?version=sap_btp) 49 | - [ABAP CDS Feature Tables](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencds_language_elements.htm) 50 | - [ABAP CDS Glossary](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencds_glossary.htm) 51 | - [ABAP CDS - SAP Annotation Documentation](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencds_annotations_ktd_docu.htm) 52 | - Blogs: 53 | - [Feature Matrix: Data Modeling with ABAP Core Data Services](https://blogs.sap.com/2022/10/24/feature-matrix-data-modeling-with-abap-core-data-services/) 54 | - [ABAP CDS Cheat Sheet: Amounts and Quantities in ABAP CDS](https://blogs.sap.com/2022/07/07/abap-cds-cheat-sheet-amounts-and-quantities-in-abap-cds/) 55 | 56 | 57 | ## Executable Example 58 | 59 | [zcl_demo_abap_cds_ve](./src/zcl_demo_abap_cds_ve.clas.abap) 60 | 61 | > **💡 Note**
62 | > - The executable example covers the following topics: 63 | > - Operands, expressions, built-in functions, and input parameters in CDS view entities 64 | > - Selecting data from CDS view entities using ABAP SQL `SELECT` statements 65 | > - Joins 66 | > - Note: A sample CDS view entity contains multiple joins. You can comment in/out code sections to see the effect. See the notes in the view. 67 | > - Excursion: Joins in ABAP SQL 68 | > - Associations 69 | > - Defining views with associations 70 | > - Exposing associations 71 | > - Using exposed associations in ABAP statements 72 | > - The example CDS view entities (`zdemo_abap_cds_ve...`) and the [class](./src/zcl_demo_abap_cds_ve.clas.abap) contains comments in the code for more information. 73 | > - The steps to import and run the code are outlined [here](README.md#-getting-started-with-the-examples). 74 | > - [Disclaimer](./README.md#%EF%B8%8F-disclaimer) -------------------------------------------------------------------------------- /LICENSES/Apache-2.0.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. 10 | 11 | "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. 12 | 13 | "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 14 | 15 | "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. 16 | 17 | "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. 18 | 19 | "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. 20 | 21 | "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). 22 | 23 | "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. 24 | 25 | "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." 26 | 27 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 28 | 29 | 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 30 | 31 | 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 32 | 33 | 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: 34 | 35 | (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and 36 | 37 | (b) You must cause any modified files to carry prominent notices stating that You changed the files; and 38 | 39 | (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and 40 | 41 | (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. 42 | 43 | You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 44 | 45 | 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 46 | 47 | 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 48 | 49 | 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 50 | 51 | 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 52 | 53 | 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. 54 | 55 | END OF TERMS AND CONDITIONS 56 | 57 | APPENDIX: How to apply the Apache License to your work. 58 | 59 | To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. 60 | 61 | Copyright [yyyy] [name of copyright owner] 62 | 63 | Licensed under the Apache License, Version 2.0 (the "License"); 64 | you may not use this file except in compliance with the License. 65 | You may obtain a copy of the License at 66 | 67 | http://www.apache.org/licenses/LICENSE-2.0 68 | 69 | Unless required by applicable law or agreed to in writing, software 70 | distributed under the License is distributed on an "AS IS" BASIS, 71 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 72 | See the License for the specific language governing permissions and 73 | limitations under the License. 74 | -------------------------------------------------------------------------------- /REUSE.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | SPDX-PackageName = "abap-cheat-sheets" 3 | SPDX-PackageSupplier = "" 4 | SPDX-PackageDownloadLocation = "https://github.com/SAP-samples/abap-cheat-sheets" 5 | SPDX-PackageComment = "The code in this project may include calls to APIs (\"API Calls\") of\n SAP or third-party products or services developed outside of this project\n (\"External Products\").\n \"APIs\" means application programming interfaces, as well as their respective\n specifications and implementing code that allows software to communicate with\n other software.\n API Calls to External Products are not licensed under the open source license\n that governs this project. The use of such API Calls and related External\n Products are subject to applicable additional agreements with the relevant\n provider of the External Products. In no event shall the open source license\n that governs this project grant any rights in or to any External Products,or\n alter, expand or supersede any terms of the applicable additional agreements.\n If you have a valid license agreement with SAP for the use of a particular SAP\n External Product, then you may make use of any API Calls included in this\n project's code for that SAP External Product, subject to the terms of such\n license agreement. If you do not have a valid license agreement for the use of\n a particular SAP External Product, then you may only make use of any API Calls\n in this project for that SAP External Product for your internal, non-productive\n and non-commercial test and evaluation of such API Calls. Nothing herein grants\n you any rights to use or access any SAP External Product, or provide any third\n parties the right to use of access any SAP External Product, through API Calls." 6 | 7 | [[annotations]] 8 | path = "**" 9 | precedence = "aggregate" 10 | SPDX-FileCopyrightText = "2022 SAP SE or an SAP affiliate company and abap-cheat-sheets contributors" 11 | SPDX-License-Identifier = "Apache-2.0" 12 | -------------------------------------------------------------------------------- /files/ABAP_Keyword_Documentation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/abap-cheat-sheets/dadf4de59c64848cb40fa34f415103999ced7ad2/files/ABAP_Keyword_Documentation.png -------------------------------------------------------------------------------- /files/abapGit_Repositories.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/abap-cheat-sheets/dadf4de59c64848cb40fa34f415103999ced7ad2/files/abapGit_Repositories.png -------------------------------------------------------------------------------- /files/bdef_derived_type_components.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/abap-cheat-sheets/dadf4de59c64848cb40fa34f415103999ced7ad2/files/bdef_derived_type_components.png -------------------------------------------------------------------------------- /files/bdef_derived_types.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/abap-cheat-sheets/dadf4de59c64848cb40fa34f415103999ced7ad2/files/bdef_derived_types.png -------------------------------------------------------------------------------- /files/example_topics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/abap-cheat-sheets/dadf4de59c64848cb40fa34f415103999ced7ad2/files/example_topics.png -------------------------------------------------------------------------------- /files/phases_of_rap_luw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/abap-cheat-sheets/dadf4de59c64848cb40fa34f415103999ced7ad2/files/phases_of_rap_luw.png -------------------------------------------------------------------------------- /files/rap_handler_method_parameters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/abap-cheat-sheets/dadf4de59c64848cb40fa34f415103999ced7ad2/files/rap_handler_method_parameters.png -------------------------------------------------------------------------------- /files/release_contract.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/abap-cheat-sheets/dadf4de59c64848cb40fa34f415103999ced7ad2/files/release_contract.png -------------------------------------------------------------------------------- /files/released_APIs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/abap-cheat-sheets/dadf4de59c64848cb40fa34f415103999ced7ad2/files/released_APIs.png -------------------------------------------------------------------------------- /files/standard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/abap-cheat-sheets/dadf4de59c64848cb40fa34f415103999ced7ad2/files/standard.png -------------------------------------------------------------------------------- /src/ezdemo_abap_lock.enqu.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | EZDEMO_ABAP_LOCK 7 | E 8 | E 9 | ZDEMO_ABAP_RAPT1 10 | Lock on demo table 11 | 5 12 | 13 | 14 | 15 | EZDEMO_ABAP_LOCK 16 | ZDEMO_ABAP_RAPT1 17 | 0001 18 | ZDEMO_ABAP_RAPT1 19 | E 20 | 21 | 22 | 23 | 24 | EZDEMO_ABAP_LOCK 25 | 0001 26 | CLIENT 27 | ZDEMO_ABAP_RAPT1 28 | CLIENT 29 | X 30 | E 31 | 32 | 33 | EZDEMO_ABAP_LOCK 34 | 0002 35 | KEY_FIELD 36 | ZDEMO_ABAP_RAPT1 37 | KEY_FIELD 38 | X 39 | E 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/package.devc.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ABAP Cheat Sheets 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/zbp_demo_abap_rap_draft_m.clas.abap: -------------------------------------------------------------------------------- 1 | "!

RAP BO provider for a RAP demo scenario
ABAP cheat sheet example class

2 | "! 3 | "!

The class represents a RAP BO provider (i. e. an ABAP behavior pool/ABP) for a RAP demo scenario:
4 | "! Managed, draft-enabled RAP BO with late numbering.

5 | CLASS zbp_demo_abap_rap_draft_m DEFINITION PUBLIC ABSTRACT FINAL FOR BEHAVIOR OF zdemo_abap_rap_draft_m. 6 | PROTECTED SECTION. 7 | PRIVATE SECTION. 8 | ENDCLASS. 9 | 10 | 11 | 12 | CLASS zbp_demo_abap_rap_draft_m IMPLEMENTATION. 13 | ENDCLASS. 14 | -------------------------------------------------------------------------------- /src/zbp_demo_abap_rap_draft_m.clas.locals_imp.abap: -------------------------------------------------------------------------------- 1 | *********************************************************************** 2 | * 3 | * RAP BO provider (i. e. ABAP behavior pool/ABP) 4 | * for a RAP demo scenario 5 | * 6 | * - RAP scenario: "RAP calculator" (managed, draft-enabled RAP BO with 7 | * late numbering) 8 | * - Data model: Consists of a root entity alone. 9 | * The BDEF defines the behavior for this entity. The definitions in the 10 | * BDEF determine which methods must be implemented in the ABAP behavior 11 | * pool (ABP). Note that the view contains many annotations for the 12 | * SAP Fiori UI. 13 | * 14 | * ----------------------------- NOTE ----------------------------------- 15 | * This simplified example is not a real life scenario and rather 16 | * focuses on the technical side by giving an idea how the communication 17 | * and data exchange between a RAP BO consumer, which is a class 18 | * in this case, and RAP BO provider can work. Additionally, it shows 19 | * how the methods for non-standard RAP BO operations might be 20 | * self-implemented in an ABP. The example is intentionally kept 21 | * short and simple and focuses on specific RAP aspects. For this reason, 22 | * the example might not fully meet the requirements of the RAP BO contract. 23 | * 24 | * You can also use side effects to trigger data 25 | * changes (in terms of this example, the recalculation of the calculation 26 | * result) and other things based on data changes in UI scenarios with 27 | * draft-enabled BOs. 28 | * 29 | * The code presented in this class is intended only to support the ABAP 30 | * cheat sheets. It is not intended for direct use in a production system 31 | * environment. The code examples in the ABAP cheat sheets are primarily 32 | * intended to provide a better explanation and visualization of the 33 | * syntax and semantics of ABAP statements, not to solve concrete 34 | * programming tasks. For production application programs, you should 35 | * always work out your own solution for each individual case. There is 36 | * no guarantee for the correctness or completeness of the code. 37 | * Furthermore, there is no legal responsibility or liability for any 38 | * errors or their consequences that may occur when using the the example 39 | * code. 40 | * 41 | *********************************************************************** 42 | 43 | CLASS lhc_calc DEFINITION INHERITING FROM cl_abap_behavior_handler. 44 | PRIVATE SECTION. 45 | 46 | METHODS delete_all FOR MODIFY 47 | IMPORTING keys FOR ACTION calc~delete_all. 48 | 49 | METHODS get_global_authorizations FOR GLOBAL AUTHORIZATION 50 | IMPORTING REQUEST requested_authorizations FOR calc RESULT result. 51 | 52 | METHODS validate FOR VALIDATE ON SAVE 53 | IMPORTING keys FOR calc~validate. 54 | 55 | METHODS det_modify FOR DETERMINE ON MODIFY 56 | IMPORTING keys FOR calc~det_modify. 57 | 58 | METHODS calculation FOR MODIFY 59 | IMPORTING keys FOR ACTION calc~calculation. 60 | 61 | ENDCLASS. 62 | 63 | CLASS lhc_calc IMPLEMENTATION. 64 | 65 | METHOD delete_all. 66 | "Purpose: The method deletes all persisted database entries. 67 | 68 | DATA all_keys TYPE TABLE FOR DELETE zdemo_abap_rap_draft_m. 69 | 70 | SELECT id FROM zdemo_abap_tabca INTO CORRESPONDING FIELDS OF TABLE @all_keys. 71 | 72 | READ ENTITIES OF zdemo_abap_rap_draft_m IN LOCAL MODE 73 | ENTITY calc 74 | ALL FIELDS WITH CORRESPONDING #( all_keys ) 75 | RESULT DATA(lt_del). 76 | 77 | IF lt_del IS NOT INITIAL. 78 | 79 | MODIFY ENTITY IN LOCAL MODE zdemo_abap_rap_draft_m 80 | DELETE FROM CORRESPONDING #( lt_del ). 81 | 82 | APPEND VALUE #( %msg = new_message_with_text( text = 'All persisted calculations were deleted.' 83 | severity = if_abap_behv_message=>severity-information ) 84 | ) TO reported-calc. 85 | 86 | ELSE. 87 | APPEND VALUE #( %msg = new_message_with_text( text = 'No persisted calculations available.' 88 | severity = if_abap_behv_message=>severity-information ) 89 | ) TO reported-calc. 90 | 91 | ENDIF. 92 | 93 | ENDMETHOD. 94 | 95 | METHOD get_global_authorizations. 96 | "Purposely kept without implementation. 97 | ENDMETHOD. 98 | 99 | METHOD validate. 100 | 101 | "Retrieving instances based on requested keys 102 | READ ENTITIES OF zdemo_abap_rap_draft_m IN LOCAL MODE 103 | ENTITY calc 104 | ALL FIELDS 105 | WITH CORRESPONDING #( keys ) 106 | RESULT DATA(result_validate) 107 | FAILED DATA(f). 108 | 109 | CHECK result_validate IS NOT INITIAL. 110 | 111 | "Various calculation errors are handled. 112 | LOOP AT result_validate ASSIGNING FIELD-SYMBOL(). 113 | 114 | APPEND VALUE #( %tky = -%tky 115 | %state_area = 'VALIDATE_CALCULATION' 116 | ) TO reported-calc. 117 | 118 | IF -calc_result = `Wrong operator`. 119 | APPEND VALUE #( %tky = -%tky ) TO failed-calc. 120 | 121 | APPEND VALUE #( %tky = -%tky 122 | %state_area = 'VALIDATE_CALCULATION' 123 | %msg = new_message_with_text( text = 'Only + - * / P allowed as operators.' 124 | severity = if_abap_behv_message=>severity-error ) 125 | "%element highlights the input field 126 | %element-arithm_op = if_abap_behv=>mk-on 127 | ) TO reported-calc. 128 | 129 | ELSEIF -calc_result = `Division by 0`. 130 | 131 | APPEND VALUE #( %tky = -%tky ) TO failed-calc. 132 | 133 | APPEND VALUE #( %tky = -%tky 134 | %state_area = 'VALIDATE_CALCULATION' 135 | %msg = new_message_with_text( text = 'Zero division not possible.' 136 | severity = if_abap_behv_message=>severity-error ) 137 | %element-arithm_op = if_abap_behv=>mk-on 138 | %element-num2 = if_abap_behv=>mk-on 139 | ) TO reported-calc. 140 | 141 | ELSEIF -calc_result = `Overflow error`. 142 | 143 | APPEND VALUE #( %tky = -%tky ) TO failed-calc. 144 | 145 | APPEND VALUE #( %tky = -%tky 146 | %state_area = 'VALIDATE_CALCULATION' 147 | %msg = new_message_with_text( text = 'Check the numbers. Try smaller ones.' 148 | severity = if_abap_behv_message=>severity-error ) 149 | %element-num1 = if_abap_behv=>mk-on 150 | %element-num2 = if_abap_behv=>mk-on 151 | ) TO reported-calc. 152 | ENDIF. 153 | 154 | ENDLOOP. 155 | 156 | ENDMETHOD. 157 | 158 | METHOD det_modify. 159 | 160 | MODIFY ENTITIES OF zdemo_abap_rap_draft_m IN LOCAL MODE 161 | ENTITY calc 162 | EXECUTE calculation 163 | FROM CORRESPONDING #( keys ). 164 | 165 | ENDMETHOD. 166 | 167 | METHOD calculation. 168 | 169 | READ ENTITIES OF zdemo_abap_rap_draft_m IN LOCAL MODE 170 | ENTITY calc 171 | FIELDS ( num1 num2 arithm_op ) WITH CORRESPONDING #( keys ) 172 | RESULT DATA(lt_calc) 173 | FAILED DATA(f). 174 | 175 | LOOP AT lt_calc ASSIGNING FIELD-SYMBOL(). 176 | 177 | TRY. 178 | -calc_result = SWITCH #( -arithm_op 179 | WHEN `+` THEN -num1 + -num2 180 | WHEN `-` THEN -num1 - -num2 181 | WHEN `*` THEN -num1 * -num2 182 | WHEN `/` THEN -num1 / -num2 183 | WHEN `P` THEN ipow( base = -num1 exp = -num2 ) 184 | ELSE `Wrong operator` ). 185 | "Bringing "-" to the front in case of negative values in the string 186 | IF -calc_result CA `-`. 187 | -calc_result = shift_right( val = -calc_result circular = 1 ). 188 | ENDIF. 189 | 190 | "Removing trailing .0 from the string 191 | REPLACE PCRE `\.0+\b` IN -calc_result WITH ``. 192 | 193 | "Handling the fact that ABAP allows division by zero if the dividend itself is zero. 194 | IF -num1 = 0 AND -num2 = 0 AND -arithm_op = `/`. 195 | -calc_result = `Division by 0`. 196 | ENDIF. 197 | 198 | CATCH cx_sy_zerodivide. 199 | -calc_result = `Division by 0`. 200 | 201 | CATCH cx_sy_arithmetic_overflow. 202 | -calc_result = `Overflow error`. 203 | 204 | ENDTRY. 205 | 206 | ENDLOOP. 207 | 208 | MODIFY ENTITY IN LOCAL MODE zdemo_abap_rap_draft_m 209 | UPDATE FIELDS ( calc_result ) 210 | WITH CORRESPONDING #( lt_calc ). 211 | 212 | ENDMETHOD. 213 | 214 | ENDCLASS. 215 | 216 | CLASS lsc_zdemo_abap_rap_draft_m DEFINITION INHERITING FROM cl_abap_behavior_saver. 217 | PROTECTED SECTION. 218 | 219 | METHODS adjust_numbers REDEFINITION. 220 | 221 | ENDCLASS. 222 | 223 | CLASS lsc_zdemo_abap_rap_draft_m IMPLEMENTATION. 224 | 225 | METHOD adjust_numbers. 226 | 227 | "The newly created entity instances are given their final key 228 | "only shortly before saving in the database in the adjust_numbers method. 229 | "Until then, the business logic uses a temporary key that has to be replaced. 230 | "In this very simplified example, the key 'id' is purposely typed with the 231 | "type sysuuid_x16 which can accept the value used in %pid to finally ensure 232 | "that there is a unique key and the instance can be stored in the database. 233 | "Hence, the final key 'id' is in this example just the value used for %pid. 234 | LOOP AT mapped-calc ASSIGNING FIELD-SYMBOL(). 235 | -%key-id = -%pid. 236 | ENDLOOP. 237 | 238 | ENDMETHOD. 239 | 240 | ENDCLASS. 241 | -------------------------------------------------------------------------------- /src/zbp_demo_abap_rap_draft_m.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZBP_DEMO_ABAP_RAP_DRAFT_M 7 | E 8 | Behavior implementation for RAP demo scenario (draft BO) 9 | 06 10 | 1 11 | X 12 | X 13 | X 14 | ZDEMO_ABAP_RAP_DRAFT_M 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/zbp_demo_abap_rap_ro_m.clas.abap: -------------------------------------------------------------------------------- 1 | "!

RAP BO provider for a RAP demo scenario
ABAP cheat sheet example class

2 | "! 3 | "!

The class represents a RAP BO provider (i. e. an ABAP behavior pool/ABP) for a RAP demo scenario:
4 | "! Managed RAP BO with external numbering.

5 | CLASS zbp_demo_abap_rap_ro_m DEFINITION PUBLIC ABSTRACT FINAL FOR BEHAVIOR OF zdemo_abap_rap_ro_m. 6 | PROTECTED SECTION. 7 | PRIVATE SECTION. 8 | ENDCLASS. 9 | 10 | 11 | 12 | CLASS zbp_demo_abap_rap_ro_m IMPLEMENTATION. 13 | ENDCLASS. 14 | -------------------------------------------------------------------------------- /src/zbp_demo_abap_rap_ro_m.clas.locals_imp.abap: -------------------------------------------------------------------------------- 1 | *********************************************************************** 2 | * 3 | * RAP BO provider (i. e. ABAP behavior pool/ABP) 4 | * for a RAP demo scenario 5 | * 6 | * - RAP scenario: managed RAP BO, external numbering 7 | * - Data model: Consists of a root entity and one child entity. The BDEF 8 | * defines the behavior for these two entities which are connected via 9 | * a CDS composition relation. The definitions in the BDEF determine 10 | * which methods must be implemented in this ABAP behavior pool (ABP). 11 | * 12 | * ----------------------------- NOTE ----------------------------------- 13 | * This simplified example is not a real life scenario and rather 14 | * focuses on the technical side by giving an idea how the communication 15 | * and data exchange between a RAP BO consumer, which is a class 16 | * in this case, and RAP BO provider can work. Additionally, it shows 17 | * how the methods for non-standard RAP BO operations might be 18 | * self-implemented in an ABP. The example is is intentionally kept 19 | * short and simple and focuses on specific RAP aspects. For this reason, 20 | * the example might not fully meet the requirements of the RAP BO contract. 21 | * 22 | * The code presented in this class is intended only to support the ABAP 23 | * cheat sheets. It is not intended for direct use in a production system 24 | * environment. The code examples in the ABAP cheat sheets are primarily 25 | * intended to provide a better explanation and visualization of the 26 | * syntax and semantics of ABAP statements, not to solve concrete 27 | * programming tasks. For production application programs, you should 28 | * always work out your own solution for each individual case. There is 29 | * no guarantee for the correctness or completeness of the code. 30 | * Furthermore, there is no legal responsibility or liability for any 31 | * errors or their consequences that may occur when using the the example 32 | * code. 33 | * 34 | *********************************************************************** 35 | 36 | CLASS lhc_root DEFINITION INHERITING FROM cl_abap_behavior_handler. 37 | PRIVATE SECTION. 38 | 39 | METHODS get_global_authorizations FOR GLOBAL AUTHORIZATION 40 | IMPORTING REQUEST requested_authorizations FOR root RESULT result. 41 | 42 | METHODS multiply_by_2 FOR MODIFY 43 | IMPORTING keys FOR ACTION root~multiply_by_2. 44 | 45 | METHODS det_add_text FOR DETERMINE ON SAVE 46 | IMPORTING keys FOR root~det_add_text. 47 | 48 | METHODS val FOR VALIDATE ON SAVE 49 | IMPORTING keys FOR root~val. 50 | 51 | ENDCLASS. 52 | 53 | CLASS lhc_root IMPLEMENTATION. 54 | 55 | METHOD get_global_authorizations. 56 | ENDMETHOD. 57 | 58 | METHOD multiply_by_2. 59 | 60 | "Retrieving instances based on requested keys 61 | READ ENTITIES OF zdemo_abap_rap_ro_m IN LOCAL MODE 62 | ENTITY root 63 | FIELDS ( field3 field4 ) WITH CORRESPONDING #( keys ) 64 | RESULT DATA(result) 65 | FAILED failed. 66 | 67 | "If read result is initial, stop further method execution. 68 | CHECK result IS NOT INITIAL. 69 | 70 | "Multiply integer values by 2 71 | MODIFY ENTITIES OF zdemo_abap_rap_ro_m IN LOCAL MODE 72 | ENTITY root 73 | UPDATE FIELDS ( field3 field4 ) WITH VALUE #( FOR key IN result ( %tky = key-%tky 74 | field3 = key-field3 * 2 75 | field4 = key-field4 * 2 ) ). 76 | ENDMETHOD. 77 | 78 | METHOD det_add_text. 79 | 80 | READ ENTITIES OF zdemo_abap_rap_ro_m IN LOCAL MODE 81 | ENTITY root 82 | FIELDS ( field2 ) WITH CORRESPONDING #( keys ) 83 | RESULT DATA(lt_res). 84 | 85 | "If read result is initial, stop further method execution. 86 | CHECK lt_res IS NOT INITIAL. 87 | 88 | "field2 is changed 89 | MODIFY ENTITIES OF zdemo_abap_rap_ro_m IN LOCAL MODE 90 | ENTITY root 91 | UPDATE FIELDS ( field2 ) 92 | WITH VALUE #( FOR key IN lt_res ( %tky = key-%tky 93 | field2 = |{ key-field2 }_#| ) ). 94 | 95 | ENDMETHOD. 96 | 97 | METHOD val. 98 | 99 | READ ENTITIES OF zdemo_abap_rap_ro_m IN LOCAL MODE 100 | ENTITY root 101 | FIELDS ( field3 ) WITH CORRESPONDING #( keys ) 102 | RESULT DATA(lt_res). 103 | 104 | "If read result is initial, stop further method execution. 105 | CHECK lt_res IS NOT INITIAL. 106 | 107 | LOOP AT lt_res ASSIGNING FIELD-SYMBOL(). 108 | IF -field3 > 1000. 109 | APPEND VALUE #( %tky = -%tky 110 | %fail-cause = if_abap_behv=>cause-unspecific 111 | ) 112 | TO failed-root. 113 | 114 | APPEND VALUE #( %tky = -%tky 115 | %msg = new_message_with_text( 116 | severity = if_abap_behv_message=>severity-error 117 | text = 'Validation failed!' ) 118 | ) TO reported-root. 119 | ENDIF. 120 | ENDLOOP. 121 | 122 | ENDMETHOD. 123 | 124 | ENDCLASS. 125 | -------------------------------------------------------------------------------- /src/zbp_demo_abap_rap_ro_m.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZBP_DEMO_ABAP_RAP_RO_M 7 | E 8 | Behavior implementation for RAP demo scenario (managed BO) 9 | 06 10 | 1 11 | X 12 | X 13 | X 14 | ZDEMO_ABAP_RAP_RO_M 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/zbp_demo_abap_rap_ro_m_as.clas.abap: -------------------------------------------------------------------------------- 1 | "!

RAP BO provider for a RAP demo scenario
ABAP cheat sheet example class

2 | "! 3 | "!

The class represents a RAP BO provider (i. e. an ABAP behavior pool/ABP) for a RAP demo scenario:
4 | "! Managed RAP BO with managed internal numbering and additional save, demonstrating the local consumption 5 | "! of RAP business events.

6 | CLASS zbp_demo_abap_rap_ro_m_as DEFINITION PUBLIC ABSTRACT FINAL FOR BEHAVIOR OF zdemo_abap_rap_ro_m_as. 7 | PUBLIC SECTION. 8 | CLASS-DATA num_raised_events TYPE i. 9 | ENDCLASS. 10 | 11 | CLASS zbp_demo_abap_rap_ro_m_as IMPLEMENTATION. 12 | ENDCLASS. 13 | -------------------------------------------------------------------------------- /src/zbp_demo_abap_rap_ro_m_as.clas.locals_imp.abap: -------------------------------------------------------------------------------- 1 | CLASS lhc_zdemo_abap_rap_ro_m_as DEFINITION INHERITING FROM cl_abap_behavior_handler. 2 | PRIVATE SECTION. 3 | 4 | METHODS get_global_authorizations FOR GLOBAL AUTHORIZATION 5 | IMPORTING REQUEST requested_authorizations FOR root RESULT result. 6 | 7 | METHODS calc FOR MODIFY 8 | IMPORTING keys FOR ACTION root~calc. 9 | 10 | METHODS det_modify FOR DETERMINE ON MODIFY 11 | IMPORTING keys FOR root~det_modify. 12 | 13 | ENDCLASS. 14 | 15 | CLASS lhc_zdemo_abap_rap_ro_m_as IMPLEMENTATION. 16 | 17 | METHOD get_global_authorizations. 18 | ENDMETHOD. 19 | 20 | METHOD calc. 21 | READ ENTITY IN LOCAL MODE zdemo_abap_rap_ro_m_as 22 | FIELDS ( num1 num2 arithm_op crea_date_time lchg_date_time ) WITH CORRESPONDING #( keys ) 23 | RESULT DATA(lt_calc) 24 | FAILED DATA(f). 25 | 26 | DATA(timestamp) = cl_abap_tstmp=>utclong2tstmp( utclong_current( ) ). 27 | 28 | LOOP AT lt_calc ASSIGNING FIELD-SYMBOL(). 29 | TRY. 30 | -calc_result = SWITCH #( -arithm_op 31 | WHEN `+` THEN |{ CONV decfloat34( -num1 + -num2 ) STYLE = SIMPLE }| 32 | WHEN `-` THEN |{ CONV decfloat34( -num1 - -num2 ) STYLE = SIMPLE }| 33 | WHEN `*` THEN |{ CONV decfloat34( -num1 * -num2 ) STYLE = SIMPLE }| 34 | WHEN `/` THEN |{ CONV decfloat34( -num1 / -num2 ) STYLE = SIMPLE }| 35 | WHEN `P` THEN |{ CONV decfloat34( ipow( base = -num1 exp = -num2 ) ) STYLE = SIMPLE }| 36 | ELSE `Wrong operator` ). 37 | 38 | "Handling the fact that ABAP allows division by zero if the dividend itself is zero. 39 | IF -num1 = 0 AND -num2 = 0 AND -arithm_op = `/`. 40 | -calc_result = `Division by 0`. 41 | ENDIF. 42 | CATCH cx_sy_zerodivide. 43 | -calc_result = `Division by 0`. 44 | CATCH cx_sy_arithmetic_overflow. 45 | -calc_result = `Overflow error`. 46 | ENDTRY. 47 | ENDLOOP. 48 | 49 | MODIFY ENTITY IN LOCAL MODE zdemo_abap_rap_ro_m_as 50 | UPDATE FIELDS ( calc_result ) 51 | WITH CORRESPONDING #( lt_calc ). 52 | ENDMETHOD. 53 | 54 | METHOD det_modify. 55 | MODIFY ENTITY IN LOCAL MODE zdemo_abap_rap_ro_m_as 56 | EXECUTE calc 57 | FROM CORRESPONDING #( keys ). 58 | ENDMETHOD. 59 | 60 | ENDCLASS. 61 | 62 | CLASS lsc_zdemo_abap_rap_ro_m_as DEFINITION INHERITING FROM cl_abap_behavior_saver. 63 | PROTECTED SECTION. 64 | 65 | METHODS save_modified REDEFINITION. 66 | 67 | METHODS cleanup_finalize REDEFINITION. 68 | 69 | ENDCLASS. 70 | 71 | CLASS lsc_zdemo_abap_rap_ro_m_as IMPLEMENTATION. 72 | 73 | METHOD save_modified. 74 | IF create-root IS NOT INITIAL. 75 | RAISE ENTITY EVENT zdemo_abap_rap_ro_m_as~created 76 | FROM VALUE #( FOR IN create-root ( 77 | %key = VALUE #( id = -id ) ) ). 78 | 79 | zbp_demo_abap_rap_ro_m_as=>num_raised_events = zbp_demo_abap_rap_ro_m_as=>num_raised_events + lines( create-root ). 80 | ENDIF. 81 | 82 | IF update-root IS NOT INITIAL. 83 | "Demonstrating the BDEF derived type TYPE TABLE FOR EVENT 84 | DATA evt_tab_up TYPE TABLE FOR EVENT zdemo_abap_rap_ro_m_as~updated. 85 | 86 | evt_tab_up = VALUE #( FOR IN update-root INDEX INTO updidx ( 87 | %key = VALUE #( id = -id ) 88 | %param = VALUE #( col1 = 'Event raised' 89 | col2 = |UPDATED ({ updidx })| ) ) ). 90 | RAISE ENTITY EVENT zdemo_abap_rap_ro_m_as~updated FROM evt_tab_up. 91 | 92 | zbp_demo_abap_rap_ro_m_as=>num_raised_events = zbp_demo_abap_rap_ro_m_as=>num_raised_events + lines( update-root ). 93 | ENDIF. 94 | 95 | IF delete-root IS NOT INITIAL. 96 | RAISE ENTITY EVENT zdemo_abap_rap_ro_m_as~deleted 97 | FROM VALUE #( FOR IN delete-root INDEX INTO delidx ( 98 | %key = VALUE #( id = -id ) 99 | %param = VALUE #( col1 = 'Event raised' 100 | col2 = |DELETED ({ delidx })| ) ) ). 101 | 102 | zbp_demo_abap_rap_ro_m_as=>num_raised_events = zbp_demo_abap_rap_ro_m_as=>num_raised_events + lines( delete-root ). 103 | ENDIF. 104 | ENDMETHOD. 105 | 106 | METHOD cleanup_finalize. 107 | ENDMETHOD. 108 | 109 | ENDCLASS. 110 | -------------------------------------------------------------------------------- /src/zbp_demo_abap_rap_ro_m_as.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZBP_DEMO_ABAP_RAP_RO_M_AS 7 | E 8 | Behavior Implementation for ZDEMO_ABAP_RAP_RO_M_AS 9 | 06 10 | 1 11 | X 12 | X 13 | X 14 | ZDEMO_ABAP_RAP_RO_M_AS 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/zbp_demo_abap_rap_ro_u.clas.abap: -------------------------------------------------------------------------------- 1 | "!

RAP BO provider for a RAP demo scenario
ABAP cheat sheet example class

2 | "! 3 | "!

The class represents a RAP BO provider (i. e. an ABAP behavior pool/ABP) for a RAP demo scenario:
4 | "! Unmanaged RAP BO with external numbering.

5 | CLASS zbp_demo_abap_rap_ro_u DEFINITION PUBLIC ABSTRACT FINAL FOR BEHAVIOR OF zdemo_abap_rap_ro_u. 6 | PROTECTED SECTION. 7 | PRIVATE SECTION. 8 | ENDCLASS. 9 | 10 | 11 | 12 | CLASS ZBP_DEMO_ABAP_RAP_RO_U IMPLEMENTATION. 13 | ENDCLASS. 14 | -------------------------------------------------------------------------------- /src/zbp_demo_abap_rap_ro_u.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZBP_DEMO_ABAP_RAP_RO_U 7 | E 8 | Behavior implementation for RAP demo scenario (unmanaged BO) 9 | 06 10 | 1 11 | X 12 | X 13 | X 14 | ZDEMO_ABAP_RAP_RO_U 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_amdp.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_AMDP 7 | E 8 | ABAP cheat sheet: AMDP 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_aux.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_AUX 7 | E 8 | ABAP cheat sheet example class: ABAP cheat sheet auxiliary c 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_builtin_func.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_BUILTIN_FUNC 7 | E 8 | ABAP cheat sheet: Built-in Functions 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_cds_ve.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_CDS_VE 7 | E 8 | ABAP cheat sheet: CDS view entities 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_cloud_excursion.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_CLOUD_EXCURSION 7 | E 8 | ABAP cheat sheet: Excursions into ABAP for Cloud Development 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_constructor_expr.clas.locals_imp.abap: -------------------------------------------------------------------------------- 1 | CLASS local_class DEFINITION. 2 | PUBLIC SECTION. 3 | METHODS: constructor IMPORTING txt TYPE string, 4 | double IMPORTING int TYPE 5 | REF TO i RETURNING VALUE(res) TYPE i. 6 | 7 | DATA: timestamp TYPE string, 8 | text TYPE string. 9 | 10 | CLASS-DATA: no_of_instances TYPE i READ-ONLY. 11 | ENDCLASS. 12 | 13 | CLASS local_class IMPLEMENTATION. 14 | METHOD constructor. 15 | "Number of instances of the class are counted. 16 | no_of_instances = no_of_instances + 1. 17 | "Set a time stamp. 18 | DATA: ts TYPE timestampl. 19 | GET TIME STAMP FIELD ts. 20 | timestamp = |{ ts TIMESTAMP = SPACE }|. 21 | 22 | text = |{ txt }, { sy-uname }.|. 23 | ENDMETHOD. 24 | METHOD double. 25 | res = int->* * 2. 26 | ENDMETHOD. 27 | ENDCLASS. 28 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_constructor_expr.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_CONSTRUCTOR_EXPR 7 | E 8 | ABAP cheat sheet: Constructor expressions 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_date_time.clas.locals_imp.abap: -------------------------------------------------------------------------------- 1 | "Note: This ABAP stopwatch is not intended to be used productively. 2 | "The implementation is intended to be a playground for exploring 3 | "time-related functions. 4 | CLASS lcl_stopwatch DEFINITION. 5 | PUBLIC SECTION. 6 | CLASS-METHODS create 7 | RETURNING 8 | VALUE(sw_inst) TYPE REF TO lcl_stopwatch. 9 | 10 | METHODS stop. 11 | METHODS start. 12 | METHODS store. 13 | 14 | TYPES: BEGIN OF stored_times_struc, 15 | interval TYPE i, 16 | time_since_start TYPE string, 17 | time_delta TYPE string, 18 | END OF stored_times_struc. 19 | TYPES stored_times_type TYPE SORTED TABLE OF stored_times_struc WITH UNIQUE KEY interval. 20 | METHODS get_stored_times RETURNING VALUE(time) TYPE stored_times_type . 21 | METHODS get_time RETURNING VALUE(time) TYPE string . 22 | 23 | PROTECTED SECTION. 24 | PRIVATE SECTION. 25 | DATA time_start TYPE utclong. 26 | DATA time_stop TYPE utclong. 27 | DATA stopwatch_is_on TYPE abap_bool. 28 | DATA interval_timer_is_on TYPE abap_bool. 29 | TYPES: BEGIN OF time_struc, 30 | days TYPE i, 31 | hours TYPE i, 32 | minutes TYPE int8, 33 | seconds TYPE decfloat34, 34 | END OF time_struc. 35 | DATA time_elapsed TYPE time_struc. 36 | TYPES cl2 TYPE c LENGTH 2. 37 | DATA storage TYPE TABLE OF utclong WITH EMPTY KEY. 38 | 39 | METHODS reset. 40 | METHODS get_elapsed_time 41 | IMPORTING start TYPE utclong 42 | stop TYPE utclong 43 | RETURNING VALUE(delta) TYPE time_struc. 44 | 45 | METHODS time_output_prep 46 | IMPORTING time TYPE time_struc 47 | RETURNING VALUE(res) TYPE string. 48 | ENDCLASS. 49 | 50 | CLASS lcl_stopwatch IMPLEMENTATION. 51 | METHOD create. 52 | sw_inst = NEW #( ). 53 | sw_inst->reset( ). 54 | ENDMETHOD. 55 | 56 | METHOD start. 57 | "No multiple starts allowed 58 | ASSERT stopwatch_is_on = abap_false. 59 | ASSERT interval_timer_is_on = abap_false. 60 | reset( ). 61 | stopwatch_is_on = abap_true. 62 | time_start = utclong_current( ). 63 | ENDMETHOD. 64 | 65 | METHOD stop. 66 | ASSERT stopwatch_is_on = abap_true. 67 | time_stop = utclong_current( ). 68 | stopwatch_is_on = abap_false. 69 | interval_timer_is_on = abap_false. 70 | time_elapsed = get_elapsed_time( start = time_start 71 | stop = time_stop ). 72 | ENDMETHOD. 73 | 74 | METHOD reset. 75 | CLEAR: time_start, 76 | time_stop, 77 | time_elapsed, 78 | stopwatch_is_on, 79 | interval_timer_is_on, 80 | storage. 81 | ENDMETHOD. 82 | 83 | METHOD get_elapsed_time. 84 | cl_abap_utclong=>diff( EXPORTING high = stop 85 | low = start 86 | IMPORTING days = delta-days 87 | hours = delta-hours 88 | minutes = delta-minutes 89 | seconds = delta-seconds ). 90 | ENDMETHOD. 91 | 92 | METHOD get_time. 93 | "When the interval timer is on, it is not allowed to 94 | "get the time. The get_stored_times method is to be used. 95 | ASSERT interval_timer_is_on = abap_false. 96 | IF stopwatch_is_on = abap_true. 97 | stop( ). 98 | ENDIF. 99 | time = time_output_prep( time_elapsed ). 100 | ENDMETHOD. 101 | 102 | METHOD time_output_prep. 103 | res = |{ COND #( WHEN time-days IS NOT INITIAL THEN time-days && ` days, ` ) }| && 104 | |{ COND #( WHEN numofchar( CONV cl2( time-hours ) ) = 1 THEN `0` && time-hours ELSE time-hours ) }:| && 105 | |{ COND #( WHEN numofchar( CONV cl2( time-minutes ) ) = 1 THEN `0` && time-minutes ELSE time-minutes ) }:| && 106 | |{ COND #( WHEN find( val = CONV string( time-seconds ) sub = `.` ) = 1 THEN `0` && time-seconds ELSE time-seconds ) }|. 107 | ENDMETHOD. 108 | 109 | METHOD store. 110 | ASSERT stopwatch_is_on = abap_true. 111 | interval_timer_is_on = abap_true. 112 | APPEND utclong_current( ) TO storage. 113 | ENDMETHOD. 114 | 115 | METHOD get_stored_times. 116 | IF interval_timer_is_on = abap_true. 117 | stop( ). 118 | ENDIF. 119 | 120 | if lines( storage ) > 0. 121 | LOOP AT storage REFERENCE INTO DATA(ref). 122 | DATA(tabix) = sy-tabix. 123 | DATA(time_since_start) = get_elapsed_time( start = time_start stop = ref->* ). 124 | DATA(prep_time_since_start) = time_output_prep( time_since_start ). 125 | DATA(time_delta) = get_elapsed_time( start = COND #( WHEN tabix = 1 THEN time_start ELSE storage[ tabix - 1 ] ) stop = ref->* ). 126 | DATA(prep_time_delta) = time_output_prep( time_delta ). 127 | INSERT VALUE #( interval = tabix 128 | time_since_start = prep_time_since_start 129 | time_delta = prep_time_delta ) INTO TABLE time. 130 | ENDLOOP. 131 | endif. 132 | ENDMETHOD. 133 | ENDCLASS. 134 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_date_time.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_DATE_TIME 7 | E 8 | ABAP cheat sheet: Date, Time, and Time Stamp 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_dtype_dobj.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_DTYPE_DOBJ 7 | E 8 | ABAP cheat sheet: Data Types and Data Objects 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_dynamic_prog.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_DYNAMIC_PROG 7 | E 8 | ABAP cheat sheet: Dynamic programming 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_error_handling.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_ERROR_HANDLING 7 | E 8 | ABAP cheat sheet: Exceptions and Runtime Errors 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_internal_tables.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_INTERNAL_TABLES 7 | E 8 | ABAP cheat sheet: Internal tables 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_objects.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_OBJECTS 7 | E 8 | ABAP cheat sheet: ABAP object orientation 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_objects_friend.clas.abap: -------------------------------------------------------------------------------- 1 | "!

Class supporting the ABAP object orientation example
ABAP cheat sheet example class

2 | "! 3 | "!

The example class supports the ABAP object orientation example.
4 | "! Choose F9 in ADT to run the class.

5 | "! 6 | "!

Note

7 | "!

Find the disclaimer in the ABAP Doc comment of class 8 | "! {@link zcl_demo_abap_aux}.

9 | CLASS zcl_demo_abap_objects_friend DEFINITION PUBLIC FINAL CREATE PUBLIC. 10 | 11 | PUBLIC SECTION. 12 | CLASS-METHODS get_strings RETURNING VALUE(res_string) TYPE string_table. 13 | 14 | protected section. 15 | private section. 16 | ENDCLASS. 17 | 18 | 19 | 20 | CLASS ZCL_DEMO_ABAP_OBJECTS_FRIEND IMPLEMENTATION. 21 | 22 | 23 | METHOD get_strings. 24 | "Getting the strings and adding them to the string table. 25 | "Accessing an attribute in a public visibility section. 26 | APPEND zcl_demo_abap_objects=>public_string TO res_string. 27 | 28 | "Accessing an attribute in a protected visibility section. 29 | APPEND zcl_demo_abap_objects=>protected_string TO res_string. 30 | 31 | "Accessing an attribute in a private visibility section. 32 | APPEND zcl_demo_abap_objects=>private_string TO res_string. 33 | ENDMETHOD. 34 | ENDCLASS. 35 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_objects_friend.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_OBJECTS_FRIEND 7 | E 8 | Class supporting ABAP cheat sheet example 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_objects_misc.clas.locals_def.abap: -------------------------------------------------------------------------------- 1 | CLASS local_class DEFINITION DEFERRED. 2 | CLASS zcl_demo_abap_objects_misc DEFINITION LOCAL FRIENDS local_class. 3 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_objects_misc.clas.locals_imp.abap: -------------------------------------------------------------------------------- 1 | CLASS local_class DEFINITION FRIENDS zcl_demo_abap_objects_misc. 2 | 3 | PUBLIC SECTION. 4 | PROTECTED SECTION. 5 | PRIVATE SECTION. 6 | CLASS-DATA hello TYPE zcl_demo_abap_objects_misc=>str4friend. 7 | CLASS-METHODS say_hello. 8 | 9 | ENDCLASS. 10 | 11 | CLASS local_class IMPLEMENTATION. 12 | METHOD say_hello. 13 | hello = |{ zcl_demo_abap_objects_misc=>get_hello( ) } { sy-uname }.|. 14 | ENDMETHOD. 15 | ENDCLASS. 16 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_objects_misc.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_OBJECTS_MISC 7 | E 8 | ABAP cheat sheet: ABAP object orientation 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_oo_inheritance_1.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_OO_INHERITANCE_1 7 | E 8 | ABAP cheat sheet: ABAP object orientation - Inheritance 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_oo_inheritance_2.clas.abap: -------------------------------------------------------------------------------- 1 | "!

ABAP object orientation - Inheritance
ABAP cheat sheet example class

2 | "! 3 | "!

The example class explores inheritance and demonstrate a selection of the inheritance-related syntax. 4 | "! The inheritance tree consists of four example classes. The base class {@link zcl_demo_abap_oo_inheritance_1} 5 | "! includes the implementation of the classrun interface. Choose F9 in ADT to run the base class.

6 | "!

Classes of the inheritance tree:

7 | "!
  • {@link zcl_demo_abap_oo_inheritance_1}
  • 8 | "!
  • {@link zcl_demo_abap_oo_inheritance_2}
  • 9 | "!
  • {@link zcl_demo_abap_oo_inheritance_3}
  • 10 | "!
  • {@link zcl_demo_abap_oo_inheritance_4}
  • 11 | "!
12 | "! 13 | "!

Notes on this class

14 | "!
  • Specifies CREATE PROTECTED, so the class can only be instantiated in methods of its subclasses, 15 | "! of the class itself, and of its friends
  • 16 | "!
  • You may want to try to create an instance of the class in {@link zcl_demo_abap_oo_inheritance_1} 17 | "! like this DATA(oref) = NEW zcl_demo_abap_oo_inheritance_2( ).. It is not possible. In 18 | "! {@link zcl_demo_abap_oo_inheritance_3} and {@link zcl_demo_abap_oo_inheritance_4}, for example, it is 19 | "! possible.
  • 20 | "!
  • Declares several instance methods
  • 21 | "!
  • One of them is declared with FINAL, so no redefinition is possible in subclasses
  • 22 | "!
  • Instance methods of the direct superclass are redefined
  • 23 | "!
  • Note: Private methods of superclasses cannot be redefined. You cannot specify abstract methods, which 24 | "! is only possible in abstract classes. Abstract methods are generally not possible in the private visibility 25 | "! section since they cannot be redefined.
  • 26 | "!
  • Declares a static method to delegate method calls of this class
  • 27 | "!
  • The implementation includes the creation of an instance of the class and instance method calls 28 | "! (including redefined methods).
  • 29 | "!
  • It is called in the classrun implementation in {@link zcl_demo_abap_oo_inheritance_1}.
30 | "! 31 | "!

More information

32 | "!
  • Find general information on the inheritance example in class {@link zcl_demo_abap_oo_inheritance_1}
  • 33 | "!
  • Find information on getting started with the example class and the 34 | "! disclaimer in the ABAP Doc comment of class {@link zcl_demo_abap_aux}.
35 | CLASS zcl_demo_abap_oo_inheritance_2 DEFINITION 36 | INHERITING FROM zcl_demo_abap_oo_inheritance_1 37 | PUBLIC 38 | CREATE PROTECTED . 39 | 40 | PUBLIC SECTION. 41 | "Instance/static constructor declarations 42 | METHODS constructor. 43 | CLASS-METHODS class_constructor. 44 | 45 | "Instance method declarations 46 | METHODS meth_public_2. 47 | METHODS meth_public_2_final FINAL. 48 | 49 | "Static method declaration for display purposes 50 | CLASS-METHODS perform_meth_calls_2. 51 | 52 | "Redefining method from the class one level up in the inheritance hierarchy 53 | "(i.e. the direct superclass) 54 | METHODS meth_public_1 REDEFINITION. 55 | 56 | "Excursions: 57 | "- Redefining the final public method of the superclass is not possible. 58 | "- The same applies to constructors. 59 | "- The following type has the same name as a type in the superclass. Since components 60 | " are inherited, the following declaration is not possible. 61 | "TYPES t_log TYPE string_table. 62 | "- Similary, the log table, which is a static component in the superclass, can be 63 | " referenced in the method implementations using 'log_table'. Using the class name 64 | " and => is also possible, but not required. 65 | "INSERT VALUE #( ) INTO TABLE zcl_demo_abap_oo_inheritance_1=>log_tab. 66 | 67 | PROTECTED SECTION. 68 | "Instance method declaration 69 | METHODS meth_protected_2. 70 | 71 | "Redefining method from the class one level up in the inheritance hierarchy 72 | "(i.e. the direct superclass) 73 | METHODS meth_protected_1 REDEFINITION. 74 | 75 | PRIVATE SECTION. 76 | "Ecursion: 77 | "- The following declarations are not possible. 78 | "- Private methods cannot be redefined. 79 | "METHODS meth_private_1 REDEFINITION. 80 | "- Abstract methods can only be declared in abstract classes. And, since 81 | " private methods cannot be redefined, abstract private methods are not 82 | " possible. 83 | "METHODS meth_private_2_abstract ABSTRACT. 84 | ENDCLASS. 85 | 86 | 87 | 88 | CLASS zcl_demo_abap_oo_inheritance_2 IMPLEMENTATION. 89 | METHOD class_constructor. 90 | INSERT VALUE #( called_at = utclong_current( ) ) INTO TABLE log_tab ASSIGNING FIELD-SYMBOL(). 91 | = CORRESPONDING #( BASE ( ) get_method_info( ) EXCEPT called_at ). 92 | ENDMETHOD. 93 | 94 | METHOD constructor. 95 | super->constructor( ). 96 | INSERT VALUE #( called_at = utclong_current( ) ) INTO TABLE log_tab ASSIGNING FIELD-SYMBOL(). 97 | = CORRESPONDING #( BASE ( ) get_method_info( ) EXCEPT called_at ). 98 | ENDMETHOD. 99 | 100 | METHOD meth_public_2. 101 | "Method of this class 102 | INSERT VALUE #( called_at = utclong_current( ) ) INTO TABLE log_tab ASSIGNING FIELD-SYMBOL(). 103 | = CORRESPONDING #( BASE ( ) get_method_info( ) EXCEPT called_at ). 104 | ENDMETHOD. 105 | 106 | METHOD meth_public_2_final. 107 | "Method of this class 108 | INSERT VALUE #( called_at = utclong_current( ) ) INTO TABLE log_tab ASSIGNING FIELD-SYMBOL(). 109 | = CORRESPONDING #( BASE ( ) get_method_info( ) EXCEPT called_at ). 110 | ENDMETHOD. 111 | 112 | METHOD meth_protected_2. 113 | "Method of this class 114 | INSERT VALUE #( called_at = utclong_current( ) ) INTO TABLE log_tab ASSIGNING FIELD-SYMBOL(). 115 | = CORRESPONDING #( BASE ( ) get_method_info( ) EXCEPT called_at ). 116 | ENDMETHOD. 117 | 118 | METHOD meth_public_1. 119 | "Reimplementing a method from the class one level up in the inheritance hierarchy (direct superclass) 120 | INSERT VALUE #( called_at = utclong_current( ) ) INTO TABLE log_tab ASSIGNING FIELD-SYMBOL(). 121 | = CORRESPONDING #( BASE ( ) get_method_info( ) EXCEPT called_at ). 122 | ENDMETHOD. 123 | 124 | METHOD meth_protected_1. 125 | "Reimplementing a method from the class one level up in the inheritance hierarchy (direct superclass) 126 | INSERT VALUE #( called_at = utclong_current( ) ) INTO TABLE log_tab ASSIGNING FIELD-SYMBOL(). 127 | = CORRESPONDING #( BASE ( ) get_method_info( ) EXCEPT called_at ). 128 | ENDMETHOD. 129 | 130 | METHOD perform_meth_calls_2. 131 | "Method of this class 132 | "Creating an instance of the class 133 | DATA(oref_2) = NEW zcl_demo_abap_oo_inheritance_2( ). 134 | 135 | "Calling methods of this class 136 | oref_2->meth_public_2( ). 137 | oref_2->meth_public_2_final( ). 138 | oref_2->meth_protected_2( ). 139 | "Calling redefined methods from the class one level up in the inheritance hierarchy (direct superclass) 140 | oref_2->meth_protected_1( ). 141 | oref_2->meth_public_1( ). 142 | 143 | ENDMETHOD. 144 | 145 | ENDCLASS. 146 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_oo_inheritance_2.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_OO_INHERITANCE_2 7 | E 8 | ABAP cheat sheet: ABAP object orientation - Inheritance 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_oo_inheritance_3.clas.abap: -------------------------------------------------------------------------------- 1 | "!

ABAP object orientation - Inheritance
ABAP cheat sheet example class

2 | "! 3 | "!

The example class explores inheritance and demonstrate a selection of the inheritance-related syntax. 4 | "! The inheritance tree consists of four example classes. The base class {@link zcl_demo_abap_oo_inheritance_1} 5 | "! includes the implementation of the classrun interface. Choose F9 in ADT to run the base class.

6 | "!

Classes of the inheritance tree:

7 | "!
  • {@link zcl_demo_abap_oo_inheritance_1}
  • 8 | "!
  • {@link zcl_demo_abap_oo_inheritance_2}
  • 9 | "!
  • {@link zcl_demo_abap_oo_inheritance_3}
  • 10 | "!
  • {@link zcl_demo_abap_oo_inheritance_4}
  • 11 | "!
12 | "! 13 | "!

Notes on this class

14 | "!
  • Inherits from {@link zcl_demo_abap_oo_inheritance_1} and thus from {@link zcl_demo_abap_oo_inheritance_2}
  • 15 | "!
  • Declared as abstract class using the ABSTRACT addition, so no instances can be created from the class
  • 16 | "!
  • Declares several instance methods
  • 17 | "!
  • Two abstract methods are included using the ABSTRACT addition, so they can only be implemented in subclasses (there 18 | "! is no implementation of these methods in the class)
  • 19 | "!
  • Instance methods of the direct superclass are redefined as well as methods from two levels up the inheritance hierarchy
  • 20 | "!
  • One redefined method specifies FINAL REDEFINITION, so a further redefinition in subclasses is not possible.
21 | "! 22 | "!

More information

23 | "!
  • Find general information on the inheritance example in class {@link zcl_demo_abap_oo_inheritance_1}
  • 24 | "!
  • Find information on getting started with the example class and the 25 | "! disclaimer in the ABAP Doc comment of class {@link zcl_demo_abap_aux}.
26 | CLASS zcl_demo_abap_oo_inheritance_3 DEFINITION 27 | INHERITING FROM zcl_demo_abap_oo_inheritance_2 28 | PUBLIC 29 | ABSTRACT 30 | CREATE PUBLIC . 31 | 32 | PUBLIC SECTION. 33 | "Instance/static constructor declarations 34 | METHODS constructor. 35 | CLASS-METHODS class_constructor. 36 | 37 | "Instance method declarations 38 | METHODS meth_public_3. 39 | "Abstract method 40 | METHODS meth_public_3_abstract ABSTRACT. 41 | 42 | "Redefining methods from the class ... 43 | "... one level up in the inheritance hierarchy (i.e. the direct superclass) 44 | METHODS meth_public_2 REDEFINITION. 45 | "... two levels up in the inheritance hierarchy 46 | METHODS meth_public_1 REDEFINITION. 47 | 48 | PROTECTED SECTION. 49 | "Instance method declarations 50 | METHODS meth_protected_3. 51 | "Abstract method 52 | METHODS meth_protected_3_abstract ABSTRACT. 53 | 54 | "Redefining methods from the class ... 55 | "... one level up in the inheritance hierarchy (i.e. the direct superclass) 56 | METHODS meth_protected_2 REDEFINITION. 57 | "... two levels up in the inheritance hierarchy 58 | "Specifying the FINAL addition 59 | METHODS meth_protected_1 FINAL REDEFINITION. 60 | 61 | PRIVATE SECTION. 62 | ENDCLASS. 63 | 64 | 65 | 66 | CLASS zcl_demo_abap_oo_inheritance_3 IMPLEMENTATION. 67 | 68 | METHOD class_constructor. 69 | INSERT VALUE #( called_at = utclong_current( ) ) INTO TABLE log_tab ASSIGNING FIELD-SYMBOL(). 70 | = CORRESPONDING #( BASE ( ) get_method_info( ) EXCEPT called_at ). 71 | ENDMETHOD. 72 | 73 | METHOD constructor. 74 | super->constructor( ). 75 | INSERT VALUE #( called_at = utclong_current( ) ) INTO TABLE log_tab ASSIGNING FIELD-SYMBOL(). 76 | = CORRESPONDING #( BASE ( ) get_method_info( ) EXCEPT called_at ). 77 | ENDMETHOD. 78 | 79 | METHOD meth_public_3. 80 | "Method of this class 81 | INSERT VALUE #( called_at = utclong_current( ) ) INTO TABLE log_tab ASSIGNING FIELD-SYMBOL(). 82 | = CORRESPONDING #( BASE ( ) get_method_info( ) EXCEPT called_at ). 83 | ENDMETHOD. 84 | 85 | METHOD meth_protected_3. 86 | "Method of this class 87 | INSERT VALUE #( called_at = utclong_current( ) ) INTO TABLE log_tab ASSIGNING FIELD-SYMBOL(). 88 | = CORRESPONDING #( BASE ( ) get_method_info( ) EXCEPT called_at ). 89 | ENDMETHOD. 90 | 91 | METHOD meth_public_2. 92 | "Reimplementing a method from the class one level up in the inheritance hierarchy (direct superclass) 93 | INSERT VALUE #( called_at = utclong_current( ) ) INTO TABLE log_tab ASSIGNING FIELD-SYMBOL(). 94 | = CORRESPONDING #( BASE ( ) get_method_info( ) EXCEPT called_at ). 95 | ENDMETHOD. 96 | 97 | METHOD meth_protected_2. 98 | "Reimplementing a method from the class one level up in the inheritance hierarchy (direct superclass) 99 | INSERT VALUE #( called_at = utclong_current( ) ) INTO TABLE log_tab ASSIGNING FIELD-SYMBOL(). 100 | = CORRESPONDING #( BASE ( ) get_method_info( ) EXCEPT called_at ). 101 | ENDMETHOD. 102 | 103 | METHOD meth_protected_1. 104 | "Reimplementing a method from the class two levels up in the inheritance hierarchy 105 | "Note that the method is specified with FINAL REDEFINITION. So, a further redefinition in subclasses is not possible. 106 | INSERT VALUE #( called_at = utclong_current( ) ) INTO TABLE log_tab ASSIGNING FIELD-SYMBOL(). 107 | = CORRESPONDING #( BASE ( ) get_method_info( ) EXCEPT called_at ). 108 | ENDMETHOD. 109 | 110 | METHOD meth_public_1. 111 | "Reimplementing a method from the class two levels up in the inheritance hierarchy 112 | INSERT VALUE #( called_at = utclong_current( ) ) INTO TABLE log_tab ASSIGNING FIELD-SYMBOL(). 113 | = CORRESPONDING #( BASE ( ) get_method_info( ) EXCEPT called_at ). 114 | ENDMETHOD. 115 | ENDCLASS. 116 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_oo_inheritance_3.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_OO_INHERITANCE_3 7 | E 8 | ABAP cheat sheet: ABAP object orientation - Inheritance 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_oo_inheritance_4.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_OO_INHERITANCE_4 7 | E 8 | ABAP cheat sheet: ABAP object orientation - Inheritance 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_prog_flow_logic.clas.locals_def.abap: -------------------------------------------------------------------------------- 1 | CLASS lcx_calc_error DEFINITION INHERITING FROM cx_no_check. 2 | ENDCLASS. 3 | 4 | CLASS lcx_some_error DEFINITION INHERITING FROM cx_no_check. 5 | ENDCLASS. 6 | 7 | CLASS lcx_invalid_email DEFINITION INHERITING FROM cx_no_check. 8 | ENDCLASS. 9 | 10 | CLASS lcx_static_exc_class DEFINITION INHERITING FROM cx_static_check. 11 | ENDCLASS. 12 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_prog_flow_logic.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_PROG_FLOW_LOGIC 7 | E 8 | ABAP cheat sheet: Program flow logic 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_rap_draft_ln_m.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_RAP_DRAFT_LN_M 7 | E 8 | ABAP cheat sheet: ABAP EML in a RAP scenario (draft BO) 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_rap_evt_handler.clas.abap: -------------------------------------------------------------------------------- 1 | "!

RAP event handler class
ABAP cheat sheet example class

2 | "! 3 | "!

The example class is the RAP event handler class for {@link zdemo_abap_rap_ro_m_as}.
4 | "! Choose F9 in ADT to run the class.

5 | "! 6 | "!

Note

7 | "!
  • The RAP business events in this example are raised using RAISE 8 | "! ENTITY EVENT statements in the save_modified saver method that 9 | "! is implemented in the CCIMP include of the ABAP behavior pool 10 | "! {@link zbp_demo_abap_rap_ro_m_as}.
  • 11 | "!
  • Find the disclaimer in the ABAP Doc comment of 12 | "! class {@link zcl_demo_abap_aux}.
13 | CLASS zcl_demo_abap_rap_evt_handler DEFINITION 14 | PUBLIC ABSTRACT FINAL 15 | FOR EVENTS OF zdemo_abap_rap_ro_m_as. 16 | 17 | PUBLIC SECTION. 18 | PROTECTED SECTION. 19 | PRIVATE SECTION. 20 | ENDCLASS. 21 | 22 | CLASS zcl_demo_abap_rap_evt_handler IMPLEMENTATION. 23 | ENDCLASS. 24 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_rap_evt_handler.clas.locals_imp.abap: -------------------------------------------------------------------------------- 1 | CLASS lhe_event DEFINITION INHERITING FROM cl_abap_behavior_event_handler. 2 | 3 | PRIVATE SECTION. 4 | 5 | METHODS on_updated FOR ENTITY EVENT 6 | updated FOR root~updated. 7 | 8 | METHODS on_deleted FOR ENTITY EVENT 9 | deleted FOR root~deleted. 10 | 11 | METHODS on_created FOR ENTITY EVENT 12 | created FOR root~created. 13 | 14 | DATA evt_log TYPE TABLE OF zdemo_abap_draft WITH EMPTY KEY. 15 | ENDCLASS. 16 | 17 | CLASS lhe_event IMPLEMENTATION. 18 | 19 | "Note: 20 | "- For this example, database table entries are created for the individual 21 | " RAP BO instances that are imported into the event handler methods. 22 | "- The transactional phases are implicitly set when RAP business events are 23 | " consumed locally. This means that RAP event handler methods are started in 24 | " the modify phase when called. If database modifications are to be implemented 25 | " in RAP event handler methods, you must explicitly activate the save phase to 26 | " avoid causing errors detected by the controlled SAP LUW. 27 | 28 | METHOD on_created. 29 | cl_abap_tx=>save( ). 30 | LOOP AT created ASSIGNING FIELD-SYMBOL(). 31 | TRY. 32 | APPEND VALUE #( id = cl_system_uuid=>create_uuid_x16_static( ) 33 | draftuuid = cl_system_uuid=>create_uuid_x16_static( ) 34 | calc_result = |Instance key: "{ -id }" / Event CREATED raised| 35 | crea_date_time = cl_abap_tstmp=>utclong2tstmp( utclong_current( ) ) 36 | ) TO evt_log. 37 | CATCH cx_uuid_error INTO DATA(err). 38 | ASSERT err IS INITIAL. 39 | ENDTRY. 40 | MODIFY zdemo_abap_draft FROM TABLE @evt_log. 41 | ENDLOOP. 42 | ENDMETHOD. 43 | 44 | METHOD on_updated. 45 | cl_abap_tx=>save( ). 46 | LOOP AT updated ASSIGNING FIELD-SYMBOL(). 47 | TRY. 48 | APPEND VALUE #( id = cl_system_uuid=>create_uuid_x16_static( ) 49 | draftuuid = cl_system_uuid=>create_uuid_x16_static( ) 50 | calc_result = |Instance key: "{ -id }" / %param: col1: "{ -%param-col1 }" col2: "{ -%param-col2 }"| 51 | crea_date_time = cl_abap_tstmp=>utclong2tstmp( utclong_current( ) ) 52 | ) TO evt_log. 53 | CATCH cx_uuid_error INTO DATA(err). 54 | ASSERT err IS INITIAL. 55 | ENDTRY. 56 | MODIFY zdemo_abap_draft FROM TABLE @evt_log. 57 | ENDLOOP. 58 | ENDMETHOD. 59 | 60 | METHOD on_deleted. 61 | cl_abap_tx=>save( ). 62 | LOOP AT deleted ASSIGNING FIELD-SYMBOL(). 63 | TRY. 64 | APPEND VALUE #( id = cl_system_uuid=>create_uuid_x16_static( ) 65 | draftuuid = cl_system_uuid=>create_uuid_x16_static( ) 66 | calc_result = |Instance key: "{ -id }" / %param: col1: "{ -%param-col1 }" col2: "{ -%param-col2 }"| 67 | crea_date_time = cl_abap_tstmp=>utclong2tstmp( utclong_current( ) ) 68 | ) TO evt_log. 69 | CATCH cx_uuid_error INTO DATA(err). 70 | ASSERT err IS INITIAL. 71 | ENDTRY. 72 | MODIFY zdemo_abap_draft FROM TABLE @evt_log. 73 | ENDLOOP. 74 | ENDMETHOD. 75 | ENDCLASS. 76 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_rap_evt_handler.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_RAP_EVT_HANDLER 7 | E 8 | RAP event handler class 9 | 07 10 | 1 11 | X 12 | X 13 | X 14 | ZDEMO_ABAP_RAP_RO_M_AS 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_rap_ext_num_m.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_RAP_EXT_NUM_M 7 | E 8 | ABAP cheat sheet: ABAP EML in a RAP scenario (managed BO) 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_rap_ext_num_u.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_RAP_EXT_NUM_U 7 | E 8 | ABAP cheat sheet: ABAP EML in a RAP scenario (unmanaged BO) 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_rap_m_as.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_RAP_M_AS 7 | E 8 | ABAP cheat sheet: Local consumption of RAP Business Events 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_regex.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_REGEX 7 | E 8 | ABAP cheat sheet: Regular Expressions in ABAP 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_sql.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_SQL 7 | E 8 | ABAP cheat sheet: ABAP SQL 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_sql_group_by.clas.abap: -------------------------------------------------------------------------------- 1 | "!

Grouping internal tables
ABAP cheat sheet example class

2 | "! 3 | "!

The example class demonstrates syntax options when grouping internal tables.
4 | "! Choose F9 in ADT to run the class.

5 | "! 6 | "!

Note

7 | "!

Find information on getting started with the example class and the 8 | "! disclaimer in the ABAP Doc comment of class {@link zcl_demo_abap_aux}.

9 | CLASS zcl_demo_abap_sql_group_by DEFINITION 10 | PUBLIC 11 | FINAL 12 | CREATE PUBLIC . 13 | 14 | PUBLIC SECTION. 15 | INTERFACES: if_oo_adt_classrun. 16 | 17 | CLASS-METHODS: class_constructor. 18 | 19 | protected section. 20 | PRIVATE SECTION. 21 | CLASS-DATA: 22 | wa TYPE zdemo_abap_flsch, 23 | member TYPE zdemo_abap_flsch, 24 | members TYPE STANDARD TABLE OF zdemo_abap_flsch WITH EMPTY KEY. 25 | 26 | ENDCLASS. 27 | 28 | 29 | 30 | CLASS ZCL_DEMO_ABAP_SQL_GROUP_BY IMPLEMENTATION. 31 | 32 | 33 | METHOD class_constructor. 34 | "Fill demo database tables. 35 | zcl_demo_abap_aux=>fill_dbtabs( ). 36 | ENDMETHOD. 37 | 38 | 39 | METHOD if_oo_adt_classrun~main. 40 | 41 | out->write( |ABAP Cheat Sheet Example: Grouping Internal Tables\n\n| ). 42 | 43 | SELECT * 44 | FROM zdemo_abap_flsch 45 | INTO TABLE @DATA(fli_tab). 46 | 47 | out->write( |1) Representative Binding\n| ). 48 | out->write( |1a) Grouping by one column\n| ). 49 | 50 | LOOP AT fli_tab INTO wa 51 | GROUP BY wa-carrid. 52 | out->write( wa-carrid ). 53 | ENDLOOP. 54 | 55 | out->write( zcl_demo_abap_aux=>heading( `1b) Members of one column groups` ) ). 56 | 57 | LOOP AT fli_tab INTO wa 58 | GROUP BY wa-carrid. 59 | CLEAR members. 60 | LOOP AT GROUP wa INTO member. 61 | members = VALUE #( BASE members ( member ) ). 62 | ENDLOOP. 63 | 64 | out->write( members ). 65 | out->write( |\n| ). 66 | ENDLOOP. 67 | 68 | out->write( zcl_demo_abap_aux=>heading( `1c) Grouping by two columns` ) ). 69 | 70 | LOOP AT fli_tab INTO wa 71 | GROUP BY ( key1 = wa-carrid key2 = wa-airpfrom ). 72 | 73 | out->write( |{ wa-carrid } { wa-airpfrom }| ). 74 | out->write( |\n| ). 75 | ENDLOOP. 76 | 77 | out->write( zcl_demo_abap_aux=>heading( `1d) Members of two column groups` ) ). 78 | 79 | LOOP AT fli_tab INTO wa 80 | GROUP BY ( key1 = wa-carrid key2 = wa-airpfrom ). 81 | CLEAR members. 82 | LOOP AT GROUP wa INTO member. 83 | members = VALUE #( BASE members ( member ) ). 84 | ENDLOOP. 85 | 86 | out->write( members ). 87 | out->write( |\n| ). 88 | ENDLOOP. 89 | 90 | out->write( zcl_demo_abap_aux=>heading( `2) Group Key Binding` ) ). 91 | out->write( |2a) Grouping by one column\n| ). 92 | 93 | LOOP AT fli_tab INTO wa 94 | GROUP BY wa-carrid 95 | INTO DATA(key). 96 | 97 | out->write( key ). 98 | out->write( |\n| ). 99 | ENDLOOP. 100 | 101 | out->write( zcl_demo_abap_aux=>heading( `2b) Members of one column groups` ) ). 102 | 103 | LOOP AT fli_tab INTO wa 104 | GROUP BY wa-carrid 105 | INTO key. 106 | CLEAR members. 107 | LOOP AT GROUP key INTO member. 108 | members = VALUE #( BASE members ( member ) ). 109 | ENDLOOP. 110 | 111 | out->write( members ). 112 | out->write( |\n| ). 113 | ENDLOOP. 114 | 115 | out->write( zcl_demo_abap_aux=>heading( `2c) Grouping by two columns` ) ). 116 | 117 | LOOP AT fli_tab INTO wa 118 | GROUP BY ( key1 = wa-carrid key2 = wa-airpfrom ) 119 | INTO DATA(keys). 120 | 121 | out->write( keys ). 122 | out->write( |\n| ). 123 | ENDLOOP. 124 | 125 | out->write( zcl_demo_abap_aux=>heading( `2d) Members of two column groups` ) ). 126 | 127 | LOOP AT fli_tab INTO wa 128 | GROUP BY ( key1 = wa-carrid key2 = wa-airpfrom ) 129 | INTO keys. 130 | CLEAR members. 131 | LOOP AT GROUP keys INTO member. 132 | members = VALUE #( BASE members ( member ) ). 133 | ENDLOOP. 134 | 135 | out->write( members ). 136 | out->write( |\n| ). 137 | ENDLOOP. 138 | 139 | out->write( zcl_demo_abap_aux=>heading( `2e) Two column groups without members` ) ). 140 | 141 | LOOP AT fli_tab INTO wa 142 | GROUP BY ( key1 = wa-carrid key2 = wa-airpfrom 143 | index = GROUP INDEX size = GROUP SIZE ) 144 | WITHOUT MEMBERS 145 | INTO DATA(keysplus). 146 | 147 | out->write( keysplus ). 148 | out->write( |\n| ). 149 | ENDLOOP. 150 | 151 | ENDMETHOD. 152 | ENDCLASS. 153 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_sql_group_by.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_SQL_GROUP_BY 7 | E 8 | ABAP cheat sheet: ABAP SQL - Grouping internal tables 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_string_proc.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_STRING_PROC 7 | E 8 | ABAP cheat sheet: String processing 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_structures.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_STRUCTURES 7 | E 8 | ABAP cheat sheet: Structures 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_unit_dataprov.clas.abap: -------------------------------------------------------------------------------- 1 | "!

Class Supporting ABAP Unit Test Example
ABAP cheat sheet example class

2 | "! 3 | "!

The example class represents a dependent-on-component (DOC) and supports an ABAP Unit test example. 4 | "! Methods of this class are called in another class: {@link zcl_demo_abap_unit_tdf}. The DOCs are replaced 5 | "! by test doubles when running ABAP Unit tests.
6 | "! Choose F9 in ADT to run the class.

7 | "! 8 | "!

Information

9 | "!

Find information on getting started with the example class and the disclaimer in 10 | "! the ABAP Doc comment of class {@link zcl_demo_abap_aux}.

11 | CLASS zcl_demo_abap_unit_dataprov DEFINITION 12 | PUBLIC 13 | CREATE PUBLIC . 14 | 15 | PUBLIC SECTION. 16 | METHODS get_discount RETURNING VALUE(discount) TYPE decfloat34. 17 | METHODS get_discount_value IMPORTING day_value TYPE i 18 | time_value TYPE i 19 | RETURNING VALUE(discount_value) TYPE decfloat34. 20 | PROTECTED SECTION. 21 | PRIVATE SECTION. 22 | ENDCLASS. 23 | 24 | 25 | 26 | CLASS zcl_demo_abap_unit_dataprov IMPLEMENTATION. 27 | METHOD get_discount. 28 | "Getting the weekday 29 | "1) Monday, 2) Tuesday, 3) Wednesday, 4) Thursday, 5) Friday, 6) Saturday, 7) Sunday 30 | DATA(weekday) = ( 5 + CONV d( xco_cp=>sy->date( xco_cp_time=>time_zone->utc 31 | )->as( xco_cp_time=>format->iso_8601_basic )->value ) MOD 7 ) MOD 7 + 1. 32 | 33 | "- Standard discount is granted at the weekend (Saturday, Sunday) 34 | "- On other weekdays, discount is granted depending on the daytime 35 | IF weekday = 6 OR weekday = 7. 36 | discount = '20'. 37 | ELSE. 38 | "Retrieving the current time in UTC 39 | DATA(utc_time) = CONV t( xco_cp=>sy->time( xco_cp_time=>time_zone->utc 40 | )->as( xco_cp_time=>format->iso_8601_basic )->value ). 41 | 42 | discount = COND #( WHEN utc_time BETWEEN '000000' AND '045959' THEN '15' "Night discount 43 | WHEN utc_time BETWEEN '220000' AND '235959' THEN '15' "Night discount 44 | WHEN utc_time BETWEEN '050000' AND '115959' THEN '10' "Morning discount 45 | WHEN utc_time BETWEEN '180000' AND '215959' THEN '5' "Evening discount 46 | ELSE 0 "No discount 47 | ). 48 | ENDIF. 49 | ENDMETHOD. 50 | 51 | METHOD get_discount_value. 52 | CASE day_value. 53 | "Standard discount is granted at the weekend (Saturday, Sunday) 54 | WHEN 6 OR 7. 55 | discount_value = '20'. 56 | "On other weekdays, discount is granted depending on the daytime 57 | WHEN OTHERS. 58 | discount_value = SWITCH #( time_value 59 | WHEN 1 THEN '15' "Night discount 60 | WHEN 2 THEN '10' "Morning discount 61 | WHEN 3 THEN '5' "Evening discount 62 | ELSE '0' "No discount 63 | ). 64 | ENDCASE. 65 | ENDMETHOD. 66 | 67 | ENDCLASS. 68 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_unit_dataprov.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_UNIT_DATAPROV 7 | E 8 | ABAP cheat sheet: Built-in Functions 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_unit_tdf.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_UNIT_TDF 7 | E 8 | ABAP cheat sheet: Creating Test Doubles Using ABAP Framework 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_unit_test.clas.locals_def.abap: -------------------------------------------------------------------------------- 1 | *"* use this source file for any type of declarations (class 2 | *"* definitions, interfaces or type declarations) you need for 3 | *"* components in the private section 4 | INTERFACE lif_get_data DEFERRED. 5 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_unit_test.clas.locals_imp.abap: -------------------------------------------------------------------------------- 1 | ****************************************************** 2 | * Local interface 3 | ****************************************************** 4 | INTERFACE lif_get_data. 5 | 6 | TYPES: carr_tab TYPE TABLE OF zdemo_abap_fli WITH EMPTY KEY, 7 | occ_rate TYPE p LENGTH 4 DECIMALS 2. 8 | 9 | METHODS: 10 | select_flight_data IMPORTING carrier TYPE zdemo_abap_fli-carrid 11 | RETURNING VALUE(flight_data) TYPE carr_tab, 12 | 13 | "This method is included to demonstrate the PARTIALLY IMPLEMENTED 14 | "addition in the test class when implementing the test double 15 | say_hello RETURNING VALUE(hi) TYPE string. 16 | 17 | ENDINTERFACE. 18 | 19 | ****************************************************** 20 | * Local class 21 | * The class implements the local interface. 22 | ****************************************************** 23 | CLASS lcl_data_prov_local_itf DEFINITION. 24 | PUBLIC SECTION. 25 | INTERFACES lif_get_data. 26 | ENDCLASS. 27 | 28 | CLASS lcl_data_prov_local_itf IMPLEMENTATION. 29 | 30 | METHOD lif_get_data~select_flight_data. 31 | 32 | SELECT seatsmax, seatsocc 33 | FROM zdemo_abap_fli 34 | WHERE carrid = @carrier 35 | INTO CORRESPONDING FIELDS OF TABLE @flight_data. 36 | 37 | ENDMETHOD. 38 | 39 | METHOD lif_get_data~say_hello. 40 | hi = `Hello, ` && sy-uname && `.`. 41 | ENDMETHOD. 42 | 43 | ENDCLASS. 44 | 45 | ****************************************************** 46 | * Local class that implements a global interface 47 | * It serves the purpose of a data provider. It can be 48 | * imagined as a global class, and a method that is 49 | * implemented there and called by the class under test 50 | * is identified as DOC. A local class is used in the 51 | * example to keep the number of separate artifacts small. 52 | ****************************************************** 53 | CLASS lcl_data_prov_glo_itf DEFINITION. 54 | PUBLIC SECTION. 55 | INTERFACES zdemo_abap_get_data_itf. 56 | ENDCLASS. 57 | 58 | CLASS lcl_data_prov_glo_itf IMPLEMENTATION. 59 | 60 | METHOD zdemo_abap_get_data_itf~select_flight_data. 61 | 62 | SELECT seatsmax, seatsocc 63 | FROM zdemo_abap_fli 64 | WHERE carrid = @carrier 65 | INTO CORRESPONDING FIELDS OF TABLE @flight_data. 66 | 67 | ENDMETHOD. 68 | 69 | METHOD zdemo_abap_get_data_itf~say_hello. 70 | hi = `Hello, ` && sy-uname && `.`. 71 | ENDMETHOD. 72 | 73 | ENDCLASS. 74 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_unit_test.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_UNIT_TEST 7 | E 8 | ABAP cheat sheet: Unit tests 9 | 1 10 | X 11 | X 12 | X 13 | X 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/zcl_demo_abap_xml_json.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCL_DEMO_ABAP_XML_JSON 7 | E 8 | ABAP cheat sheet: Working with XML and JSON in ABAP 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcx_demo_abap_error_a.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcx_demo_abap_error_a DEFINITION 2 | PUBLIC 3 | INHERITING FROM cx_dynamic_check 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | 9 | INTERFACES if_t100_message. 10 | 11 | CONSTANTS message_class TYPE symsgid VALUE 'ZDEMO_ABAP_MESSAGES'. 12 | 13 | CONSTANTS: 14 | BEGIN OF zcx_demo_abap_error_a, 15 | msgid TYPE symsgid VALUE message_class, 16 | msgno TYPE symsgno VALUE '001', 17 | attr1 TYPE scx_attrname VALUE '', 18 | attr2 TYPE scx_attrname VALUE '', 19 | attr3 TYPE scx_attrname VALUE '', 20 | attr4 TYPE scx_attrname VALUE '', 21 | END OF zcx_demo_abap_error_a. 22 | 23 | CONSTANTS: 24 | BEGIN OF error_002, 25 | msgid TYPE symsgid VALUE message_class, 26 | msgno TYPE symsgno VALUE '002', 27 | attr1 TYPE scx_attrname VALUE '', 28 | attr2 TYPE scx_attrname VALUE '', 29 | attr3 TYPE scx_attrname VALUE '', 30 | attr4 TYPE scx_attrname VALUE '', 31 | END OF error_002. 32 | 33 | CONSTANTS: 34 | BEGIN OF error_003, 35 | msgid TYPE symsgid VALUE message_class, 36 | msgno TYPE symsgno VALUE '003', 37 | attr1 TYPE scx_attrname VALUE 'P_003_A', 38 | attr2 TYPE scx_attrname VALUE 'P_003_B', 39 | attr3 TYPE scx_attrname VALUE '', 40 | attr4 TYPE scx_attrname VALUE '', 41 | END OF error_003. 42 | 43 | CONSTANTS: 44 | BEGIN OF error_004, 45 | msgid TYPE symsgid VALUE message_class, 46 | msgno TYPE symsgno VALUE '004', 47 | attr1 TYPE scx_attrname VALUE 'P_004_A', 48 | attr2 TYPE scx_attrname VALUE 'P_004_B', 49 | attr3 TYPE scx_attrname VALUE 'P_004_C', 50 | attr4 TYPE scx_attrname VALUE 'P_004_D', 51 | END OF error_004. 52 | 53 | CONSTANTS: 54 | BEGIN OF error_005, 55 | msgid TYPE symsgid VALUE message_class, 56 | msgno TYPE symsgno VALUE '005', 57 | attr1 TYPE scx_attrname VALUE 'P_005_A', 58 | attr2 TYPE scx_attrname VALUE 'P_005_B', 59 | attr3 TYPE scx_attrname VALUE 'P_005_C', 60 | attr4 TYPE scx_attrname VALUE 'P_005_D', 61 | END OF error_005. 62 | 63 | DATA p_003_a TYPE string. 64 | DATA p_003_b TYPE string. 65 | DATA p_004_a TYPE string. 66 | DATA p_004_b TYPE string. 67 | DATA p_004_c TYPE string. 68 | DATA p_004_d TYPE string. 69 | DATA p_005_a TYPE string. 70 | DATA p_005_b TYPE string. 71 | DATA p_005_c TYPE string. 72 | DATA p_005_d TYPE string. 73 | 74 | METHODS constructor 75 | IMPORTING 76 | textid LIKE if_t100_message=>t100key OPTIONAL 77 | previous LIKE previous OPTIONAL 78 | p_003_a TYPE string OPTIONAL 79 | p_003_b TYPE string OPTIONAL 80 | p_004_a TYPE string OPTIONAL 81 | p_004_b TYPE string OPTIONAL 82 | p_004_c TYPE string OPTIONAL 83 | p_004_d TYPE string OPTIONAL 84 | p_005_a TYPE string OPTIONAL 85 | p_005_b TYPE string OPTIONAL 86 | p_005_c TYPE string OPTIONAL 87 | p_005_d TYPE string OPTIONAL 88 | . 89 | PROTECTED SECTION. 90 | PRIVATE SECTION. 91 | ENDCLASS. 92 | 93 | 94 | 95 | CLASS zcx_demo_abap_error_a IMPLEMENTATION. 96 | 97 | 98 | METHOD constructor ##ADT_SUPPRESS_GENERATION. 99 | 100 | super->constructor( previous = previous ). 101 | 102 | me->p_003_a = p_003_a. 103 | me->p_003_b = p_003_b. 104 | me->p_004_a = p_004_a. 105 | me->p_004_b = p_004_b. 106 | me->p_004_c = p_004_c. 107 | me->p_004_d = p_004_d. 108 | me->p_005_a = p_005_a. 109 | me->p_005_b = p_005_b. 110 | me->p_005_c = p_005_c. 111 | me->p_005_d = p_005_d. 112 | 113 | CLEAR me->textid. 114 | IF textid IS INITIAL. 115 | if_t100_message~t100key = if_t100_message=>default_textid. 116 | ELSE. 117 | if_t100_message~t100key = textid. 118 | ENDIF. 119 | ENDMETHOD. 120 | ENDCLASS. 121 | -------------------------------------------------------------------------------- /src/zcx_demo_abap_error_a.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCX_DEMO_ABAP_ERROR_A 7 | E 8 | ABAP cheat sheet exception class 9 | 40 10 | 1 11 | X 12 | X 13 | X 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/zcx_demo_abap_error_b.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcx_demo_abap_error_b DEFINITION 2 | PUBLIC 3 | INHERITING FROM cx_static_check 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | 9 | INTERFACES if_t100_message. 10 | INTERFACES if_t100_dyn_msg. 11 | 12 | METHODS constructor 13 | IMPORTING 14 | textid LIKE if_t100_message=>t100key OPTIONAL 15 | previous LIKE previous OPTIONAL. 16 | PROTECTED SECTION. 17 | PRIVATE SECTION. 18 | ENDCLASS. 19 | 20 | 21 | 22 | CLASS zcx_demo_abap_error_b IMPLEMENTATION. 23 | METHOD constructor ##ADT_SUPPRESS_GENERATION. 24 | super->constructor( previous = previous ). 25 | 26 | CLEAR me->textid. 27 | IF textid IS INITIAL. 28 | if_t100_message~t100key = if_t100_message=>default_textid. 29 | ELSE. 30 | if_t100_message~t100key = textid. 31 | ENDIF. 32 | ENDMETHOD. 33 | ENDCLASS. 34 | -------------------------------------------------------------------------------- /src/zcx_demo_abap_error_b.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZCX_DEMO_ABAP_ERROR_B 7 | E 8 | ABAP cheat sheet exception class 9 | 40 10 | 1 11 | X 12 | X 13 | X 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/zdemo_abap_abstract_ent.ddls.asddls: -------------------------------------------------------------------------------- 1 | @EndUserText.label: 'Demo abstract entity' 2 | define abstract entity zdemo_abap_abstract_ent 3 | { 4 | col1: abap.char(25); 5 | col2: abap.char(25); 6 | } 7 | -------------------------------------------------------------------------------- /src/zdemo_abap_abstract_ent.ddls.baseinfo: -------------------------------------------------------------------------------- 1 | { 2 | "BASEINFO": 3 | { 4 | "FROM": 5 | [], 6 | "ASSOCIATED": 7 | [], 8 | "BASE": 9 | [], 10 | "ANNO_REF": 11 | [], 12 | "SCALAR_FUNCTION": 13 | [], 14 | "VERSION":0, 15 | "ANNOREF_EVALUATION_ERROR":"" 16 | } 17 | } -------------------------------------------------------------------------------- /src/zdemo_abap_abstract_ent.ddls.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_ABSTRACT_ENT 7 | E 8 | Demo abstract entity 9 | A 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/zdemo_abap_carr.tabl.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_CARR 7 | E 8 | TRANSP 9 | X 10 | Demo table: Airline 11 | E 12 | A 13 | 1 14 | 15 | 16 | ZDEMO_ABAP_CARR 17 | A 18 | 0 19 | APPL0 20 | N 21 | 22 | 23 | 24 | MANDT 25 | X 26 | 0 27 | C 28 | 000006 29 | X 30 | CLNT 31 | 000003 32 | CLNT 33 | 34 | 35 | CARRID 36 | X 37 | 0 38 | C 39 | 000006 40 | X 41 | CHAR 42 | 000003 43 | CHAR 44 | 45 | 46 | CARRNAME 47 | 0 48 | C 49 | 000040 50 | X 51 | CHAR 52 | 000020 53 | CHAR 54 | 55 | 56 | CURRCODE 57 | 0 58 | C 59 | 000010 60 | X 61 | CUKY 62 | 000005 63 | CUKY 64 | 65 | 66 | URL 67 | 0 68 | C 69 | 000510 70 | X 71 | CHAR 72 | 000255 73 | CHAR 74 | 75 | 76 | 77 | 78 | ZDEMO_ABAP_CARR 79 | CUS_DEV_SUP_DA 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /src/zdemo_abap_carr_ve.ddls.asddls: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #NOT_REQUIRED 2 | define view entity ZDEMO_ABAP_CARR_VE 3 | as select from zdemo_abap_carr 4 | { 5 | key carrid, 6 | carrname, 7 | currcode, 8 | url 9 | } 10 | -------------------------------------------------------------------------------- /src/zdemo_abap_carr_ve.ddls.baseinfo: -------------------------------------------------------------------------------- 1 | { 2 | "BASEINFO": 3 | { 4 | "FROM": 5 | [ 6 | "ZDEMO_ABAP_CARR" 7 | ], 8 | "ASSOCIATED": 9 | [], 10 | "BASE": 11 | [], 12 | "ANNO_REF": 13 | [], 14 | "SCALAR_FUNCTION": 15 | [], 16 | "VERSION":0, 17 | "ANNOREF_EVALUATION_ERROR":"" 18 | } 19 | } -------------------------------------------------------------------------------- /src/zdemo_abap_carr_ve.ddls.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_CARR_VE 7 | E 8 | Demo CDS view entity 9 | W 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/zdemo_abap_cds_ve_agg_exp.ddls.asddls: -------------------------------------------------------------------------------- 1 | // ABAP CDS cheat sheet example: 2 | // Aggregate expressions in the element list of CDS view entities 3 | // 4 | //////////////////////////------ NOTES ------////////////////////////////////// 5 | // - CDS view entity selects from a demo database table 6 | // - Demonstrates various aggregate expressions in the element list 7 | // - As a prerequisite, run the class zcl_demo_abap_cds_ve to populate the 8 | // database tables of the example. Otherwise, no data is displayed. 9 | // 10 | //////////////////////------ DATA PREVIEW ------/////////////////////////////// 11 | // - Choose F8 in ADT to open the data preview and check out the data displayed 12 | // - For comparing and checking the output, you can also open the data preview 13 | // for the database table. In ADT, press and hold CTRL and click the database 14 | // table name. In the opened table artifact, choose F8 to open the data preview. 15 | // 16 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 17 | 18 | @AccessControl.authorizationCheck: #NOT_REQUIRED 19 | @EndUserText.label: 'CDS view entity: Aggregate expressions' 20 | define view entity zdemo_abap_cds_ve_agg_exp 21 | as select from zdemo_abap_fli 22 | 23 | { 24 | 25 | // The element list intentionally includes few fields only to focus on the effect of aggregate expressions. 26 | key carrid, 27 | currency, 28 | 29 | // -------- Aggregate expressions -------- 30 | // - Aggregate expressions can be used as elements of an element list. Other positions are possible. 31 | // - An alias name must be specified. 32 | // - A GROUP BY clause is required. It must list all non-aggregated fields from the element list. 33 | // - Additions: If ALL is used, all rows in the result set are respected. This is the default setting. 34 | // If DISTINCT is used, only distinct values of an argument are respected. 35 | // - Note: There may or may not be spaces between the parentheses following avg, min, etc., and the 36 | // content specified within. 37 | 38 | // AVG (Returns the average value of an argument) 39 | avg( seatsocc as abap.dec(15,2)) as avg_seats_occ, 40 | avg( cast(paymentsum as abap.dec(15, 2)) as abap.dec(15,2)) as avg_paysum, 41 | 42 | // SUM (Returns the sum of an argument) 43 | // Since a currency field is used in the example, an annotatin is required. 44 | @Semantics.amount.currencyCode: 'currency' 45 | sum(paymentsum) as total_paysum, 46 | 47 | // MIN (Returns the least value of an argument) 48 | min( seatsocc ) as min_occ_seats, 49 | 50 | // MAX (Returns the greatest value of an argument) 51 | max( seatsocc ) as max_occ_seats, 52 | max( all seatsocc ) as max_occ_seats_all, //Same result as above, ALL is optional 53 | 54 | // COUNT (Returns counted lines) 55 | count(*) as cnt, // * means that all lines are respected 56 | count(distinct planetype) as cnt_planetype //DISTINCT means that the number of dinstinct values if an argument is counted; 57 | //e.g. if 3 is returned, it means there are 3 different plane types among the result set 58 | 59 | } 60 | //GROUP BY clause that lists all non-aggregated fields from the element list 61 | group by 62 | carrid, 63 | currency 64 | -------------------------------------------------------------------------------- /src/zdemo_abap_cds_ve_agg_exp.ddls.baseinfo: -------------------------------------------------------------------------------- 1 | { 2 | "BASEINFO": 3 | { 4 | "FROM": 5 | [ 6 | "ZDEMO_ABAP_FLI" 7 | ], 8 | "ASSOCIATED": 9 | [], 10 | "BASE": 11 | [], 12 | "ANNO_REF": 13 | [], 14 | "SCALAR_FUNCTION": 15 | [], 16 | "VERSION":0, 17 | "ANNOREF_EVALUATION_ERROR":"" 18 | } 19 | } -------------------------------------------------------------------------------- /src/zdemo_abap_cds_ve_agg_exp.ddls.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_CDS_VE_AGG_EXP 7 | E 8 | CDS view entity: Aggregate expressions 9 | W 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/zdemo_abap_cds_ve_assoc.ddls.baseinfo: -------------------------------------------------------------------------------- 1 | { 2 | "BASEINFO": 3 | { 4 | "FROM": 5 | [ 6 | "ZDEMO_ABAP_CDS_VE_ASSOC_E", 7 | "ZDEMO_ABAP_CARR", 8 | "ZDEMO_ABAP_FLI" 9 | ], 10 | "ASSOCIATED": 11 | [ 12 | "ZDEMO_ABAP_CARR" 13 | ], 14 | "BASE": 15 | [], 16 | "ANNO_REF": 17 | [], 18 | "SCALAR_FUNCTION": 19 | [], 20 | "VERSION":0, 21 | "ANNOREF_EVALUATION_ERROR":"" 22 | } 23 | } -------------------------------------------------------------------------------- /src/zdemo_abap_cds_ve_assoc.ddls.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_CDS_VE_ASSOC 7 | E 8 | CDS view entity: Associations 9 | W 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/zdemo_abap_cds_ve_assoc_e.ddls.asddls: -------------------------------------------------------------------------------- 1 | // ABAP CDS cheat sheet example: Associations 2 | // 3 | //////////////////////////------ NOTES ------////////////////////////////////// 4 | // - CDS view entity that selects from a demo database table. 5 | // - The purpose of this CDS view entity is to demonstrate associations. The view 6 | // is used as a data source in another CDS view entity. 7 | // - As a prerequisite, run the class zcl_demo_abap_cds_ve to populate the 8 | // database tables of the example. Otherwise, no data is displayed. 9 | // 10 | //////////////////////------ DATA PREVIEW ------/////////////////////////////// 11 | // - Choose F8 in ADT to open the data preview and check out the data displayed 12 | // 13 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 14 | 15 | @AccessControl.authorizationCheck: #NOT_REQUIRED 16 | @EndUserText.label: 'CDS view entity: Associations' 17 | define view entity zdemo_abap_cds_ve_assoc_e 18 | as select from zdemo_abap_flsch as _flsch 19 | association [1..1] to zdemo_abap_carr as _carr_exp on _flsch.carrid = _carr_exp.carrid 20 | association [1..*] to zdemo_abap_fli as _fli on _flsch.carrid = _fli.carrid and _flsch.connid = _fli.connid 21 | 22 | { 23 | key _flsch.carrid as Carrid, 24 | key _flsch.connid as Connid, 25 | _flsch.countryfr as Countryfr, 26 | _flsch.cityfrom as Cityfrom, 27 | _flsch.airpfrom as Airpfrom, 28 | _flsch.countryto as Countryto, 29 | _flsch.cityto as Cityto, 30 | _flsch.airpto as Airpto, 31 | _flsch.fltime as Fltime, 32 | _flsch.deptime as Deptime, 33 | _flsch.arrtime as Arrtime, 34 | _flsch.distance as Distance, 35 | _flsch.distid as Distid, 36 | _flsch.fltype as Fltype, 37 | _flsch.period as Period, 38 | _carr_exp, 39 | _fli 40 | } 41 | -------------------------------------------------------------------------------- /src/zdemo_abap_cds_ve_assoc_e.ddls.baseinfo: -------------------------------------------------------------------------------- 1 | { 2 | "BASEINFO": 3 | { 4 | "FROM": 5 | [ 6 | "ZDEMO_ABAP_FLSCH" 7 | ], 8 | "ASSOCIATED": 9 | [ 10 | "ZDEMO_ABAP_CARR", 11 | "ZDEMO_ABAP_FLI" 12 | ], 13 | "BASE": 14 | [], 15 | "ANNO_REF": 16 | [], 17 | "SCALAR_FUNCTION": 18 | [], 19 | "VERSION":0, 20 | "ANNOREF_EVALUATION_ERROR":"" 21 | } 22 | } -------------------------------------------------------------------------------- /src/zdemo_abap_cds_ve_assoc_e.ddls.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_CDS_VE_ASSOC_E 7 | E 8 | CDS view entity: Associations 9 | W 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/zdemo_abap_cds_ve_joins.ddls.asddls: -------------------------------------------------------------------------------- 1 | // ABAP CDS cheat sheet example: Joins 2 | // 3 | //////////////////////////------ NOTES ------////////////////////////////////// 4 | // - CDS view entity selects from a demo database table 5 | // - Demonstrates various joins 6 | // - As a prerequisite, run the class zcl_demo_abap_cds_ve to populate the 7 | // database tables of the example. Otherwise, no data is displayed. 8 | // It is particularly needed in this case because it contains entries to 9 | // visualize the effect of outer joins. 10 | // - HOW TO: 11 | // - To reduce the number of separate artifacts, this example CDS view entity 12 | // contains the code for multiple joins, which is commented out. 13 | // - To test out various joins, you can comment out and comment in the 14 | // respective code sections (select the lines and choose CTRL + 7). 15 | // - The example for inner joins is commented in by default. The relevant 16 | // code sections are marked with "COMMENT IN/OUT ... START" and 17 | // "COMMENT IN/OUT ... END" in both SELECT and element list 18 | // (inner joins -> 1a / 1b). To test the left outer joins, for example, 19 | // comment out the respective sections of the inner join and comment in 20 | // the sections for left outer joins (2a, 2b), and so on. 21 | // - Once done, activate the view and choose F8 to open the data preview. 22 | // You must activate the view and choose F8 again for every change here 23 | // because the alias names are different. 24 | // 25 | //////////////////////------ DATA PREVIEW ------/////////////////////////////// 26 | // - Choose F8 in ADT to open the data preview and check out the data displayed 27 | // - Note the hints above regarding commenting in/out of code. 28 | // 29 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 30 | 31 | @AccessControl.authorizationCheck: #NOT_REQUIRED 32 | @EndUserText.label: 'CDS view entity: Joins' 33 | define view entity zdemo_abap_cds_ve_joins 34 | as select from zdemo_abap_carr as _carr 35 | 36 | // Notes on joins: 37 | // - Joins combine two data sources into one result set, consisting of columns of both data sources 38 | // - Rows of the result set are determined by the join type and by join conditions between columns of the data sources 39 | // - Joins can be nested 40 | // - Inner or outer join must contain a join condition after ON 41 | // - Each element of the SELECT list must have the name of its data source as prefix 42 | // - When joins are used, a WHERE condition affects the result set 43 | // - The cardinality can be specified for left outer joins. For more details, see the ABAP Keyword Documentation. 44 | 45 | /////////////////// ----- Example for INNER JOIN ----- ///////////////////////////////// 46 | // Notes: 47 | // - Joins all entries of the data sources whose fields match the ON condition 48 | // - In the table zdemo_abap_carr, there are entries in carrid that are not present in zdemo_abap_flsch. 49 | // The same is true the other way round. The result only contains those entries that exist in both data sources 50 | // based on the ON condition. 51 | 52 | //// ----> COMMENT IN/OUT 1a START <----- 53 | inner join zdemo_abap_flsch as _flsch_in on _carr.carrid = _flsch_in.carrid 54 | //// ----> COMMENT IN/OUT 1a END <----- 55 | 56 | //Alternative syntax: Specifying 'inner' is optional 57 | // join zdemo_abap_flsch 58 | // as _flsch_in on _carr.carrid = _flsch_in.carrid 59 | 60 | /////////////////// ----- Example for LEFT OUTER JOIN ----- ///////////////////////////////// 61 | // Notes: 62 | // - The join selects all entries on the left side. Entries that match the ON condition have the same content as in the inner join. 63 | // In entries that do not match the ON condition, the elements on the right side have the null value. 64 | // - To demonstrate the effect, the table zdemo_abap_carr contains entries for carrid that are not present in zdemo_abap_flsch. 65 | // - Example in the element list: 66 | // - The coalesce function can be used to prevent null values in the result set. 67 | // - In the example, the function is used for an element to prevent null values. 68 | 69 | //// ----> COMMENT IN/OUT 2A START <----- 70 | // left outer join zdemo_abap_flsch as _flsch_lo on _carr.carrid = _flsch_lo.carrid 71 | //// ----> COMMENT IN/OUT 2A END <----- 72 | 73 | /////////////////// ----- Example for RIGHT OUTER JOIN ----- ///////////////////////////////// 74 | // Notes: 75 | // - The join selects all entries on the right side. Entries that match the ON condition have the same content as in the inner join. 76 | // In entries that do not match the ON condition, the elements on the left side have the null value. 77 | // - To demonstrate the effect, the table zdemo_abap_carr contains entries for carrid that are not present in zdemo_abap_flsch. 78 | // - Example in the element list: 79 | // - Instead of the coalesce function, you can also use a CASE expression using a logical expression with IS [NOT] NULL 80 | // to prevent null values in the result set. 81 | // - In the example, a CASE expression is used for an element to prevent null values. 82 | 83 | //// ----> COMMENT IN/OUT 3A START <----- 84 | // right outer join zdemo_abap_flsch as _flsch_ro on _carr.carrid = _flsch_ro.carrid 85 | //// ----> COMMENT IN/OUT 3A END <----- 86 | 87 | /////////////////// ----- Example for CROSS JOIN ----- ///////////////////////////////// 88 | // Notes: 89 | // - All entries on the left side are combined with all entries on the right side. 90 | // - It is not possible to specify an ON condition. 91 | //- The number of lines of the result is the number of left lines multiplied by the number of lines of the right table. 92 | 93 | //// ----> COMMENT IN/OUT 4A START <----- 94 | // cross join zdemo_abap_flsch as _flsch_cr 95 | //// ----> COMMENT IN/OUT 4A END <----- 96 | 97 | { 98 | key _carr.carrid, 99 | _carr.carrname, 100 | 101 | /////////////////// ----- Example for INNER JOIN ----- ///////////////////////////////// 102 | 103 | // ----> COMMENT IN/OUT 1b START <----- 104 | _flsch_in.cityfrom as cityfr_in, 105 | _flsch_in.cityto as cityto_in 106 | // ----> COMMENT IN/OUT 1b END <----- 107 | 108 | /////////////////// ----- Example for LEFT OUTER JOIN ----- ///////////////////////////////// 109 | 110 | //// ----> COMMENT IN/OUT 2b START <----- 111 | // _flsch_lo.cityfrom as cityfr_lo, 112 | // coalesce(_flsch_lo.cityto, '???') as cityto_lo 113 | //// ----> COMMENT IN/OUT 2b END <----- 114 | 115 | /////////////////// ----- Example for RIGHT OUTER JOIN ----- ///////////////////////////////// 116 | 117 | //// ----> COMMENT IN/OUT 3b START <----- 118 | // case when _carr.url is not null then _carr.url 119 | // else '!!!' 120 | // end as url_ro, 121 | // _flsch_ro.cityfrom as cityfr_ro, 122 | // _flsch_ro.cityto as cityto_ro 123 | //// ----> COMMENT IN/OUT 3b END <----- 124 | 125 | /////////////////// ----- Example for CROSS JOIN ----- ///////////////////////////////// 126 | 127 | //// ----> COMMENT IN/OUT 4b START <----- 128 | // _flsch_cr.cityfrom as cityfr_cr, 129 | // _flsch_cr.cityto as cityto_cr 130 | //// ----> COMMENT IN/OUT 4b END <----- 131 | 132 | } 133 | -------------------------------------------------------------------------------- /src/zdemo_abap_cds_ve_joins.ddls.baseinfo: -------------------------------------------------------------------------------- 1 | { 2 | "BASEINFO": 3 | { 4 | "FROM": 5 | [ 6 | "ZDEMO_ABAP_CARR", 7 | "ZDEMO_ABAP_FLSCH" 8 | ], 9 | "ASSOCIATED": 10 | [], 11 | "BASE": 12 | [], 13 | "ANNO_REF": 14 | [], 15 | "SCALAR_FUNCTION": 16 | [], 17 | "VERSION":0, 18 | "ANNOREF_EVALUATION_ERROR":"" 19 | } 20 | } -------------------------------------------------------------------------------- /src/zdemo_abap_cds_ve_joins.ddls.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_CDS_VE_JOINS 7 | E 8 | CDS view entity: Joins 9 | W 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/zdemo_abap_cds_ve_sel.ddls.baseinfo: -------------------------------------------------------------------------------- 1 | { 2 | "BASEINFO": 3 | { 4 | "FROM": 5 | [ 6 | "ZDEMO_ABAP_FLI" 7 | ], 8 | "ASSOCIATED": 9 | [], 10 | "BASE": 11 | [], 12 | "ANNO_REF": 13 | [], 14 | "SCALAR_FUNCTION": 15 | [], 16 | "VERSION":0, 17 | "ANNOREF_EVALUATION_ERROR":"" 18 | } 19 | } -------------------------------------------------------------------------------- /src/zdemo_abap_cds_ve_sel.ddls.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_CDS_VE_SEL 7 | E 8 | CDS view entity: Operands and expressions 9 | W 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/zdemo_abap_draft.tabl.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_DRAFT 7 | E 8 | TRANSP 9 | X 10 | X 11 | Draft table for RAP calculator 12 | E 13 | X 14 | A 15 | 1 16 | 17 | 18 | ZDEMO_ABAP_DRAFT 19 | A 20 | 0 21 | APPL0 22 | N 23 | 24 | 25 | 26 | CLIENT 27 | X 28 | 0 29 | C 30 | 000006 31 | X 32 | CLNT 33 | 000003 34 | CLNT 35 | 36 | 37 | ID 38 | X 39 | SYSUUID_X16 40 | 0 41 | X 42 | E 43 | 44 | 45 | DRAFTUUID 46 | X 47 | SYSUUID_X16 48 | 0 49 | X 50 | E 51 | 52 | 53 | NUM1 54 | 0 55 | X 56 | 000004 57 | INT4 58 | 000010 59 | INT4 60 | 61 | 62 | ARITHM_OP 63 | 0 64 | C 65 | 000002 66 | CHAR 67 | 000001 68 | CHAR 69 | 70 | 71 | NUM2 72 | 0 73 | X 74 | 000004 75 | INT4 76 | 000010 77 | INT4 78 | 79 | 80 | CALC_RESULT 81 | 0 82 | g 83 | 000008 84 | STRG 85 | STRG 86 | 87 | 88 | CREA_DATE_TIME 89 | TIMESTAMPL 90 | 0 91 | E 92 | 93 | 94 | LCHG_DATE_TIME 95 | TIMESTAMPL 96 | 0 97 | E 98 | 99 | 100 | .INCLUDE 101 | 0 102 | SYCH_BDL_DRAFT_ADMIN_INC 103 | S 104 | Standard Include for Draft Administration (BDL Syntax Check) 105 | S 106 | %ADMIN 107 | 108 | 109 | 110 | 111 | ZDEMO_ABAP_DRAFT 112 | CUS_DEV_SUP_DA 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /src/zdemo_abap_fli.tabl.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_FLI 7 | E 8 | TRANSP 9 | X 10 | Demo table: Flight 11 | E 12 | A 13 | 1 14 | 15 | 16 | ZDEMO_ABAP_FLI 17 | A 18 | 0 19 | APPL0 20 | N 21 | 22 | 23 | 24 | MANDT 25 | X 26 | 0 27 | C 28 | 000006 29 | X 30 | CLNT 31 | 000003 32 | CLNT 33 | 34 | 35 | CARRID 36 | X 37 | 0 38 | C 39 | 000006 40 | X 41 | CHAR 42 | 000003 43 | CHAR 44 | 45 | 46 | CONNID 47 | X 48 | 0 49 | N 50 | 000008 51 | X 52 | NUMC 53 | 000004 54 | NUMC 55 | 56 | 57 | FLDATE 58 | X 59 | 0 60 | D 61 | 000016 62 | X 63 | DATS 64 | 000008 65 | DATS 66 | T 67 | 68 | 69 | PRICE 70 | 0 71 | P 72 | 000008 73 | ZDEMO_ABAP_FLI 74 | CURRENCY 75 | CURR 76 | 000015 77 | 000002 78 | CURR 79 | 80 | 81 | CURRENCY 82 | 0 83 | C 84 | 000010 85 | X 86 | CUKY 87 | 000005 88 | CUKY 89 | 90 | 91 | PLANETYPE 92 | 0 93 | C 94 | 000020 95 | X 96 | CHAR 97 | 000010 98 | CHAR 99 | 100 | 101 | SEATSMAX 102 | 0 103 | X 104 | 000004 105 | X 106 | INT4 107 | 000010 108 | INT4 109 | 110 | 111 | SEATSOCC 112 | 0 113 | X 114 | 000004 115 | X 116 | INT4 117 | 000010 118 | INT4 119 | 120 | 121 | PAYMENTSUM 122 | 0 123 | P 124 | 000009 125 | ZDEMO_ABAP_FLI 126 | CURRENCY 127 | X 128 | CURR 129 | 000017 130 | 000002 131 | CURR 132 | 133 | 134 | SEATSMAX_B 135 | 0 136 | X 137 | 000004 138 | X 139 | INT4 140 | 000010 141 | INT4 142 | 143 | 144 | SEATSOCC_B 145 | 0 146 | X 147 | 000004 148 | X 149 | INT4 150 | 000010 151 | INT4 152 | 153 | 154 | SEATSMAX_F 155 | 0 156 | X 157 | 000004 158 | X 159 | INT4 160 | 000010 161 | INT4 162 | 163 | 164 | SEATSOCC_F 165 | 0 166 | X 167 | 000004 168 | X 169 | INT4 170 | 000010 171 | INT4 172 | 173 | 174 | 175 | 176 | ZDEMO_ABAP_FLI 177 | CUS_DEV_SUP_DA 178 | 179 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /src/zdemo_abap_fli_ve.ddls.asddls: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #NOT_REQUIRED 2 | define view entity ZDEMO_ABAP_FLI_VE 3 | as select from zdemo_abap_fli 4 | { 5 | key carrid, 6 | key connid, 7 | key fldate, 8 | price, 9 | currency, 10 | planetype, 11 | seatsmax, 12 | seatsocc, 13 | paymentsum, 14 | seatsmax_b, 15 | seatsocc_b, 16 | seatsmax_f, 17 | seatsocc_f 18 | } 19 | -------------------------------------------------------------------------------- /src/zdemo_abap_fli_ve.ddls.baseinfo: -------------------------------------------------------------------------------- 1 | { 2 | "BASEINFO": 3 | { 4 | "FROM": 5 | [ 6 | "ZDEMO_ABAP_FLI" 7 | ], 8 | "ASSOCIATED": 9 | [], 10 | "BASE": 11 | [], 12 | "ANNO_REF": 13 | [], 14 | "SCALAR_FUNCTION": 15 | [], 16 | "VERSION":0, 17 | "ANNOREF_EVALUATION_ERROR":"" 18 | } 19 | } -------------------------------------------------------------------------------- /src/zdemo_abap_fli_ve.ddls.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_FLI_VE 7 | E 8 | Demo CDS view entity 9 | W 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/zdemo_abap_flsch.tabl.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_FLSCH 7 | E 8 | TRANSP 9 | X 10 | Demo table: Flight schedule 11 | E 12 | X 13 | A 14 | 1 15 | 16 | 17 | ZDEMO_ABAP_FLSCH 18 | A 19 | 0 20 | APPL0 21 | N 22 | 23 | 24 | 25 | MANDT 26 | X 27 | 0 28 | C 29 | 000006 30 | X 31 | CLNT 32 | 000003 33 | CLNT 34 | 35 | 36 | CARRID 37 | X 38 | 0 39 | C 40 | 000006 41 | X 42 | CHAR 43 | 000003 44 | CHAR 45 | 46 | 47 | CONNID 48 | X 49 | 0 50 | N 51 | 000008 52 | X 53 | NUMC 54 | 000004 55 | NUMC 56 | 57 | 58 | COUNTRYFR 59 | 0 60 | C 61 | 000006 62 | CHAR 63 | 000003 64 | CHAR 65 | 66 | 67 | CITYFROM 68 | 0 69 | C 70 | 000040 71 | X 72 | CHAR 73 | 000020 74 | CHAR 75 | 76 | 77 | AIRPFROM 78 | 0 79 | C 80 | 000006 81 | X 82 | CHAR 83 | 000003 84 | CHAR 85 | 86 | 87 | COUNTRYTO 88 | 0 89 | C 90 | 000006 91 | CHAR 92 | 000003 93 | CHAR 94 | 95 | 96 | CITYTO 97 | 0 98 | C 99 | 000040 100 | X 101 | CHAR 102 | 000020 103 | CHAR 104 | 105 | 106 | AIRPTO 107 | 0 108 | C 109 | 000006 110 | X 111 | CHAR 112 | 000003 113 | CHAR 114 | 115 | 116 | FLTIME 117 | 0 118 | X 119 | 000004 120 | X 121 | INT4 122 | 000010 123 | INT4 124 | 125 | 126 | DEPTIME 127 | 0 128 | T 129 | 000012 130 | X 131 | TIMS 132 | 000006 133 | TIMS 134 | T 135 | 136 | 137 | ARRTIME 138 | 0 139 | T 140 | 000012 141 | X 142 | TIMS 143 | 000006 144 | TIMS 145 | T 146 | 147 | 148 | DISTANCE 149 | 0 150 | P 151 | 000005 152 | ZDEMO_ABAP_FLSCH 153 | DISTID 154 | X 155 | QUAN 156 | 000009 157 | 000004 158 | QUAN 159 | 160 | 161 | DISTID 162 | 0 163 | C 164 | 000006 165 | X 166 | UNIT 167 | 000003 168 | UNIT 169 | 170 | 171 | FLTYPE 172 | 0 173 | C 174 | 000002 175 | X 176 | CHAR 177 | 000001 178 | CHAR 179 | 180 | 181 | PERIOD 182 | 0 183 | X 184 | 000001 185 | X 186 | INT1 187 | 000003 188 | INT1 189 | 190 | 191 | 192 | 193 | ZDEMO_ABAP_FLSCH 194 | CUS_DEV_SUP_DA 195 | 196 | 197 | 198 | 199 | 200 | -------------------------------------------------------------------------------- /src/zdemo_abap_flsch_ve.ddls.asddls: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #NOT_REQUIRED 2 | define view entity ZDEMO_ABAP_FLSCH_VE 3 | as select from zdemo_abap_flsch 4 | { 5 | key carrid, 6 | key connid, 7 | countryfr, 8 | cityfrom, 9 | airpfrom, 10 | countryto, 11 | cityto, 12 | airpto, 13 | fltime, 14 | deptime, 15 | arrtime, 16 | distance, 17 | distid, 18 | fltype, 19 | period 20 | } 21 | -------------------------------------------------------------------------------- /src/zdemo_abap_flsch_ve.ddls.baseinfo: -------------------------------------------------------------------------------- 1 | { 2 | "BASEINFO": 3 | { 4 | "FROM": 5 | [ 6 | "ZDEMO_ABAP_FLSCH" 7 | ], 8 | "ASSOCIATED": 9 | [], 10 | "BASE": 11 | [], 12 | "ANNO_REF": 13 | [], 14 | "SCALAR_FUNCTION": 15 | [], 16 | "VERSION":0, 17 | "ANNOREF_EVALUATION_ERROR":"" 18 | } 19 | } -------------------------------------------------------------------------------- /src/zdemo_abap_flsch_ve.ddls.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_FLSCH_VE 7 | E 8 | Demo CDS view entity 9 | W 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/zdemo_abap_get_data_itf.intf.abap: -------------------------------------------------------------------------------- 1 | "!

Interface supporting the ABAP Unit Tests example class 2 | "!
ABAP cheat sheet example interface

3 | "! 4 | "!

Note

5 | "!

Find the disclaimer in the ABAP Doc comment of class {@link zcl_demo_abap_aux}.

6 | INTERFACE zdemo_abap_get_data_itf 7 | PUBLIC. 8 | 9 | TYPES: carr_tab TYPE TABLE OF zdemo_abap_fli WITH EMPTY KEY, 10 | occ_rate TYPE p LENGTH 4 DECIMALS 2. 11 | 12 | METHODS: select_flight_data IMPORTING carrier TYPE zdemo_abap_fli-carrid 13 | RETURNING VALUE(flight_data) TYPE carr_tab, 14 | say_hello RETURNING VALUE(hi) TYPE string. 15 | 16 | ENDINTERFACE. 17 | -------------------------------------------------------------------------------- /src/zdemo_abap_get_data_itf.intf.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_GET_DATA_ITF 7 | E 8 | Interface for ABAP cheat sheet example 9 | 2 10 | 1 11 | X 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/zdemo_abap_messages.msag.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_MESSAGES 7 | E 8 | ABAP cheat sheet message class 9 | 10 | 11 | 12 | E 13 | ZDEMO_ABAP_MESSAGES 14 | 001 15 | An error occured (Nr. 001) 16 | 17 | 18 | E 19 | ZDEMO_ABAP_MESSAGES 20 | 002 21 | Exception raised (Nr. 002) 22 | 23 | 24 | E 25 | ZDEMO_ABAP_MESSAGES 26 | 003 27 | Test message (Nr. 003) &1 &2 28 | 29 | 30 | E 31 | ZDEMO_ABAP_MESSAGES 32 | 004 33 | Message (Nr. 004) p1: "&1" p2: "&2" p3: "&3" p4: "&4" 34 | 35 | 36 | E 37 | ZDEMO_ABAP_MESSAGES 38 | 005 39 | &1 &2 &3 &4 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/zdemo_abap_objects_interface.intf.abap: -------------------------------------------------------------------------------- 1 | "!

Interface supporting the ABAP object orientation example class 2 | "!
ABAP cheat sheet example interface

3 | "! 4 | "!

Note

5 | "!

Find the disclaimer in the ABAP Doc comment of class {@link zcl_demo_abap_aux}.

6 | INTERFACE zdemo_abap_objects_interface 7 | PUBLIC. 8 | 9 | METHODS: double IMPORTING i_op TYPE i 10 | RETURNING VALUE(r_double) TYPE i, 11 | 12 | triple DEFAULT IGNORE IMPORTING i_op TYPE i 13 | RETURNING VALUE(r_triple) TYPE i . 14 | 15 | DATA in_str TYPE string. 16 | 17 | CLASS-METHODS: halve IMPORTING i_op TYPE i 18 | RETURNING VALUE(r_halve) TYPE i. 19 | 20 | CLASS-DATA: stat_str TYPE string. 21 | 22 | CONSTANTS const_intf TYPE i VALUE 987. 23 | 24 | TYPES c3 TYPE c LENGTH 3. 25 | DATA add_result TYPE i. 26 | CLASS-DATA: subtr_result TYPE i. 27 | METHODS addition IMPORTING num1 TYPE i 28 | num2 TYPE i. 29 | CLASS-METHODS subtraction IMPORTING num1 TYPE i 30 | num2 TYPE i. 31 | 32 | METHODS meth_ignore DEFAULT IGNORE RETURNING VALUE(int) TYPE i. 33 | METHODS meth_fail DEFAULT FAIL RETURNING VALUE(int) TYPE i. 34 | 35 | ENDINTERFACE. 36 | -------------------------------------------------------------------------------- /src/zdemo_abap_objects_interface.intf.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_OBJECTS_INTERFACE 7 | E 8 | Interface for ABAP cheat sheet example 9 | 2 10 | 1 11 | X 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/zdemo_abap_rap_calc_sd.srvd.srvdsrv: -------------------------------------------------------------------------------- 1 | @EndUserText.label: 'Service definition for RAP Calculator' 2 | define service ZDEMO_ABAP_RAP_CALC_SD { 3 | expose ZDEMO_ABAP_RAP_DRAFT_M; 4 | } -------------------------------------------------------------------------------- /src/zdemo_abap_rap_calc_sd.srvd.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_RAP_CALC_SD 7 | SRVD/SRV 8 | Service definition for RAP Calculator 9 | EN 10 | EN 11 | ./zdemo_abap_rap_calc_sd/source/main 12 | ABAP_SOURCE 13 | ABAP Development Tools 14 | S 15 | Definition 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ch_m.ddls.asddls: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #NOT_REQUIRED 2 | define view entity ZDEMO_ABAP_RAP_CH_M 3 | as select from zdemo_abap_rapt2 4 | association to parent ZDEMO_ABAP_RAP_RO_M 5 | as _parent on $projection.key_field = _parent.key_field 6 | { 7 | _parent, 8 | key key_field, 9 | key key_ch, 10 | field_ch1, 11 | field_ch2 12 | } 13 | -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ch_m.ddls.baseinfo: -------------------------------------------------------------------------------- 1 | { 2 | "BASEINFO": 3 | { 4 | "FROM": 5 | [ 6 | "ZDEMO_ABAP_RAPT2" 7 | ], 8 | "ASSOCIATED": 9 | [ 10 | "ZDEMO_ABAP_RAP_RO_M" 11 | ], 12 | "BASE": 13 | [], 14 | "ANNO_REF": 15 | [], 16 | "SCALAR_FUNCTION": 17 | [], 18 | "VERSION":0, 19 | "ANNOREF_EVALUATION_ERROR":"" 20 | } 21 | } -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ch_m.ddls.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_RAP_CH_M 7 | E 8 | CDS view entity (child) 9 | W 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ch_u.ddls.asddls: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #NOT_REQUIRED 2 | define view entity ZDEMO_ABAP_RAP_CH_U 3 | as select from zdemo_abap_rapt2 4 | association to parent ZDEMO_ABAP_RAP_RO_U 5 | as _parent on $projection.key_field = _parent.key_field 6 | { 7 | _parent, 8 | key key_field, 9 | key key_ch, 10 | field_ch1, 11 | field_ch2 12 | } 13 | -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ch_u.ddls.baseinfo: -------------------------------------------------------------------------------- 1 | { 2 | "BASEINFO": 3 | { 4 | "FROM": 5 | [ 6 | "ZDEMO_ABAP_RAPT2" 7 | ], 8 | "ASSOCIATED": 9 | [ 10 | "ZDEMO_ABAP_RAP_RO_U" 11 | ], 12 | "BASE": 13 | [], 14 | "ANNO_REF": 15 | [], 16 | "SCALAR_FUNCTION": 17 | [], 18 | "VERSION":0, 19 | "ANNOREF_EVALUATION_ERROR":"" 20 | } 21 | } -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ch_u.ddls.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_RAP_CH_U 7 | E 8 | CDS view entity (child) 9 | W 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/zdemo_abap_rap_draft_m.bdef.asbdef: -------------------------------------------------------------------------------- 1 | managed implementation in class zbp_demo_abap_rap_draft_m unique; 2 | strict(2); 3 | with draft; 4 | 5 | define behavior for ZDEMO_ABAP_RAP_DRAFT_M alias calc 6 | persistent table zdemo_abap_tabca 7 | draft table zdemo_abap_draft 8 | lock master 9 | total etag crea_date_time 10 | etag master lchg_date_time 11 | authorization master ( global ) 12 | late numbering 13 | { 14 | create; 15 | update; 16 | delete; 17 | field ( readonly ) id, calc_result, crea_date_time, lchg_date_time; 18 | field ( mandatory ) num1, num2, arithm_op; 19 | static action delete_all; 20 | internal action calculation; 21 | side effects { field num1 affects field calc_result; 22 | field num2 affects field calc_result; 23 | field arithm_op affects field calc_result; } 24 | validation validate on save { create; field num1, arithm_op, num2; } 25 | determination det_modify on modify { field num1, num2, arithm_op; } 26 | draft action Resume; 27 | draft action Edit; 28 | draft action Activate optimized; 29 | draft action Discard; 30 | draft determine action Prepare 31 | { 32 | validation validate; 33 | } 34 | } -------------------------------------------------------------------------------- /src/zdemo_abap_rap_draft_m.bdef.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_RAP_DRAFT_M 7 | BDEF/BDO 8 | BDEF, managed, draft, late numbering 9 | 60 10 | EN 11 | 12 | 13 | ./zdemo_abap_rap_draft_m/source/main/versions 14 | http://www.sap.com/adt/relations/versions 15 | Historic versions 16 | 17 | 18 | ./zdemo_abap_rap_draft_m/source/main 19 | http://www.sap.com/adt/relations/source 20 | text/plain 21 | Source Content 22 | 23 | 24 | ./zdemo_abap_rap_draft_m/source/main 25 | http://www.sap.com/adt/relations/source 26 | text/html 27 | Source Content (HTML) 28 | 29 | 30 | EN 31 | 5 32 | ./zdemo_abap_rap_draft_m/source/main 33 | ABAP_SOURCE 34 | true 35 | true 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/zdemo_abap_rap_draft_m.ddls.asddls: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #NOT_REQUIRED 2 | 3 | @ObjectModel.semanticKey: ['id'] 4 | @UI: { 5 | headerInfo: { 6 | typeName: 'Calculation', 7 | typeNamePlural: 'Calculations', 8 | title: { type: #STANDARD, value: 'id' } 9 | } 10 | } 11 | 12 | define root view entity ZDEMO_ABAP_RAP_DRAFT_M 13 | as select from zdemo_abap_tabca 14 | { 15 | 16 | @UI.facet: [ 17 | { 18 | id: 'calc', 19 | purpose: #STANDARD, 20 | type: #IDENTIFICATION_REFERENCE, 21 | label: 'Calculation', 22 | position: 10 23 | }] 24 | 25 | @EndUserText.label: 'Calculation ID' 26 | @UI: { lineItem: [ { importance: #HIGH, position: 10, 27 | label: 'Calculation ID' }, 28 | { type: #FOR_ACTION, dataAction: 'delete_all', 29 | label: 'Delete All Persisted Calculations' } ], 30 | fieldGroup: [ { qualifier: 'Fieldgroup:HeaderItems', 31 | position: 10 } ] } 32 | key id, 33 | @UI: { lineItem: [ { importance: #HIGH, position: 20, 34 | label: '1st Operand' } ], 35 | identification: [ { position: 20, 36 | label: '1st Operand' } ], 37 | fieldGroup: [ { qualifier: 'CaluclationItems', 38 | position: 10 } ] } 39 | num1, 40 | @UI: { lineItem: [ { importance: #HIGH, position: 30, 41 | label: 'Operator' } ], 42 | identification: [ { position: 30, label: 'Operator' } ], 43 | fieldGroup: [ { qualifier: 'CaluclationItems', 44 | position: 20 } ] } 45 | arithm_op, 46 | @UI: { lineItem: [ { importance: #HIGH, position: 40, 47 | label: '2nd Operand' } ], 48 | identification: [ { position: 40, 49 | label: '2nd Operand' } ], 50 | fieldGroup: [ { qualifier: 'CaluclationItems', 51 | position: 30 } ] } 52 | num2, 53 | @UI: { lineItem: [ { importance: #HIGH, position: 50, 54 | label: 'Result' } ], 55 | identification: [ { position: 50, label: 'Result' } ], 56 | fieldGroup: [ { qualifier: 'CaluclationItems', 57 | position: 40 } ] } 58 | calc_result, 59 | @UI: { hidden: true } 60 | @Semantics.systemDateTime.lastChangedAt: true 61 | crea_date_time, 62 | @EndUserText.label: 'Last Changed At' 63 | @UI: { fieldGroup: [ { qualifier: 'Fieldgroup:HeaderItems', 64 | position: 20 } ] } 65 | @Semantics.systemDateTime.localInstanceLastChangedAt: true 66 | lchg_date_time 67 | } 68 | -------------------------------------------------------------------------------- /src/zdemo_abap_rap_draft_m.ddls.baseinfo: -------------------------------------------------------------------------------- 1 | { 2 | "BASEINFO": 3 | { 4 | "FROM": 5 | [ 6 | "ZDEMO_ABAP_TABCA" 7 | ], 8 | "ASSOCIATED": 9 | [], 10 | "BASE": 11 | [], 12 | "ANNO_REF": 13 | [], 14 | "SCALAR_FUNCTION": 15 | [], 16 | "VERSION":0, 17 | "ANNOREF_EVALUATION_ERROR":"" 18 | } 19 | } -------------------------------------------------------------------------------- /src/zdemo_abap_rap_draft_m.ddls.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_RAP_DRAFT_M 7 | E 8 | CDS root view entity 9 | W 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ro_m.bdef.asbdef: -------------------------------------------------------------------------------- 1 | managed implementation in class zbp_demo_abap_rap_ro_m unique; 2 | strict(2); 3 | 4 | define behavior for ZDEMO_ABAP_RAP_RO_M alias root 5 | persistent table zdemo_abap_rapt1 6 | lock master 7 | authorization master ( global ) 8 | 9 | { 10 | create; 11 | update; 12 | delete; 13 | association _child { create; } 14 | action multiply_by_2; 15 | validation val on save { field field3; } 16 | determination det_add_text on save { create; } 17 | field ( readonly:update ) key_field; 18 | } 19 | 20 | define behavior for ZDEMO_ABAP_RAP_CH_M alias child 21 | persistent table zdemo_abap_rapt2 22 | lock dependent by _parent 23 | authorization dependent by _parent 24 | { 25 | update; 26 | delete; 27 | field ( readonly ) key_field; 28 | field ( readonly:update ) key_ch; 29 | association _parent; 30 | } -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ro_m.bdef.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_RAP_RO_M 7 | BDEF/BDO 8 | BDEF, managed, external numbering 9 | 60 10 | EN 11 | 12 | 13 | ./zdemo_abap_rap_ro_m/source/main/versions 14 | http://www.sap.com/adt/relations/versions 15 | Historic versions 16 | 17 | 18 | ./zdemo_abap_rap_ro_m/source/main 19 | http://www.sap.com/adt/relations/source 20 | text/plain 21 | Source Content 22 | 23 | 24 | ./zdemo_abap_rap_ro_m/source/main 25 | http://www.sap.com/adt/relations/source 26 | text/html 27 | Source Content (HTML) 28 | 29 | 30 | EN 31 | 5 32 | ./zdemo_abap_rap_ro_m/source/main 33 | ABAP_SOURCE 34 | true 35 | true 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ro_m.ddls.asddls: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #NOT_REQUIRED 2 | define root view entity ZDEMO_ABAP_RAP_RO_M 3 | as select from zdemo_abap_rapt1 4 | composition [0..*] of ZDEMO_ABAP_RAP_CH_M as _child 5 | { 6 | key key_field, 7 | field1, 8 | field2, 9 | field3, 10 | field4, 11 | _child 12 | } 13 | -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ro_m.ddls.baseinfo: -------------------------------------------------------------------------------- 1 | { 2 | "BASEINFO": 3 | { 4 | "FROM": 5 | [ 6 | "ZDEMO_ABAP_RAPT1" 7 | ], 8 | "ASSOCIATED": 9 | [ 10 | "ZDEMO_ABAP_RAP_CH_M" 11 | ], 12 | "BASE": 13 | [], 14 | "ANNO_REF": 15 | [], 16 | "SCALAR_FUNCTION": 17 | [], 18 | "VERSION":0, 19 | "ANNOREF_EVALUATION_ERROR":"" 20 | } 21 | } -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ro_m.ddls.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_RAP_RO_M 7 | E 8 | CDS root view entity 9 | W 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ro_m_as.bdef.asbdef: -------------------------------------------------------------------------------- 1 | managed with additional save with full data 2 | implementation in class zbp_demo_abap_rap_ro_m_as unique; 3 | strict ( 2 ); 4 | 5 | define behavior for ZDEMO_ABAP_RAP_RO_M_AS alias root 6 | persistent table zdemo_abap_tabca 7 | lock master 8 | authorization master ( global ) 9 | 10 | { 11 | create; 12 | update; 13 | delete; 14 | internal action calc; 15 | event created; 16 | event updated parameter zdemo_abap_abstract_ent; 17 | event deleted parameter zdemo_abap_abstract_ent; 18 | field ( numbering : managed, readonly : update ) id; 19 | //determination det_save on save { field calc_result; } 20 | determination det_modify on modify { field num1, num2, arithm_op; } 21 | } -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ro_m_as.bdef.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_RAP_RO_M_AS 7 | BDEF/BDO 8 | BDEF: managed BO, unmanaged save, external numbering 9 | 60 10 | EN 11 | 12 | 13 | ./zdemo_abap_rap_ro_m_as/source/main/versions 14 | http://www.sap.com/adt/relations/versions 15 | Historic versions 16 | 17 | 18 | ./zdemo_abap_rap_ro_m_as/source/main 19 | http://www.sap.com/adt/relations/source 20 | text/plain 21 | Source Content 22 | 23 | 24 | ./zdemo_abap_rap_ro_m_as/source/main 25 | http://www.sap.com/adt/relations/source 26 | text/html 27 | Source Content (HTML) 28 | 29 | 30 | EN 31 | 5 32 | ./zdemo_abap_rap_ro_m_as/source/main 33 | ABAP_SOURCE 34 | true 35 | true 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ro_m_as.ddls.asddls: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #NOT_REQUIRED 2 | define root view entity ZDEMO_ABAP_RAP_RO_M_AS 3 | as select from zdemo_abap_tabca 4 | { 5 | key id, 6 | num1, 7 | arithm_op, 8 | num2, 9 | calc_result, 10 | @Semantics.systemDateTime.createdAt: true 11 | crea_date_time, 12 | @Semantics.systemDateTime.lastChangedAt: true 13 | lchg_date_time 14 | } 15 | -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ro_m_as.ddls.baseinfo: -------------------------------------------------------------------------------- 1 | { 2 | "BASEINFO": 3 | { 4 | "FROM": 5 | [ 6 | "ZDEMO_ABAP_TABCA" 7 | ], 8 | "ASSOCIATED": 9 | [], 10 | "BASE": 11 | [], 12 | "ANNO_REF": 13 | [], 14 | "SCALAR_FUNCTION": 15 | [], 16 | "VERSION":0, 17 | "ANNOREF_EVALUATION_ERROR":"" 18 | } 19 | } -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ro_m_as.ddls.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_RAP_RO_M_AS 7 | E 8 | CDS root view entity 9 | W 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ro_u.bdef.asbdef: -------------------------------------------------------------------------------- 1 | unmanaged implementation in class zbp_demo_abap_rap_ro_u unique; 2 | strict(2); 3 | 4 | define behavior for ZDEMO_ABAP_RAP_RO_U alias root 5 | lock master 6 | authorization master ( global, instance ) 7 | 8 | { 9 | create; 10 | update; 11 | delete; 12 | association _child { create; } 13 | action multiply_by_2; 14 | action ( features : instance ) multiply_by_3; 15 | action ( features : global ) set_z; 16 | field ( readonly:update ) key_field; 17 | } 18 | 19 | define behavior for ZDEMO_ABAP_RAP_CH_U alias child 20 | lock dependent by _parent 21 | authorization dependent by _parent 22 | { 23 | field ( readonly ) key_field; 24 | field ( readonly : update ) key_ch; 25 | association _parent; 26 | } -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ro_u.bdef.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_RAP_RO_U 7 | BDEF/BDO 8 | BDEF, unmanaged, external numbering 9 | 60 10 | EN 11 | 12 | 13 | ./zdemo_abap_rap_ro_u/source/main/versions 14 | http://www.sap.com/adt/relations/versions 15 | Historic versions 16 | 17 | 18 | ./zdemo_abap_rap_ro_u/source/main 19 | http://www.sap.com/adt/relations/source 20 | text/plain 21 | Source Content 22 | 23 | 24 | ./zdemo_abap_rap_ro_u/source/main 25 | http://www.sap.com/adt/relations/source 26 | text/html 27 | Source Content (HTML) 28 | 29 | 30 | EN 31 | 5 32 | ./zdemo_abap_rap_ro_u/source/main 33 | ABAP_SOURCE 34 | true 35 | true 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ro_u.ddls.asddls: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #NOT_REQUIRED 2 | define root view entity ZDEMO_ABAP_RAP_RO_U 3 | as select from zdemo_abap_rapt1 4 | composition [0..*] of ZDEMO_ABAP_RAP_CH_U as _child 5 | { 6 | key key_field, 7 | field1, 8 | field2, 9 | field3, 10 | field4, 11 | _child 12 | } 13 | -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ro_u.ddls.baseinfo: -------------------------------------------------------------------------------- 1 | { 2 | "BASEINFO": 3 | { 4 | "FROM": 5 | [ 6 | "ZDEMO_ABAP_RAPT1" 7 | ], 8 | "ASSOCIATED": 9 | [ 10 | "ZDEMO_ABAP_RAP_CH_U" 11 | ], 12 | "BASE": 13 | [], 14 | "ANNO_REF": 15 | [], 16 | "SCALAR_FUNCTION": 17 | [], 18 | "VERSION":0, 19 | "ANNOREF_EVALUATION_ERROR":"" 20 | } 21 | } -------------------------------------------------------------------------------- /src/zdemo_abap_rap_ro_u.ddls.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_RAP_RO_U 7 | E 8 | CDS root view entity 9 | W 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/zdemo_abap_rapt1.tabl.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_RAPT1 7 | E 8 | TRANSP 9 | X 10 | Demo table for RAP 11 | E 12 | X 13 | A 14 | 1 15 | 16 | 17 | ZDEMO_ABAP_RAPT1 18 | A 19 | 0 20 | APPL0 21 | N 22 | 23 | 24 | 25 | CLIENT 26 | X 27 | 0 28 | C 29 | 000006 30 | X 31 | CLNT 32 | 000003 33 | CLNT 34 | 35 | 36 | KEY_FIELD 37 | X 38 | 0 39 | X 40 | 000004 41 | X 42 | INT4 43 | 000010 44 | INT4 45 | 46 | 47 | FIELD1 48 | 0 49 | C 50 | 000020 51 | CHAR 52 | 000010 53 | CHAR 54 | 55 | 56 | FIELD2 57 | 0 58 | C 59 | 000020 60 | CHAR 61 | 000010 62 | CHAR 63 | 64 | 65 | FIELD3 66 | 0 67 | X 68 | 000004 69 | INT4 70 | 000010 71 | INT4 72 | 73 | 74 | FIELD4 75 | 0 76 | X 77 | 000004 78 | INT4 79 | 000010 80 | INT4 81 | 82 | 83 | 84 | 85 | ZDEMO_ABAP_RAPT1 86 | CUS_DEV_SUP_DA 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /src/zdemo_abap_rapt2.tabl.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_RAPT2 7 | E 8 | TRANSP 9 | X 10 | Demo table for RAP 11 | E 12 | X 13 | A 14 | 1 15 | 16 | 17 | ZDEMO_ABAP_RAPT2 18 | A 19 | 0 20 | APPL0 21 | N 22 | 23 | 24 | 25 | CLIENT 26 | X 27 | 0 28 | C 29 | 000006 30 | X 31 | CLNT 32 | 000003 33 | CLNT 34 | 35 | 36 | KEY_FIELD 37 | X 38 | 0 39 | X 40 | 000004 41 | X 42 | INT4 43 | 000010 44 | INT4 45 | 46 | 47 | KEY_CH 48 | X 49 | 0 50 | X 51 | 000004 52 | X 53 | INT4 54 | 000010 55 | INT4 56 | 57 | 58 | FIELD_CH1 59 | 0 60 | C 61 | 000020 62 | CHAR 63 | 000010 64 | CHAR 65 | 66 | 67 | FIELD_CH2 68 | 0 69 | X 70 | 000004 71 | INT4 72 | 000010 73 | INT4 74 | 75 | 76 | 77 | 78 | ZDEMO_ABAP_RAPT2 79 | CUS_DEV_SUP_DA 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /src/zdemo_abap_st_carrhtml.xslt.source.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

Carrier Information

9 | 10 | 11 | 14 | 17 | 20 | 23 | 24 | 25 | 26 | 29 | 32 | 35 | 41 | 42 | 43 |
12 | ID 13 | 15 | Name 16 | 18 | Currency 19 | 21 | Website 22 |
27 | 28 | 30 | 31 | 33 | 34 | 36 | 37 | 38 | 39 | 40 |
44 | 45 | 46 |
47 | 48 |
49 | -------------------------------------------------------------------------------- /src/zdemo_abap_st_carrhtml.xslt.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_ST_CARRHTML 7 | E 8 | ST Demo 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/zdemo_abap_st_strhtml.xslt.source.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

String Table Content

8 | 9 | 10 | 11 | 14 | 15 | 16 |
12 | 13 |
17 | 18 | 19 |
20 |
21 | -------------------------------------------------------------------------------- /src/zdemo_abap_st_strhtml.xslt.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_ST_STRHTML 7 | E 8 | ST Demo 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/zdemo_abap_tab1.tabl.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_TAB1 7 | E 8 | TRANSP 9 | X 10 | Demo table 11 | E 12 | X 13 | A 14 | 1 15 | 16 | 17 | ZDEMO_ABAP_TAB1 18 | A 19 | 0 20 | APPL0 21 | N 22 | 23 | 24 | 25 | CLIENT 26 | X 27 | 0 28 | C 29 | 000006 30 | X 31 | CLNT 32 | 000003 33 | CLNT 34 | 35 | 36 | KEY_FIELD 37 | X 38 | 0 39 | X 40 | 000004 41 | X 42 | INT4 43 | 000010 44 | INT4 45 | 46 | 47 | CHAR1 48 | 0 49 | C 50 | 000020 51 | CHAR 52 | 000010 53 | CHAR 54 | 55 | 56 | CHAR2 57 | 0 58 | C 59 | 000020 60 | CHAR 61 | 000010 62 | CHAR 63 | 64 | 65 | NUM1 66 | 0 67 | X 68 | 000004 69 | INT4 70 | 000010 71 | INT4 72 | 73 | 74 | NUM2 75 | 0 76 | X 77 | 000004 78 | INT4 79 | 000010 80 | INT4 81 | 82 | 83 | 84 | 85 | ZDEMO_ABAP_TAB1 86 | CUS_DEV_SUP_DA 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /src/zdemo_abap_tab2.tabl.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_TAB2 7 | E 8 | TRANSP 9 | X 10 | Demo table 11 | E 12 | X 13 | A 14 | 1 15 | 16 | 17 | ZDEMO_ABAP_TAB2 18 | A 19 | 0 20 | APPL0 21 | N 22 | 23 | 24 | 25 | CLIENT 26 | X 27 | 0 28 | C 29 | 000006 30 | X 31 | CLNT 32 | 000003 33 | CLNT 34 | 35 | 36 | KEY_FIELD 37 | X 38 | 0 39 | X 40 | 000004 41 | X 42 | INT4 43 | 000010 44 | INT4 45 | 46 | 47 | CHAR1 48 | 0 49 | C 50 | 000020 51 | CHAR 52 | 000010 53 | CHAR 54 | 55 | 56 | NUM1 57 | 0 58 | X 59 | 000004 60 | INT4 61 | 000010 62 | INT4 63 | 64 | 65 | NUMLONG 66 | 0 67 | 8 68 | 000008 69 | INT8 70 | 000019 71 | INT8 72 | 73 | 74 | 75 | 76 | ZDEMO_ABAP_TAB2 77 | CUS_DEV_SUP_DA 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /src/zdemo_abap_tabca.tabl.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_TABCA 7 | E 8 | TRANSP 9 | X 10 | Demo table for RAP calculator 11 | E 12 | X 13 | A 14 | 1 15 | 16 | 17 | ZDEMO_ABAP_TABCA 18 | A 19 | 0 20 | APPL0 21 | N 22 | 23 | 24 | 25 | CLIENT 26 | X 27 | 0 28 | C 29 | 000006 30 | X 31 | CLNT 32 | 000003 33 | CLNT 34 | 35 | 36 | ID 37 | X 38 | SYSUUID_X16 39 | 0 40 | X 41 | E 42 | 43 | 44 | NUM1 45 | 0 46 | X 47 | 000004 48 | INT4 49 | 000010 50 | INT4 51 | 52 | 53 | ARITHM_OP 54 | 0 55 | C 56 | 000002 57 | CHAR 58 | 000001 59 | CHAR 60 | 61 | 62 | NUM2 63 | 0 64 | X 65 | 000004 66 | INT4 67 | 000010 68 | INT4 69 | 70 | 71 | CALC_RESULT 72 | 0 73 | g 74 | 000008 75 | STRG 76 | STRG 77 | 78 | 79 | CREA_DATE_TIME 80 | TIMESTAMPL 81 | 0 82 | E 83 | 84 | 85 | LCHG_DATE_TIME 86 | TIMESTAMPL 87 | 0 88 | E 89 | 90 | 91 | 92 | 93 | ZDEMO_ABAP_TABCA 94 | CUS_DEV_SUP_DA 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /src/zdemo_abap_table_function.ddls.asddls: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #NOT_REQUIRED 2 | @ClientHandling.type: #CLIENT_DEPENDENT 3 | @ClientHandling.algorithm: #SESSION_VARIABLE 4 | define table function ZDEMO_ABAP_TABLE_FUNCTION 5 | returns 6 | { 7 | client : abap.clnt; 8 | carrier_id : abap.char(3); 9 | carrier_name : abap.char(20); 10 | connections : abap.string; 11 | avg_flight_time : abap.decfloat34; 12 | avg_distance : abap.decfloat34; 13 | } 14 | implemented by method 15 | zcl_demo_abap_amdp=>flight_analysis; 16 | -------------------------------------------------------------------------------- /src/zdemo_abap_table_function.ddls.baseinfo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-samples/abap-cheat-sheets/dadf4de59c64848cb40fa34f415103999ced7ad2/src/zdemo_abap_table_function.ddls.baseinfo -------------------------------------------------------------------------------- /src/zdemo_abap_table_function.ddls.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_TABLE_FUNCTION 7 | E 8 | ABAP Demo: Table function 9 | F 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/zdemo_abap_xslt_fl.xslt.source.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/zdemo_abap_xslt_fl.xslt.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZDEMO_ABAP_XSLT_FL 7 | E 8 | XSLT Demo 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/ztcl_demo_abap_unit_tdf_testcl.clas.abap: -------------------------------------------------------------------------------- 1 | "!

Test Class Supporting an ABAP Unit Test Example
ABAP cheat sheet example class

2 | "! 3 | "!

The example class {@link zcl_demo_abap_unit_tdf} demonstrates managing dependencies (dependent-on-components, DOC) 4 | "! with ABAP Unit and explores the creation of test doubles using ABAP frameworks.
5 | "! This global class is empty, but the the Test Classes tab includes a test class. Using the syntax 6 | "! "! @testing ..., a test relation between this test class and another global class 7 | "! ({@link zcl_demo_abap_unit_tdf}) is defined. Therefore, when you run unit tests of class {@link zcl_demo_abap_unit_tdf}, 8 | "! the tests contained in the class {@link ztcl_demo_abap_unit_tdf_testcl} are executed.

9 | "! 10 | "!

Information

11 | "!

Find information on getting started with the example class and the disclaimer in 12 | "! the ABAP Doc comment of class {@link zcl_demo_abap_aux}.

13 | CLASS ztcl_demo_abap_unit_tdf_testcl DEFINITION 14 | PUBLIC 15 | FINAL 16 | CREATE PUBLIC . 17 | 18 | PUBLIC SECTION. 19 | PROTECTED SECTION. 20 | PRIVATE SECTION. 21 | ENDCLASS. 22 | 23 | CLASS ztcl_demo_abap_unit_tdf_testcl IMPLEMENTATION. 24 | 25 | ENDCLASS. 26 | -------------------------------------------------------------------------------- /src/ztcl_demo_abap_unit_tdf_testcl.clas.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | ZTCL_DEMO_ABAP_UNIT_TDF_TESTCL 7 | E 8 | ABAP cheat sheet: Creating Test Doubles Using ABAP Framework 9 | 1 10 | X 11 | X 12 | X 13 | X 14 | 15 | 16 | 17 | 18 | --------------------------------------------------------------------------------