├── .github └── CODEOWNERS ├── src ├── .vscode │ └── settings.json ├── package.devc.xml ├── zabap_oo_patterns │ ├── zcl_5_composite_other.clas.abap │ ├── package.devc.xml │ ├── zif_5_composite.intf.abap │ ├── zif_5_composite.intf.xml │ ├── zcl_3_factory.clas.xml │ ├── zcl_4_singleton.clas.xml │ ├── zcl_3_factory_tester.clas.xml │ ├── zcl_4_singleton_tester_1.clas.xml │ ├── zcl_5_composite_tester.clas.xml │ ├── zcl_1_basic_class_tester.clas.xml │ ├── zcl_5_composite_a340.clas.xml │ ├── zcl_5_composite_other.clas.xml │ ├── zcl_2_static_and_inst_tester.clas.xml │ ├── zcl_3_factory_tester.clas.abap │ ├── zcl_5_composite_a340.clas.abap │ ├── zcl_4_singleton_tester_1.clas.abap │ ├── zoo_patterns.msag.xml │ ├── zcl_1_basic_class.clas.xml │ ├── zcx_5_composite.clas.xml │ ├── zcl_3_factory.clas.abap │ ├── zcl_4_singleton.clas.abap │ ├── zcl_2_static.clas.xml │ ├── zcl_1_basic_class.clas.abap │ ├── zcl_5_composite_747.clas.xml │ ├── zcl_5_composite_tester.clas.abap │ ├── zcl_2_instance.clas.xml │ ├── zcl_1_basic_class_tester.clas.abap │ ├── zcl_2_instance.clas.abap │ ├── zcx_5_composite.clas.abap │ ├── zcl_5_composite_base.clas.xml │ ├── zcl_5_composite_747.clas.abap │ ├── zcl_2_static.clas.abap │ ├── zcl_2_static_and_inst_tester.clas.abap │ └── zcl_5_composite_base.clas.abap ├── zcl_oo_tutorial_6_other.clas.abap ├── zif_oo_tutorial.intf.abap ├── zif_oo_tutorial.intf.xml ├── zcl_workflow_test.clas.xml ├── zcl_abap_to_json.clas.xml ├── zcl_json_to_xml.clas.xml ├── zcl_obj_xml_test.clas.xml ├── zcl_xml_to_json.clas.xml ├── zcl_json_to_abap.clas.xml ├── zcl_simple_example.clas.xml ├── zcl_inline_declare.clas.xml ├── zcl_oo_tutorial_3_tester.clas.xml ├── zcl_oo_tutorial_4_tester.clas.xml ├── zcl_oo_tutorial_5_tester.clas.xml ├── zcl_oo_tutorial_6_a340.clas.xml ├── zcl_oo_tutorial_6_tester.clas.xml ├── zcl_table_expressions.clas.xml ├── zcl_oo_tutorial_6_other.clas.xml ├── zcl_xml_to_json_call.clas.xml ├── zcl_abap_to_json_id.clas.xml ├── zcl_abap_to_json_restore.clas.xml ├── zcl_constructor_expression.clas.xml ├── zcl_json_to_xml_call.clas.xml ├── zcl_fs_ref_perf_testing.clas.xml ├── zcl_oo_tutorial_5a_tester.clas.xml ├── zcl_abap_to_json_restore.clas.abap ├── zcl_oo_tutorial_6_a340.clas.abap ├── zcl_oo_tutorial_1.clas.xml ├── zoo_messages.msag.xml ├── zcx_oo_tutorial.clas.xml ├── zcl_oo_tutorial_1.clas.abap ├── zcl_oo_tutorial_2.clas.xml ├── zcl_hungarian_notation.clas.xml ├── zcl_json_to_abap.clas.abap ├── zcl_oo_tutorial_6_747.clas.xml ├── zcl_workflow_test.clas.abap ├── zcl_json_to_xml_call.clas.abap ├── zcl_oo_tutorial_6_tester.clas.abap ├── zcl_oo_tutorial_3.clas.xml ├── zcl_oo_tutorial_5.clas.xml ├── zcl_oo_tutorial_4.clas.xml ├── zcl_xml_to_json_call.clas.abap ├── zcl_oo_tutorial_4_tester.clas.abap ├── zcl_fs_ref_perf_testing.clas.abap ├── zcl_xml_to_json.clas.abap ├── zcl_abap_to_json.clas.abap ├── zcl_json_to_xml.clas.abap ├── zcl_inline_declare.clas.abap ├── zcl_oo_tutorial_3_tester.clas.abap ├── zcl_oo_tutorial_5_tester.clas.abap ├── zcx_oo_tutorial.clas.abap ├── zcl_oo_tutorial_6_base.clas.xml ├── zcl_oo_tutorial_3.clas.abap ├── zcl_hungarian_notation.clas.abap ├── zobject_xml.tabl.xml ├── zcl_oo_tutorial_4.clas.abap ├── zcl_abap_to_json_id.clas.abap ├── zcl_oo_tutorial_5a_tester.clas.abap ├── zcl_oo_tutorial_6_747.clas.abap ├── zcl_simple_example.clas.abap ├── zcl_obj_xml_test.clas.abap ├── zcl_oo_tutorial_5.clas.abap ├── zcl_oo_tutorial_2.clas.abap ├── zcl_oo_tutorial_6_base.clas.abap ├── zcl_table_expressions.clas.abap └── zcl_constructor_expression.clas.abap ├── .vscode └── settings.json ├── .abapgit.xml ├── REUSE.toml ├── README.md ├── LICENSES └── Apache-2.0.txt └── LICENSE /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @jung-thomas 2 | -------------------------------------------------------------------------------- /src/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "actions": [] 3 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "SAP HANA Database Artifacts.displaySapWebAnalyticsStartupNotification": false 3 | } -------------------------------------------------------------------------------- /src/package.devc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ABAP Basics and Refresher 7 | X 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_5_composite_other.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_5_composite_other DEFINITION 2 | PUBLIC 3 | INHERITING FROM zcl_5_composite_base 4 | FINAL 5 | CREATE PROTECTED 6 | GLOBAL FRIENDS zcl_5_composite_base. 7 | 8 | PUBLIC SECTION. 9 | PROTECTED SECTION. 10 | PRIVATE SECTION. 11 | ENDCLASS. 12 | 13 | 14 | 15 | CLASS zcl_5_composite_other IMPLEMENTATION. 16 | ENDCLASS. 17 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/package.devc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ABAP OO Patterns 7 | X 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zif_5_composite.intf.abap: -------------------------------------------------------------------------------- 1 | INTERFACE zif_5_composite 2 | PUBLIC . 3 | 4 | TYPES: 5 | BEGIN OF COST, 6 | PRICE TYPE /DMO/FLIGHT_PRICE, 7 | CURRENCY TYPE /DMO/CURRENCY_CODE, 8 | END OF COST . 9 | 10 | METHODS GET_FLIGHT_DETAILS 11 | RETURNING 12 | VALUE(FLIGHT) TYPE /DMO/FLIGHT . 13 | METHODS CALCULATE_FLIGHT_PRICE 14 | RETURNING 15 | VALUE(PRICE) TYPE COST . 16 | ENDINTERFACE. 17 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_6_other.clas.abap: -------------------------------------------------------------------------------- 1 | "!

Tutorial #6 - Planetype Other

2 | CLASS ZCL_OO_TUTORIAL_6_OTHER DEFINITION 3 | public 4 | inheriting from ZCL_OO_TUTORIAL_6_BASE 5 | final 6 | create protected 7 | 8 | global friends ZCL_OO_TUTORIAL_6_BASE . 9 | 10 | PUBLIC SECTION. 11 | PROTECTED SECTION. 12 | PRIVATE SECTION. 13 | ENDCLASS. 14 | 15 | 16 | 17 | CLASS ZCL_OO_TUTORIAL_6_OTHER IMPLEMENTATION. 18 | ENDCLASS. 19 | -------------------------------------------------------------------------------- /src/zif_oo_tutorial.intf.abap: -------------------------------------------------------------------------------- 1 | "!

OO Tutorial Base Interface

2 | INTERFACE ZIF_OO_TUTORIAL 3 | PUBLIC . 4 | 5 | 6 | TYPES: 7 | BEGIN OF COST, 8 | PRICE TYPE /DMO/FLIGHT_PRICE, 9 | CURRENCY TYPE /DMO/CURRENCY_CODE, 10 | END OF COST . 11 | 12 | METHODS GET_FLIGHT_DETAILS 13 | RETURNING 14 | VALUE(FLIGHT) TYPE /DMO/FLIGHT . 15 | METHODS CALCULATE_FLIGHT_PRICE 16 | RETURNING 17 | VALUE(PRICE) TYPE COST . 18 | ENDINTERFACE. 19 | -------------------------------------------------------------------------------- /src/zif_oo_tutorial.intf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZIF_OO_TUTORIAL 7 | E 8 | OO Tutorial Base Interface 9 | 2 10 | 1 11 | X 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/zcl_workflow_test.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_WORKFLOW_TEST 7 | E 8 | Workflow Test 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zif_5_composite.intf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZIF_5_COMPOSITE 7 | E 8 | Composite Pattern Interface 9 | 2 10 | 1 11 | X 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/zcl_abap_to_json.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_ABAP_TO_JSON 7 | E 8 | ABAP To JSON Example 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_json_to_xml.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_JSON_TO_XML 7 | E 8 | Convert JSON to XML 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_obj_xml_test.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_OBJ_XML_TEST 7 | E 8 | Handlerclass for HTTP Service ZOBJ_XML_TEST 9 | 1 10 | X 11 | X 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/zcl_xml_to_json.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_XML_TO_JSON 7 | E 8 | XML to JSON Conversion 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_json_to_abap.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_JSON_TO_ABAP 7 | E 8 | JSON to ABAP Conversion 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_simple_example.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_SIMPLE_EXAMPLE 7 | E 8 | Simple Example Class 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_3_factory.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_3_FACTORY 7 | E 8 | Factory Pattern 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_inline_declare.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_INLINE_DECLARE 7 | E 8 | ABAP Inline Declaration 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_4_singleton.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_4_SINGLETON 7 | E 8 | Singleton Pattern 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_3_tester.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_OO_TUTORIAL_3_TESTER 7 | E 8 | OO Tutorial #3 Tester 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_4_tester.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_OO_TUTORIAL_4_TESTER 7 | E 8 | OO Tutorial #4 Tester 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_5_tester.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_OO_TUTORIAL_5_TESTER 7 | E 8 | OO Tutorial #5 Tester 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_6_a340.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_OO_TUTORIAL_6_A340 7 | E 8 | Tutorial #6 - Planetype A340 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_6_tester.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_OO_TUTORIAL_6_TESTER 7 | E 8 | OO Tutorial #6 Tester 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_table_expressions.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_TABLE_EXPRESSIONS 7 | E 8 | ABAP Table Expressions Examples 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_6_other.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_OO_TUTORIAL_6_OTHER 7 | E 8 | Tutorial #6 - Planetype Other 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_xml_to_json_call.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_XML_TO_JSON_CALL 7 | E 8 | XML To JSON via CALL Transformation 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_3_factory_tester.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_3_FACTORY_TESTER 7 | E 8 | Factory Pattern Tester 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_4_singleton_tester_1.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_4_SINGLETON_TESTER_1 7 | E 8 | Singleton Tester #1 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_5_composite_tester.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_5_COMPOSITE_TESTER 7 | E 8 | Composite Pattern - Tester 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_abap_to_json_id.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_ABAP_TO_JSON_ID 7 | E 8 | ABAP to JSON Example using Call Transformation ID 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_abap_to_json_restore.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_ABAP_TO_JSON_RESTORE 7 | E 8 | ABAP to JSON Example restore from table 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_constructor_expression.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_CONSTRUCTOR_EXPRESSION 7 | E 8 | ABAP Constructor Expression Examples 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_json_to_xml_call.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_JSON_TO_XML_CALL 7 | E 8 | JSON To XML Conversion via Call Transformation 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_1_basic_class_tester.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_1_BASIC_CLASS_TESTER 7 | E 8 | ABAP Basic Class Tester 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_5_composite_a340.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_5_COMPOSITE_A340 7 | E 8 | Composite Pattern - A340 Plane Type 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_fs_ref_perf_testing.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_FS_REF_PERF_TESTING 7 | E 8 | Field-Symbol vs. Reference Performance Testing 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_5a_tester.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_OO_TUTORIAL_5A_TESTER 7 | E 8 | OO Tutorial #5A - Tester with iTab of references 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_5_composite_other.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_5_COMPOSITE_OTHER 7 | E 8 | Composite Pattern - All Other Plane Types 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_2_static_and_inst_tester.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_2_STATIC_AND_INST_TESTER 7 | E 8 | Static and Instance Methods Tester 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_3_factory_tester.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_3_factory_tester DEFINITION 2 | PUBLIC 3 | FINAL 4 | CREATE PUBLIC . 5 | 6 | PUBLIC SECTION. 7 | INTERFACES IF_OO_ADT_CLASSRUN. 8 | PROTECTED SECTION. 9 | PRIVATE SECTION. 10 | ENDCLASS. 11 | 12 | 13 | 14 | CLASS zcl_3_factory_tester IMPLEMENTATION. 15 | METHOD if_oo_adt_classrun~main. 16 | * data(direct_instance) = new zcl_3_factory( 'Try without Factory' ). 17 | data(factory_instance) = zcl_3_factory=>factory( 'Try with Factory' ). 18 | out->write( factory_instance->get_stored_stuff( ) ). 19 | ENDMETHOD. 20 | 21 | ENDCLASS. 22 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_5_composite_a340.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_5_composite_a340 DEFINITION 2 | PUBLIC 3 | INHERITING FROM zcl_5_composite_base 4 | FINAL 5 | CREATE PROTECTED 6 | GLOBAL FRIENDS zcl_5_composite_base. 7 | 8 | PUBLIC SECTION. 9 | METHODS zif_5_composite~calculate_flight_price 10 | REDEFINITION. 11 | PROTECTED SECTION. 12 | PRIVATE SECTION. 13 | ENDCLASS. 14 | 15 | 16 | 17 | CLASS zcl_5_composite_a340 IMPLEMENTATION. 18 | METHOD zif_5_composite~calculate_flight_price. 19 | price = super->calculate_flight_price( ). 20 | price-price = price-price + 15. 21 | ENDMETHOD. 22 | ENDCLASS. 23 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /src/zcl_abap_to_json_restore.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_abap_to_json_restore DEFINITION 2 | PUBLIC 3 | FINAL 4 | CREATE PUBLIC . 5 | 6 | PUBLIC SECTION. 7 | INTERFACES if_oo_adt_classrun. 8 | PROTECTED SECTION. 9 | PRIVATE SECTION. 10 | ENDCLASS. 11 | 12 | 13 | 14 | CLASS ZCL_ABAP_TO_JSON_RESTORE IMPLEMENTATION. 15 | 16 | 17 | METHOD if_oo_adt_classrun~main. 18 | 19 | SELECT SINGLE * FROM zobject_xml 20 | WHERE id = 1 INTO @DATA(object_xml). 21 | DATA context2 TYPE REF TO zcl_oo_tutorial_5. 22 | CALL TRANSFORMATION id SOURCE XML object_xml-content 23 | RESULT flight = context2. 24 | out->write( context2->get_flight_details( ) ). 25 | ENDMETHOD. 26 | ENDCLASS. 27 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_6_a340.clas.abap: -------------------------------------------------------------------------------- 1 | "!

Tutorial #6 - Planetype A340

2 | CLASS ZCL_OO_TUTORIAL_6_A340 DEFINITION 3 | PUBLIC 4 | INHERITING FROM ZCL_OO_TUTORIAL_6_BASE 5 | FINAL 6 | CREATE PROTECTED 7 | 8 | GLOBAL FRIENDS ZCL_OO_TUTORIAL_6_BASE. 9 | 10 | PUBLIC SECTION. 11 | 12 | METHODS ZIF_OO_TUTORIAL~CALCULATE_FLIGHT_PRICE 13 | REDEFINITION . 14 | PROTECTED SECTION. 15 | PRIVATE SECTION. 16 | ENDCLASS. 17 | 18 | 19 | 20 | CLASS ZCL_OO_TUTORIAL_6_A340 IMPLEMENTATION. 21 | 22 | 23 | METHOD ZIF_OO_TUTORIAL~CALCULATE_FLIGHT_PRICE. 24 | price = SUPER->CALCULATE_FLIGHT_PRICE( ). 25 | PRICE-PRICE = PRICE-PRICE + 15. 26 | ENDMETHOD. 27 | ENDCLASS. 28 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_4_singleton_tester_1.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_4_singleton_tester_1 DEFINITION 2 | PUBLIC 3 | FINAL 4 | CREATE PUBLIC . 5 | 6 | PUBLIC SECTION. 7 | INTERFACES if_oo_adt_classrun. 8 | PROTECTED SECTION. 9 | PRIVATE SECTION. 10 | ENDCLASS. 11 | 12 | 13 | 14 | CLASS zcl_4_singleton_tester_1 IMPLEMENTATION. 15 | METHOD if_oo_adt_classrun~main. 16 | DATA(logger) = zcl_4_singleton=>factory( ). 17 | logger->write_to_log( |First Test| ). 18 | out->write( logger->read_log( ) ). 19 | clear logger. 20 | DATA(second_logger) = zcl_4_singleton=>factory( ). 21 | second_logger->write_to_log( |Second Test| ). 22 | out->write( second_logger->read_log( ) ). 23 | ENDMETHOD. 24 | ENDCLASS. 25 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_1.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_OO_TUTORIAL_1 7 | E 8 | OO Tutorial #1 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | ZCL_OO_TUTORIAL_1 17 | MY_FIRST_METHOD 18 | E 19 | My First Method 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zoo_patterns.msag.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZOO_PATTERNS 7 | E 8 | ZOO_PATTERNS 9 | 10 | 11 | 12 | E 13 | ZOO_PATTERNS 14 | 001 15 | General Exception 16 | 17 | 18 | E 19 | ZOO_PATTERNS 20 | 002 21 | No Flight Found for Airline &1 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/zoo_messages.msag.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZOO_MESSAGES 7 | E 8 | Object Oriented Example Messages 9 | 10 | 11 | 12 | E 13 | ZOO_MESSAGES 14 | 001 15 | General Exception 16 | 17 | 18 | E 19 | ZOO_MESSAGES 20 | 002 21 | No Flight Found for Airline &1 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_1_basic_class.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_1_BASIC_CLASS 7 | E 8 | ABAP Basic Class 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | ZCL_1_BASIC_CLASS 17 | MY_FIRST_METHOD 18 | E 19 | My First Method 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/zcx_oo_tutorial.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCX_OO_TUTORIAL 7 | E 8 | Exception Class For OO Tutorial 9 | 40 10 | 1 11 | X 12 | X 13 | X 14 | 15 | 16 | 17 | ZCX_OO_TUTORIAL 18 | CONSTRUCTOR 19 | E 20 | CONSTRUCTOR 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcx_5_composite.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCX_5_COMPOSITE 7 | E 8 | Exception Class For OO Tutorial 9 | 40 10 | 1 11 | X 12 | X 13 | X 14 | 15 | 16 | 17 | ZCX_5_COMPOSITE 18 | CONSTRUCTOR 19 | E 20 | CONSTRUCTOR 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_3_factory.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_3_factory DEFINITION PUBLIC 2 | CREATE private . 3 | 4 | PUBLIC SECTION. 5 | 6 | class-methods factory importing my_stuff type string 7 | RETURNING VALUE(my_instance) type ref to zcl_3_factory. 8 | methods get_stored_stuff 9 | returning value(results) type string. 10 | PROTECTED SECTION. 11 | PRIVATE SECTION. 12 | methods constructor importing my_stuff type string. 13 | data stored_my_stuff type string. 14 | ENDCLASS. 15 | 16 | 17 | 18 | CLASS zcl_3_factory IMPLEMENTATION. 19 | method constructor. 20 | stored_my_stuff = my_stuff. 21 | endmethod. 22 | 23 | method factory. 24 | my_instance = new zcl_3_factory( my_stuff ). 25 | endmethod. 26 | 27 | method get_stored_stuff. 28 | results = me->stored_my_stuff. 29 | ENDMETHOD. 30 | ENDCLASS. 31 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_4_singleton.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_4_singleton DEFINITION 2 | PUBLIC 3 | FINAL 4 | CREATE PRIVATE . 5 | 6 | PUBLIC SECTION. 7 | CLASS-METHODS factory RETURNING VALUE(results) TYPE REF TO zcl_4_singleton. 8 | METHODS write_to_log IMPORTING log_entry TYPE string. 9 | methods read_log returning value(results) type string_table. 10 | PROTECTED SECTION. 11 | PRIVATE SECTION. 12 | CLASS-DATA: self TYPE REF TO zcl_4_singleton. 13 | DATA: log TYPE STANDARD TABLE OF string. 14 | ENDCLASS. 15 | 16 | 17 | 18 | CLASS zcl_4_singleton IMPLEMENTATION. 19 | METHOD factory. 20 | IF self IS NOT BOUND. 21 | self = NEW zcl_4_singleton( ). 22 | ENDIF. 23 | results = self. 24 | ENDMETHOD. 25 | 26 | METHOD write_to_log. 27 | IF log_entry IS NOT INITIAL. 28 | APPEND INITIAL LINE TO log REFERENCE INTO DATA(log_line). 29 | log_line->* = log_entry. 30 | ENDIF. 31 | ENDMETHOD. 32 | 33 | method read_log. 34 | results = log. 35 | endmethod. 36 | ENDCLASS. 37 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_2_static.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_2_STATIC 7 | E 8 | Static Methods 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | ZCL_2_STATIC 17 | CALCULATE_FLIGHT_PRICE 18 | E 19 | Calculate Flight Price 20 | 21 | 22 | ZCL_2_STATIC 23 | GET_FLIGHT_DETAILS 24 | E 25 | Get Booking Details 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_1.clas.abap: -------------------------------------------------------------------------------- 1 | "!

OO Tutorial #1

2 | CLASS zcl_oo_tutorial_1 DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | 9 | INTERFACES if_oo_adt_classrun. 10 | TYPES: 11 | sample_table_type TYPE STANDARD TABLE OF string . 12 | 13 | DATA sample_internal_table TYPE sample_table_type . 14 | 15 | "!

My First Method

16 | METHODS my_first_method 17 | IMPORTING 18 | !import TYPE string "Import parameter 19 | RETURNING VALUE(export) TYPE string. 20 | 21 | PROTECTED SECTION. 22 | 23 | PRIVATE SECTION. 24 | 25 | ENDCLASS. 26 | 27 | 28 | 29 | CLASS ZCL_OO_TUTORIAL_1 IMPLEMENTATION. 30 | 31 | 32 | METHOD if_oo_adt_classrun~main. 33 | out->write( `Starting OO #1 Test` ). 34 | out->write( me->my_first_method( `Input Value` ) ). 35 | ENDMETHOD. 36 | 37 | 38 | METHOD my_first_method. 39 | export = import. 40 | ENDMETHOD. 41 | ENDCLASS. 42 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_2.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_OO_TUTORIAL_2 7 | E 8 | Flight Data as Static Methods 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | ZCL_OO_TUTORIAL_2 17 | CALCULATE_FLIGHT_PRICE 18 | E 19 | Calculate Flight Price 20 | 21 | 22 | ZCL_OO_TUTORIAL_2 23 | GET_FLIGHT_DETAILS 24 | E 25 | Get Booking Details 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/zcl_hungarian_notation.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_HUNGARIAN_NOTATION 7 | E 8 | ABAP Class examples with and without Hungarian Notation 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | ZCL_HUNGARIAN_NOTATION 17 | FLIGHTS 18 | E 19 | All Flights 20 | 21 | 22 | ZCL_HUNGARIAN_NOTATION 23 | GIT_FLIGHTS 24 | E 25 | All Flights 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_1_basic_class.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_1_basic_class DEFINITION 2 | PUBLIC 3 | FINAL 4 | CREATE PUBLIC . 5 | 6 | PUBLIC SECTION. 7 | TYPES: 8 | sample_Table_Type TYPE STANDARD TABLE OF string . 9 | 10 | DATA sample_Internal_Table TYPE sample_Table_Type . 11 | 12 | "!

My First Method

13 | METHODS my_First_Method 14 | IMPORTING 15 | !import TYPE string "Import parameter 16 | RETURNING VALUE(export) TYPE string. 17 | 18 | 19 | methods my_Second_Method 20 | returning VALUE(sample_Internal_Table) like sample_Internal_Table. 21 | PROTECTED SECTION. 22 | PRIVATE SECTION. 23 | ENDCLASS. 24 | 25 | 26 | 27 | CLASS zcl_1_basic_class IMPLEMENTATION. 28 | 29 | METHOD my_First_Method. 30 | export = |${ import } - Plus New Stuff|. 31 | APPEND INITIAL LINE TO sample_Internal_Table REFERENCE INTO DATA(itab_Line). 32 | itab_Line->* = export. 33 | ENDMETHOD. 34 | 35 | method my_Second_Method. 36 | sample_Internal_Table = me->sample_Internal_Table. 37 | ENDMETHOD. 38 | ENDCLASS. 39 | -------------------------------------------------------------------------------- /src/zcl_json_to_abap.clas.abap: -------------------------------------------------------------------------------- 1 | "!

JSON to ABAP Conversion

2 | CLASS ZCL_JSON_TO_ABAP DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | INTERFACES IF_OO_ADT_CLASSRUN. 9 | PROTECTED SECTION. 10 | PRIVATE SECTION. 11 | ENDCLASS. 12 | 13 | 14 | 15 | CLASS ZCL_JSON_TO_ABAP IMPLEMENTATION. 16 | 17 | 18 | METHOD IF_OO_ADT_CLASSRUN~MAIN. 19 | 20 | TYPES: BEGIN OF T_STRUCT, 21 | C1 TYPE STRING, 22 | C2 TYPE STRING, 23 | END OF T_STRUCT. 24 | TYPES T_TAB TYPE STANDARD TABLE OF T_STRUCT. 25 | DATA ITAB TYPE T_TAB. 26 | 27 | DATA(JSON) = `{"TEXT":"JSON", "SECOND": "Second Variable", "TAB": [{"C1": "HI", "C2":"Hey"},{"C1": "HI2", "C2":"Hey2"}]}`. 28 | DATA TEXT TYPE STRING. 29 | DATA SECOND TYPE STRING. 30 | CALL TRANSFORMATION ID SOURCE XML JSON 31 | RESULT TEXT = TEXT 32 | SECOND = SECOND 33 | TAB = ITAB. 34 | OUT->WRITE( TEXT ). 35 | OUT->WRITE( SECOND ). 36 | OUT->WRITE( ITAB ). 37 | ENDMETHOD. 38 | ENDCLASS. 39 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_6_747.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_OO_TUTORIAL_6_747 7 | E 8 | OO Tutorial #6 - Planetype 747 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | ZCL_OO_TUTORIAL_6_747 17 | CONSTRUCTOR 18 | E 19 | CONSTRUCTOR 20 | 21 | 22 | ZCL_OO_TUTORIAL_6_747 23 | GET_INFLIGHT_MOVIES 24 | E 25 | Get a listing of in flight movies 26 | 27 | 28 | ZCL_OO_TUTORIAL_6_747 29 | MOVIES 30 | E 31 | List of Movies on the Flight 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_5_composite_747.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_5_COMPOSITE_747 7 | E 8 | Composite Pattern - 747 Plane Type 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | ZCL_5_COMPOSITE_747 17 | CONSTRUCTOR 18 | E 19 | CONSTRUCTOR 20 | 21 | 22 | ZCL_5_COMPOSITE_747 23 | GET_INFLIGHT_MOVIES 24 | E 25 | Get a listing of in flight movies 26 | 27 | 28 | ZCL_5_COMPOSITE_747 29 | MOVIES 30 | E 31 | List of Movies on the Flight 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/zcl_workflow_test.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_workflow_test DEFINITION 2 | PUBLIC 3 | FINAL 4 | CREATE PUBLIC . 5 | 6 | PUBLIC SECTION. 7 | INTERFACES if_oo_adt_classrun. 8 | PROTECTED SECTION. 9 | PRIVATE SECTION. 10 | ENDCLASS. 11 | 12 | 13 | 14 | CLASS ZCL_WORKFLOW_TEST IMPLEMENTATION. 15 | 16 | 17 | METHOD if_oo_adt_classrun~main. 18 | TYPES: BEGIN OF ty_context, 19 | some_property TYPE string, 20 | END OF ty_context. 21 | 22 | TRY. 23 | DATA(cpwf_api) = cl_swf_cpwf_api_factory_a4c=>get_api_instance( ). 24 | 25 | DATA(wf_def) = cpwf_api->get_workflow_definitions( ). 26 | out->write( `Definitions:` ). 27 | out->write( wf_def ). 28 | CATCH cx_swf_cpwf_api INTO DATA(cx_wf_api). 29 | out->write( cx_wf_api->get_text( ) ). 30 | ENDTRY. 31 | 32 | * 33 | * DATA(ls_context) = VALUE ty_context( 34 | * some_property = 'someValue' 35 | * ). 36 | * DATA(lv_context_json) = lo_cpwf_api->get_start_context_from_data( 37 | * iv_data = ls_context 38 | * ). 39 | * 40 | * DATA(lv_cpwf_handle) = lo_cpwf_api->start_workflow( 41 | * iv_cp_workflow_def_id = 'myprocess' 42 | * iv_context = lv_context_json 43 | * iv_retention_time = 30 44 | * iv_callback_class = 'ZCL_SWF_CPWF_CALLBACK' 45 | * ). 46 | ENDMETHOD. 47 | ENDCLASS. 48 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_5_composite_tester.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_5_composite_tester DEFINITION 2 | PUBLIC 3 | FINAL 4 | CREATE PUBLIC . 5 | 6 | PUBLIC SECTION. 7 | INTERFACES if_oo_adt_classrun. 8 | PROTECTED SECTION. 9 | PRIVATE SECTION. 10 | ENDCLASS. 11 | 12 | 13 | 14 | CLASS zcl_5_composite_tester IMPLEMENTATION. 15 | 16 | METHOD if_oo_adt_classrun~main. 17 | SELECT * FROM /dmo/flight 18 | WHERE carrier_id = `LH` 19 | INTO TABLE @DATA(flights). 20 | 21 | LOOP AT flights REFERENCE INTO DATA(flight). 22 | TRY. 23 | DATA(flight_obj) = zcl_5_composite_base=>factory( 24 | carrier_id = flight->carrier_id 25 | connection_id = flight->connection_id 26 | flight_date = flight->flight_date ). 27 | out->write( flight_obj->get_flight_details( ) ). 28 | out->write( flight_obj->calculate_flight_price( ) ). 29 | IF flight->plane_type_id CS zcl_5_composite_base=>plane_type-b747. 30 | DATA(flight_747) = CAST zcl_5_composite_747( flight_obj ). 31 | out->write( flight_747->get_inflight_movies( ) ). 32 | ENDIF. 33 | out->write( ` ` ). 34 | CATCH zcx_5_composite INTO DATA(cx_flight). 35 | out->write( cx_flight->get_text( ) ). 36 | ENDTRY. 37 | ENDLOOP. 38 | 39 | IF sy-subrc = 0. 40 | ENDIF. 41 | 42 | ENDMETHOD. 43 | ENDCLASS. 44 | -------------------------------------------------------------------------------- /src/zcl_json_to_xml_call.clas.abap: -------------------------------------------------------------------------------- 1 | "!

JSON To XML Conversion via Call Transformation

2 | CLASS ZCL_JSON_TO_XML_CALL DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | INTERFACES IF_OO_ADT_CLASSRUN. 9 | PROTECTED SECTION. 10 | PRIVATE SECTION. 11 | ENDCLASS. 12 | 13 | 14 | 15 | CLASS ZCL_JSON_TO_XML_CALL IMPLEMENTATION. 16 | 17 | 18 | METHOD IF_OO_ADT_CLASSRUN~MAIN. 19 | DATA(JSON) = `{"TEXT":"JSON"}`. 20 | CALL TRANSFORMATION ID SOURCE XML JSON 21 | RESULT XML DATA(XML). 22 | 23 | TRY. 24 | DATA(READER) = CL_SXML_STRING_READER=>CREATE( XML ). 25 | DATA(WRITER) = CAST IF_SXML_WRITER( 26 | CL_SXML_STRING_WRITER=>CREATE( ) ). 27 | WRITER->SET_OPTION( OPTION = IF_SXML_WRITER=>CO_OPT_LINEBREAKS ). 28 | WRITER->SET_OPTION( OPTION = IF_SXML_WRITER=>CO_OPT_INDENT ). 29 | READER->NEXT_NODE( ). 30 | READER->SKIP_NODE( WRITER ). 31 | * DATA(xml_output) = cl_abap_codepage=>convert_from( CAST cl_sxml_string_writer( writer )->get_output( ) ). 32 | DATA(XML_OUTPUT) = CL_ABAP_CONV_CODEPAGE=>CREATE_IN( )->CONVERT( CAST CL_SXML_STRING_WRITER( WRITER )->GET_OUTPUT( ) ). 33 | CATCH CX_SXML_PARSE_ERROR. 34 | RETURN. 35 | ENDTRY. 36 | 37 | OUT->WRITE( XML_OUTPUT ). 38 | 39 | ENDMETHOD. 40 | ENDCLASS. 41 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_2_instance.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_2_INSTANCE 7 | E 8 | Instance Methods 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | ZCL_2_INSTANCE 17 | CALCULATE_FLIGHT_PRICE 18 | E 19 | Calculate Flight Price 20 | 21 | 22 | ZCL_2_INSTANCE 23 | CONSTRUCTOR 24 | E 25 | CONSTRUCTOR 26 | 27 | 28 | ZCL_2_INSTANCE 29 | FLIGHT 30 | E 31 | Flight 32 | 33 | 34 | ZCL_2_INSTANCE 35 | GET_FLIGHT_DETAILS 36 | E 37 | Get Booking Details 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_6_tester.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS ZCL_OO_TUTORIAL_6_TESTER DEFINITION 2 | PUBLIC 3 | FINAL 4 | CREATE PUBLIC . 5 | 6 | PUBLIC SECTION. 7 | INTERFACES IF_OO_ADT_CLASSRUN. 8 | PROTECTED SECTION. 9 | PRIVATE SECTION. 10 | ENDCLASS. 11 | 12 | 13 | 14 | CLASS ZCL_OO_TUTORIAL_6_TESTER IMPLEMENTATION. 15 | 16 | 17 | METHOD IF_OO_ADT_CLASSRUN~MAIN. 18 | SELECT * FROM /DMO/FLIGHT 19 | WHERE CARRIER_ID = `LH` 20 | INTO TABLE @DATA(FLIGHTS). 21 | 22 | LOOP AT FLIGHTS REFERENCE INTO DATA(FLIGHT). 23 | TRY. 24 | DATA(FLIGHT_OBJECT) = ZCL_OO_TUTORIAL_6_BASE=>GET_FLIGHT_OBJECT( 25 | CARRIER_ID = FLIGHT->CARRIER_ID 26 | CONNECTION_ID = FLIGHT->CONNECTION_ID 27 | FLIGHT_DATE = FLIGHT->FLIGHT_DATE ). 28 | OUT->WRITE( FLIGHT_OBJECT->GET_FLIGHT_DETAILS( ) ). 29 | OUT->WRITE( FLIGHT_OBJECT->CALCULATE_FLIGHT_PRICE( ) ). 30 | IF FLIGHT->PLANE_TYPE_ID CS ZCL_OO_TUTORIAL_6_BASE=>PLANE_TYPE-B747. 31 | DATA(FLIGHT_747) = CAST ZCL_OO_TUTORIAL_6_747( FLIGHT_OBJECT ). 32 | OUT->WRITE( FLIGHT_747->GET_INFLIGHT_MOVIES( ) ). 33 | ENDIF. 34 | OUT->WRITE( ` ` ). 35 | CATCH ZCX_OO_TUTORIAL INTO DATA(CX_FLIGHT). 36 | OUT->WRITE( CX_FLIGHT->GET_TEXT( ) ). 37 | ENDTRY. 38 | ENDLOOP. 39 | 40 | if sy-subrc = 0. 41 | endif. 42 | 43 | ENDMETHOD. 44 | ENDCLASS. 45 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_3.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_OO_TUTORIAL_3 7 | E 8 | Flight Data as Instance Methods 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | ZCL_OO_TUTORIAL_3 17 | CALCULATE_FLIGHT_PRICE 18 | E 19 | Calculate Flight Price 20 | 21 | 22 | ZCL_OO_TUTORIAL_3 23 | CONSTRUCTOR 24 | E 25 | CONSTRUCTOR 26 | 27 | 28 | ZCL_OO_TUTORIAL_3 29 | FLIGHT 30 | E 31 | Flight 32 | 33 | 34 | ZCL_OO_TUTORIAL_3 35 | GET_FLIGHT_DETAILS 36 | E 37 | Get Booking Details 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_5.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_OO_TUTORIAL_5 7 | E 8 | Flight Data with Exception Classes 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | ZCL_OO_TUTORIAL_5 17 | CALCULATE_FLIGHT_PRICE 18 | E 19 | Calculate Flight Price 20 | 21 | 22 | ZCL_OO_TUTORIAL_5 23 | CONSTRUCTOR 24 | E 25 | CONSTRUCTOR 26 | 27 | 28 | ZCL_OO_TUTORIAL_5 29 | GET_FLIGHT_DETAILS 30 | E 31 | Get Booking Details 32 | 33 | 34 | ZCL_OO_TUTORIAL_5 35 | TEST 36 | E 37 | Flight 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_4.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_OO_TUTORIAL_4 7 | E 8 | Flight Data with Private Attribute and Func Method 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | ZCL_OO_TUTORIAL_4 17 | CALCULATE_FLIGHT_PRICE 18 | E 19 | Calculate Flight Price 20 | 21 | 22 | ZCL_OO_TUTORIAL_4 23 | CONSTRUCTOR 24 | E 25 | CONSTRUCTOR 26 | 27 | 28 | ZCL_OO_TUTORIAL_4 29 | FLIGHT 30 | E 31 | Flight 32 | 33 | 34 | ZCL_OO_TUTORIAL_4 35 | GET_FLIGHT_DETAILS 36 | E 37 | Get Booking Details 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/zcl_xml_to_json_call.clas.abap: -------------------------------------------------------------------------------- 1 | "!

XML To JSON via CALL Transformation

2 | CLASS zcl_xml_to_json_call DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | INTERFACES if_oo_adt_classrun. 9 | PROTECTED SECTION. 10 | PRIVATE SECTION. 11 | ENDCLASS. 12 | 13 | 14 | 15 | CLASS ZCL_XML_TO_JSON_CALL IMPLEMENTATION. 16 | 17 | 18 | METHOD if_oo_adt_classrun~main. 19 | DATA(xml) = `JSON`. 20 | DATA(json_writer) = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ). 21 | CALL TRANSFORMATION id SOURCE XML xml 22 | RESULT XML json_writer. 23 | 24 | 25 | TRY. 26 | DATA(reader) = cl_sxml_string_reader=>create( json_writer->get_output( ) ). 27 | DATA(writer) = CAST if_sxml_writer( 28 | cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ) ). 29 | writer->set_option( option = if_sxml_writer=>co_opt_linebreaks ). 30 | writer->set_option( option = if_sxml_writer=>co_opt_indent ). 31 | reader->next_node( ). 32 | reader->skip_node( writer ). 33 | data(json_output) = CL_ABAP_CONV_CODEPAGE=>CREATE_IN( )->CONVERT( CAST cl_sxml_string_writer( writer )->get_output( ) ). 34 | 35 | CATCH cx_sxml_parse_error. 36 | RETURN. 37 | ENDTRY. 38 | out->write( json_output ). 39 | ENDMETHOD. 40 | ENDCLASS. 41 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_4_tester.clas.abap: -------------------------------------------------------------------------------- 1 | "!

OO Tutorial #4 Tester

2 | CLASS ZCL_OO_TUTORIAL_4_TESTER DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | INTERFACES IF_OO_ADT_CLASSRUN. 9 | PROTECTED SECTION. 10 | PRIVATE SECTION. 11 | ENDCLASS. 12 | 13 | 14 | 15 | CLASS ZCL_OO_TUTORIAL_4_TESTER IMPLEMENTATION. 16 | 17 | 18 | METHOD IF_OO_ADT_CLASSRUN~MAIN. 19 | DATA(AA_0017) = NEW ZCL_OO_TUTORIAL_4( 20 | CARRIER_ID = `AA` 21 | CONNECTION_ID = `0017` 22 | FLIGHT_DATE = `20230222` ). 23 | 24 | DATA(FLIGHT_GOOD) = AA_0017->CALCULATE_FLIGHT_PRICE( ). 25 | OUT->WRITE( |Flight Price for AA-0017 on { CONV /DMO/FLIGHT_DATE( `20230222` ) DATE = ENVIRONMENT }: | && 26 | |{ FLIGHT_GOOD-PRICE CURRENCY = FLIGHT_GOOD-CURRENCY } { FLIGHT_GOOD-CURRENCY }| ). 27 | OUT->WRITE( AA_0017->GET_FLIGHT_DETAILS( ) ). 28 | 29 | OUT->WRITE( ` `). 30 | DATA(UA_0017) = NEW ZCL_OO_TUTORIAL_4( 31 | CARRIER_ID = `UA` 32 | CONNECTION_ID = `0058` 33 | FLIGHT_DATE = `20200426` ). 34 | 35 | DATA(FLIGHT_BAD) = UA_0017->CALCULATE_FLIGHT_PRICE( ). 36 | 37 | OUT->WRITE( |Flight Price for UA-0058 on { CONV /DMO/FLIGHT_DATE( `20200426` ) DATE = ENVIRONMENT }: | && 38 | |{ FLIGHT_BAD-PRICE CURRENCY = FLIGHT_BAD-CURRENCY } { FLIGHT_BAD-CURRENCY }| ). 39 | OUT->WRITE( UA_0017->GET_FLIGHT_DETAILS( ) ). 40 | ENDMETHOD. 41 | ENDCLASS. 42 | -------------------------------------------------------------------------------- /src/zcl_fs_ref_perf_testing.clas.abap: -------------------------------------------------------------------------------- 1 | "!

Field-Symbol vs. Reference Performance Testing

2 | CLASS zcl_fs_ref_perf_testing DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | INTERFACES if_oo_adt_classrun. 9 | PROTECTED SECTION. 10 | PRIVATE SECTION. 11 | DATA flights TYPE /dmo/t_flight. 12 | METHODS data_test. 13 | METHODS field_symbols_test. 14 | METHODS data_ref_test. 15 | ENDCLASS. 16 | 17 | 18 | 19 | CLASS ZCL_FS_REF_PERF_TESTING IMPLEMENTATION. 20 | 21 | 22 | METHOD if_oo_adt_classrun~main. 23 | DO 1000 TIMES. 24 | SELECT * FROM /dmo/flight APPENDING TABLE @flights. 25 | ENDDO. 26 | 27 | data_test( ). 28 | field_symbols_test( ). 29 | data_ref_test( ). 30 | ENDMETHOD. 31 | 32 | 33 | METHOD data_ref_test. 34 | LOOP AT flights REFERENCE INTO DATA(flight). 35 | IF flight->carrier_id = `AA`. 36 | flight->price += 35. 37 | ENDIF. 38 | ENDLOOP. 39 | ENDMETHOD. 40 | 41 | 42 | METHOD data_test. 43 | LOOP AT flights INTO DATA(flight). 44 | IF flight-carrier_id = `SQ`. 45 | flight-price += 35. 46 | modify table flights from flight. 47 | ENDIF. 48 | ENDLOOP. 49 | ENDMETHOD. 50 | 51 | 52 | METHOD field_symbols_test. 53 | LOOP AT flights ASSIGNING FIELD-SYMBOL(). 54 | IF -carrier_id = `SQ`. 55 | -price += 35. 56 | ENDIF. 57 | ENDLOOP. 58 | ENDMETHOD. 59 | ENDCLASS. 60 | -------------------------------------------------------------------------------- /src/zcl_xml_to_json.clas.abap: -------------------------------------------------------------------------------- 1 | "!

XML to JSON Conversion

2 | CLASS ZCL_XML_TO_JSON DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | INTERFACES IF_OO_ADT_CLASSRUN. 9 | PROTECTED SECTION. 10 | PRIVATE SECTION. 11 | ENDCLASS. 12 | 13 | 14 | 15 | CLASS ZCL_XML_TO_JSON IMPLEMENTATION. 16 | 17 | 18 | METHOD IF_OO_ADT_CLASSRUN~MAIN. 19 | DATA(XML) = CL_ABAP_CONV_CODEPAGE=>CREATE_OUT( )->CONVERT( 20 | `JSON` ). 21 | DATA(XML_READER) = CL_SXML_STRING_READER=>CREATE( XML ). 22 | DATA(JSON_WRITER) = CL_SXML_STRING_WRITER=>CREATE( TYPE = IF_SXML=>CO_XT_JSON ). 23 | XML_READER->NEXT_NODE( ). 24 | XML_READER->SKIP_NODE( JSON_WRITER ). 25 | 26 | TRY. 27 | DATA(READER) = CL_SXML_STRING_READER=>CREATE( JSON_WRITER->GET_OUTPUT( ) ). 28 | DATA(WRITER) = CAST IF_SXML_WRITER( 29 | CL_SXML_STRING_WRITER=>CREATE( TYPE = IF_SXML=>CO_XT_JSON ) ). 30 | WRITER->SET_OPTION( OPTION = IF_SXML_WRITER=>CO_OPT_LINEBREAKS ). 31 | WRITER->SET_OPTION( OPTION = IF_SXML_WRITER=>CO_OPT_INDENT ). 32 | READER->NEXT_NODE( ). 33 | READER->SKIP_NODE( WRITER ). 34 | DATA(JSON_OUTPUT) = CL_ABAP_CONV_CODEPAGE=>CREATE_IN( )->CONVERT( CAST CL_SXML_STRING_WRITER( WRITER )->GET_OUTPUT( ) ). 35 | 36 | CATCH CX_SXML_PARSE_ERROR. 37 | RETURN. 38 | ENDTRY. 39 | OUT->WRITE( JSON_OUTPUT ). 40 | 41 | ENDMETHOD. 42 | ENDCLASS. 43 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_1_basic_class_tester.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_1_basic_class_tester DEFINITION 2 | PUBLIC 3 | FINAL 4 | CREATE PUBLIC . 5 | 6 | PUBLIC SECTION. 7 | INTERFACES IF_OO_ADT_CLASSRUN. 8 | PROTECTED SECTION. 9 | PRIVATE SECTION. 10 | ENDCLASS. 11 | 12 | 13 | 14 | CLASS zcl_1_basic_class_tester IMPLEMENTATION. 15 | METHOD if_oo_adt_classrun~main. 16 | * out->write( |sample_Internal_Table Starter| ). 17 | * out->write( zcl_1_basic_class=>sample_Internal_Table ). 18 | * APPEND INITIAL LINE TO zcl_1_basic_class=>sample_internal_table REFERENCE INTO DATA(line). 19 | * line->* = `Sneaky Stuff I Injected`. 20 | 21 | out->write( |\nCalling First Method| ). 22 | data(class_Instance) = new zcl_1_basic_class( ). 23 | out->write( class_Instance->my_first_method( `First Call` ) ). 24 | 25 | out->write( class_Instance->my_second_method( ) ). 26 | 27 | out->write( |\nCalling First Method Again| ). 28 | out->write( class_Instance->my_first_method( `Second Call` ) ). 29 | 30 | out->write( class_Instance->my_second_method( ) ). 31 | 32 | clear class_instance. 33 | * out->write( zcl_1_basic_class=>sample_Internal_Table ). 34 | * out->write( class_Instance->my_second_method( ) ). 35 | 36 | out->write( |\nCalling New Instance First Method| ). 37 | data(class_Instance_New) = new zcl_1_basic_class( ). 38 | out->write( class_Instance_New->my_first_method( `First Call Of New Instance` ) ). 39 | out->write( class_Instance_New->my_second_method( ) ). 40 | ENDMETHOD. 41 | 42 | ENDCLASS. 43 | -------------------------------------------------------------------------------- /src/zcl_abap_to_json.clas.abap: -------------------------------------------------------------------------------- 1 | "!

ABAP To JSON Example

2 | CLASS zcl_abap_to_json DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | INTERFACES if_oo_adt_classrun. 9 | PROTECTED SECTION. 10 | PRIVATE SECTION. 11 | ENDCLASS. 12 | 13 | 14 | 15 | CLASS ZCL_ABAP_TO_JSON IMPLEMENTATION. 16 | 17 | 18 | METHOD if_oo_adt_classrun~main. 19 | 20 | SELECT * FROM /DMO/FLIGHT INTO TABLE @DATA(flights). 21 | DATA(json_writer) = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ). 22 | CALL TRANSFORMATION id SOURCE flights = flights 23 | RESULT XML json_writer. 24 | 25 | TRY. 26 | DATA(reader) = cl_sxml_string_reader=>create( json_writer->get_output( ) ). 27 | DATA(writer) = CAST if_sxml_writer( 28 | cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ) ). 29 | writer->set_option( option = if_sxml_writer=>co_opt_linebreaks ). 30 | writer->set_option( option = if_sxml_writer=>co_opt_indent ). 31 | reader->next_node( ). 32 | reader->skip_node( writer ). 33 | * data(json_output) = cl_abap_codepage=>convert_from( CAST cl_sxml_string_writer( writer )->get_output( ) ). 34 | data(json_output) = CL_ABAP_CONV_CODEPAGE=>CREATE_IN( )->CONVERT( CAST cl_sxml_string_writer( writer )->get_output( ) ). 35 | CATCH cx_sxml_parse_error. 36 | RETURN. 37 | ENDTRY. 38 | out->write( json_output ). 39 | 40 | 41 | ENDMETHOD. 42 | ENDCLASS. 43 | -------------------------------------------------------------------------------- /src/zcl_json_to_xml.clas.abap: -------------------------------------------------------------------------------- 1 | "!

Convert JSON to XML

2 | CLASS ZCL_JSON_TO_XML DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | INTERFACES IF_OO_ADT_CLASSRUN. 9 | PROTECTED SECTION. 10 | PRIVATE SECTION. 11 | ENDCLASS. 12 | 13 | 14 | 15 | CLASS ZCL_JSON_TO_XML IMPLEMENTATION. 16 | 17 | 18 | METHOD IF_OO_ADT_CLASSRUN~MAIN. 19 | * DATA(json) = cl_abap_codepage=>convert_to( `{"TEXT":"JSON"}` ). 20 | DATA(JSON) = CL_ABAP_CONV_CODEPAGE=>CREATE_OUT( )->CONVERT( `{"TEXT":"JSON"}` ). 21 | DATA(JSON_READER) = CL_SXML_STRING_READER=>CREATE( JSON ). 22 | DATA(XML_WRITER) = CL_SXML_STRING_WRITER=>CREATE( ). 23 | JSON_READER->NEXT_NODE( ). 24 | JSON_READER->SKIP_NODE( XML_WRITER ). 25 | 26 | TRY. 27 | DATA(READER) = CL_SXML_STRING_READER=>CREATE( XML_WRITER->GET_OUTPUT( ) ). 28 | DATA(WRITER) = CAST IF_SXML_WRITER( 29 | CL_SXML_STRING_WRITER=>CREATE( ) ). 30 | WRITER->SET_OPTION( OPTION = IF_SXML_WRITER=>CO_OPT_LINEBREAKS ). 31 | WRITER->SET_OPTION( OPTION = IF_SXML_WRITER=>CO_OPT_INDENT ). 32 | READER->NEXT_NODE( ). 33 | READER->SKIP_NODE( WRITER ). 34 | * DATA(XML_OUTPUT) = CL_ABAP_CODEPAGE=>CONVERT_FROM( CAST CL_SXML_STRING_WRITER( WRITER )->GET_OUTPUT( ) ). 35 | DATA(XML_OUTPUT) = CL_ABAP_CONV_CODEPAGE=>CREATE_IN( )->CONVERT( CAST CL_SXML_STRING_WRITER( WRITER )->GET_OUTPUT( ) ). 36 | CATCH CX_SXML_PARSE_ERROR. 37 | RETURN. 38 | ENDTRY. 39 | 40 | OUT->WRITE( XML_OUTPUT ). 41 | ENDMETHOD. 42 | ENDCLASS. 43 | -------------------------------------------------------------------------------- /src/zcl_inline_declare.clas.abap: -------------------------------------------------------------------------------- 1 | "!

ABAP Inline Declaration

2 | CLASS zcl_inline_declare DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | INTERFACES if_oo_adt_classrun. 9 | PROTECTED SECTION. 10 | PRIVATE SECTION. 11 | ENDCLASS. 12 | 13 | 14 | 15 | CLASS ZCL_INLINE_DECLARE IMPLEMENTATION. 16 | 17 | 18 | METHOD if_oo_adt_classrun~main. 19 | 20 | 21 | SELECT * FROM /dmo/flight INTO TABLE @DATA(flights). 22 | 23 | LOOP AT flights INTO DATA(flight). 24 | ENDLOOP. 25 | 26 | READ TABLE flights INTO DATA(flight2) INDEX 1. 27 | 28 | DATA old TYPE i VALUE 6. 29 | DATA inc TYPE i VALUE 5. 30 | DATA(new) = old + inc. 31 | 32 | DATA(rnd) = cl_abap_random_int=>create( seed = CONV i( CL_ABAP_CONTEXT_INFO=>GET_SYSTEM_TIME( ) ) 33 | min = 0 max = 500 ). 34 | 35 | ****Old Way 36 | FIELD-SYMBOLS: LIKE LINE OF flights, 37 | LIKE LINE OF flights, 38 | TYPE t. "Wrong type - causes program to dump 39 | 40 | READ TABLE flights ASSIGNING INDEX 1. 41 | LOOP AT flights ASSIGNING . 42 | * ASSIGN COMPONENT 1 OF STRUCTURE TO . 43 | ENDLOOP. 44 | 45 | ****New Way 46 | READ TABLE flights REFERENCE INTO DATA(new_line1) INDEX 1. 47 | LOOP AT flights REFERENCE INTO DATA(new_line). 48 | ASSIGN COMPONENT 1 OF STRUCTURE new_line TO FIELD-SYMBOL(). 49 | ENDLOOP. 50 | 51 | ****Breakpoint helper 52 | IF sy-subrc = 0. 53 | ENDIF. 54 | 55 | ENDMETHOD. 56 | ENDCLASS. 57 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_3_tester.clas.abap: -------------------------------------------------------------------------------- 1 | "!

OO Tutorial #3 Tester

2 | CLASS ZCL_OO_TUTORIAL_3_TESTER DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | INTERFACES IF_OO_ADT_CLASSRUN. 9 | PROTECTED SECTION. 10 | PRIVATE SECTION. 11 | ENDCLASS. 12 | 13 | 14 | 15 | CLASS ZCL_OO_TUTORIAL_3_TESTER IMPLEMENTATION. 16 | 17 | 18 | METHOD IF_OO_ADT_CLASSRUN~MAIN. 19 | DATA(AA_0017) = NEW ZCL_OO_TUTORIAL_3( 20 | CARRIER_ID = `AA` 21 | CONNECTION_ID = `0017` 22 | FLIGHT_DATE = `20230222` ). 23 | 24 | AA_0017->FLIGHT-PRICE = `0.01`. 25 | AA_0017->CALCULATE_FLIGHT_PRICE( 26 | IMPORTING 27 | PRICE = DATA(PRICE) 28 | CURRENCY_CODE = DATA(CURRENCY_CODE) ). 29 | 30 | OUT->WRITE( |Flight Price for AA-0017 on { CONV /DMO/FLIGHT_DATE( `20230222` ) DATE = ENVIRONMENT }: | && 31 | |{ PRICE CURRENCY = CURRENCY_CODE } { CURRENCY_CODE }| ). 32 | OUT->WRITE( AA_0017->GET_FLIGHT_DETAILS( ) ). 33 | 34 | OUT->WRITE( ` ` ). 35 | DATA(UA_0017) = NEW ZCL_OO_TUTORIAL_3( 36 | CARRIER_ID = `UA` 37 | CONNECTION_ID = `0058` 38 | FLIGHT_DATE = `20200426` ). 39 | 40 | UA_0017->CALCULATE_FLIGHT_PRICE( 41 | IMPORTING 42 | PRICE = DATA(PRICE_BAD) 43 | CURRENCY_CODE = DATA(CURRENCY_CODE_BAD) ). 44 | 45 | OUT->WRITE( |Flight Price for UA-0058 on { CONV /DMO/FLIGHT_DATE( `20200426` ) DATE = ENVIRONMENT }: | && 46 | |{ PRICE_BAD CURRENCY = CURRENCY_CODE_BAD } { CURRENCY_CODE_BAD }| ). 47 | OUT->WRITE( UA_0017->GET_FLIGHT_DETAILS( ) ). 48 | 49 | ENDMETHOD. 50 | ENDCLASS. 51 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_5_tester.clas.abap: -------------------------------------------------------------------------------- 1 | "!

OO Tutorial #5 Tester

2 | CLASS ZCL_OO_TUTORIAL_5_TESTER DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | INTERFACES IF_OO_ADT_CLASSRUN. 9 | PROTECTED SECTION. 10 | PRIVATE SECTION. 11 | ENDCLASS. 12 | 13 | 14 | 15 | CLASS ZCL_OO_TUTORIAL_5_TESTER IMPLEMENTATION. 16 | 17 | 18 | METHOD IF_OO_ADT_CLASSRUN~MAIN. 19 | 20 | TRY. 21 | DATA(AA_0017) = NEW ZCL_OO_TUTORIAL_5( 22 | CARRIER_ID = `AA` 23 | CONNECTION_ID = `0017` 24 | FLIGHT_DATE = `20230222` ). 25 | DATA(FLIGHT_GOOD) = AA_0017->CALCULATE_FLIGHT_PRICE( ). 26 | OUT->WRITE( |Flight Price for AA-0017 on { CONV /DMO/FLIGHT_DATE( `20230222` ) DATE = ENVIRONMENT }: | && 27 | |{ FLIGHT_GOOD-PRICE CURRENCY = FLIGHT_GOOD-CURRENCY } { FLIGHT_GOOD-CURRENCY }| ). 28 | OUT->WRITE( AA_0017->GET_FLIGHT_DETAILS( ) ). 29 | 30 | OUT->WRITE( ` `). 31 | DATA(UA_0017) = NEW ZCL_OO_TUTORIAL_5( 32 | CARRIER_ID = `UA` 33 | CONNECTION_ID = `0058` 34 | FLIGHT_DATE = `20200426` ). 35 | 36 | DATA(FLIGHT_BAD) = UA_0017->CALCULATE_FLIGHT_PRICE( ). 37 | 38 | OUT->WRITE( |Flight Price for UA-0058 on { CONV /DMO/FLIGHT_DATE( `20220426` ) DATE = ENVIRONMENT }: | && 39 | |{ FLIGHT_BAD-PRICE CURRENCY = FLIGHT_BAD-CURRENCY } { FLIGHT_BAD-CURRENCY }| ). 40 | OUT->WRITE( UA_0017->GET_FLIGHT_DETAILS( ) ). 41 | 42 | CATCH ZCX_OO_TUTORIAL INTO DATA(CX_FLIGHT). 43 | OUT->WRITE( CX_FLIGHT->GET_TEXT( ) ). 44 | ENDTRY. 45 | 46 | ENDMETHOD. 47 | ENDCLASS. 48 | -------------------------------------------------------------------------------- /src/zcx_oo_tutorial.clas.abap: -------------------------------------------------------------------------------- 1 | class ZCX_OO_TUTORIAL definition 2 | public 3 | inheriting from CX_STATIC_CHECK 4 | final 5 | create public . 6 | 7 | public section. 8 | 9 | interfaces IF_T100_DYN_MSG . 10 | interfaces IF_T100_MESSAGE . 11 | data CARRID type /DMO/CARRIER_ID . 12 | constants: 13 | begin of ZCX_OO_TUTORIAL, 14 | MSGID type SYMSGID value 'ZOO_MESSAGES', 15 | MSGNO type SYMSGNO value '001', 16 | ATTR1 type SCX_ATTRNAME value '', 17 | ATTR2 type SCX_ATTRNAME value '', 18 | ATTR3 type SCX_ATTRNAME value '', 19 | ATTR4 type SCX_ATTRNAME value '', 20 | end of ZCX_OO_TUTORIAL. 21 | 22 | constants: 23 | begin of FLIGHT_NOT_FOUND, 24 | MSGID type SYMSGID value 'ZOO_MESSAGES', 25 | MSGNO type SYMSGNO value '002', 26 | ATTR1 type SCX_ATTRNAME value 'CARRID', 27 | ATTR2 type SCX_ATTRNAME value '', 28 | ATTR3 type SCX_ATTRNAME value '', 29 | ATTR4 type SCX_ATTRNAME value '', 30 | end of FLIGHT_NOT_FOUND. 31 | 32 | methods CONSTRUCTOR 33 | importing 34 | !TEXTID like IF_T100_MESSAGE=>T100KEY optional 35 | !PREVIOUS like PREVIOUS optional 36 | !CARRID type /DMO/CARRIER_ID optional . 37 | protected section. 38 | private section. 39 | ENDCLASS. 40 | 41 | 42 | 43 | CLASS ZCX_OO_TUTORIAL IMPLEMENTATION. 44 | 45 | 46 | method CONSTRUCTOR ##ADT_SUPPRESS_GENERATION. 47 | call method SUPER->CONSTRUCTOR 48 | exporting 49 | PREVIOUS = PREVIOUS. 50 | clear ME->TEXTID. 51 | if TEXTID is initial. 52 | IF_T100_MESSAGE~T100KEY = IF_T100_MESSAGE=>DEFAULT_TEXTID. 53 | else. 54 | IF_T100_MESSAGE~T100KEY = TEXTID. 55 | endif. 56 | ME->CARRID = CARRID . 57 | endmethod. 58 | ENDCLASS. 59 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_2_instance.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_2_instance DEFINITION 2 | PUBLIC 3 | FINAL 4 | CREATE PUBLIC . 5 | 6 | PUBLIC SECTION. 7 | "!

Flight

8 | DATA flight TYPE /dmo/flight. 9 | 10 | "!

CONSTRUCTOR

11 | METHODS constructor 12 | IMPORTING 13 | !carrier_id TYPE /dmo/carrier_id 14 | !connection_id TYPE /dmo/connection_id 15 | !flight_date TYPE /dmo/flight_date. 16 | 17 | "!

Get Booking Details

18 | METHODS get_flight_details 19 | RETURNING VALUE(flight) TYPE /dmo/flight . 20 | 21 | "!

Calculate Flight Price

22 | METHODS calculate_flight_price 23 | EXPORTING 24 | !price TYPE /dmo/flight_price 25 | !currency_code TYPE /dmo/currency_code. 26 | PROTECTED SECTION. 27 | PRIVATE SECTION. 28 | ENDCLASS. 29 | 30 | 31 | 32 | CLASS zcl_2_instance IMPLEMENTATION. 33 | 34 | METHOD calculate_flight_price. 35 | 36 | price = me->flight-price. 37 | currency_code = me->flight-currency_code. 38 | 39 | CASE me->flight-plane_type_id. 40 | WHEN `747-400`. 41 | PRICE = PRICE + 40. 42 | WHEN `A321-200`. 43 | PRICE = PRICE + 25. 44 | WHEN OTHERS. 45 | PRICE = PRICE + 10. 46 | ENDCASE. 47 | ENDMETHOD. 48 | 49 | 50 | METHOD constructor. 51 | SELECT SINGLE * FROM /dmo/flight 52 | WHERE carrier_id = @carrier_id 53 | AND connection_id = @connection_id 54 | AND flight_date = @flight_date 55 | INTO @flight. 56 | ENDMETHOD. 57 | 58 | 59 | METHOD get_flight_details. 60 | flight = me->flight. 61 | ENDMETHOD. 62 | ENDCLASS. 63 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcx_5_composite.clas.abap: -------------------------------------------------------------------------------- 1 | class ZCX_5_COMPOSITE definition 2 | public 3 | inheriting from CX_STATIC_CHECK 4 | final 5 | create public . 6 | 7 | public section. 8 | 9 | interfaces IF_T100_DYN_MSG . 10 | interfaces IF_T100_MESSAGE . 11 | data CARRID type /DMO/CARRIER_ID . 12 | constants: 13 | begin of ZCX_5_COMPOSITE, 14 | MSGID type SYMSGID value 'ZOO_PATTERNS', 15 | MSGNO type SYMSGNO value '001', 16 | ATTR1 type SCX_ATTRNAME value '', 17 | ATTR2 type SCX_ATTRNAME value '', 18 | ATTR3 type SCX_ATTRNAME value '', 19 | ATTR4 type SCX_ATTRNAME value '', 20 | end of ZCX_5_COMPOSITE. 21 | 22 | constants: 23 | begin of FLIGHT_NOT_FOUND, 24 | MSGID type SYMSGID value 'ZOO_PATTERNS', 25 | MSGNO type SYMSGNO value '002', 26 | ATTR1 type SCX_ATTRNAME value 'CARRID', 27 | ATTR2 type SCX_ATTRNAME value '', 28 | ATTR3 type SCX_ATTRNAME value '', 29 | ATTR4 type SCX_ATTRNAME value '', 30 | end of FLIGHT_NOT_FOUND. 31 | 32 | methods CONSTRUCTOR 33 | importing 34 | !TEXTID like IF_T100_MESSAGE=>T100KEY optional 35 | !PREVIOUS like PREVIOUS optional 36 | !CARRID type /DMO/CARRIER_ID optional . 37 | protected section. 38 | private section. 39 | ENDCLASS. 40 | 41 | 42 | 43 | CLASS ZCX_5_COMPOSITE IMPLEMENTATION. 44 | 45 | 46 | method CONSTRUCTOR ##ADT_SUPPRESS_GENERATION. 47 | call method SUPER->CONSTRUCTOR 48 | exporting 49 | PREVIOUS = PREVIOUS. 50 | clear ME->TEXTID. 51 | if TEXTID is initial. 52 | IF_T100_MESSAGE~T100KEY = IF_T100_MESSAGE=>DEFAULT_TEXTID. 53 | else. 54 | IF_T100_MESSAGE~T100KEY = TEXTID. 55 | endif. 56 | ME->CARRID = CARRID . 57 | endmethod. 58 | ENDCLASS. 59 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_6_base.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_OO_TUTORIAL_6_BASE 7 | E 8 | Flight Data Basic Class 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | ZCL_OO_TUTORIAL_6_BASE 17 | CLASS_BASE_NAME 18 | E 19 | Base Class Name 20 | 21 | 22 | ZCL_OO_TUTORIAL_6_BASE 23 | CLASS_OTHER 24 | E 25 | Class Name Other 26 | 27 | 28 | ZCL_OO_TUTORIAL_6_BASE 29 | CONSTRUCTOR 30 | E 31 | CONSTRUCTOR 32 | 33 | 34 | ZCL_OO_TUTORIAL_6_BASE 35 | FLIGHT 36 | E 37 | Flight 38 | 39 | 40 | ZCL_OO_TUTORIAL_6_BASE 41 | GET_FLIGHT_OBJECT 42 | E 43 | Get Filght Object 44 | 45 | 46 | ZCL_OO_TUTORIAL_6_BASE 47 | PLANE_TYPE 48 | E 49 | Plane Type Enumerator 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_5_composite_base.clas.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZCL_5_COMPOSITE_BASE 7 | E 8 | Composite Pattern Abstract Base Class 9 | 1 10 | X 11 | X 12 | X 13 | 14 | 15 | 16 | ZCL_5_COMPOSITE_BASE 17 | CLASS_BASE_NAME 18 | E 19 | Base Class Name 20 | 21 | 22 | ZCL_5_COMPOSITE_BASE 23 | CLASS_OTHER 24 | E 25 | Class Name Other 26 | 27 | 28 | ZCL_5_COMPOSITE_BASE 29 | CONSTRUCTOR 30 | E 31 | CONSTRUCTOR 32 | 33 | 34 | ZCL_5_COMPOSITE_BASE 35 | FACTORY 36 | E 37 | Get Filght Object 38 | 39 | 40 | ZCL_5_COMPOSITE_BASE 41 | FLIGHT 42 | E 43 | Flight 44 | 45 | 46 | ZCL_5_COMPOSITE_BASE 47 | PLANE_TYPE 48 | E 49 | Plane Type Enumerator 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_5_composite_747.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_5_composite_747 DEFINITION 2 | PUBLIC 3 | INHERITING FROM zcl_5_composite_base 4 | FINAL 5 | CREATE PROTECTED 6 | GLOBAL FRIENDS zcl_5_composite_base. 7 | 8 | PUBLIC SECTION. 9 | 10 | TYPES: 11 | BEGIN OF movie, 12 | movie_title TYPE string, 13 | running_time TYPE string, 14 | END OF movie. 15 | TYPES: 16 | movies_table TYPE STANDARD TABLE OF movie WITH EMPTY KEY. 17 | 18 | "!

CONSTRUCTOR

19 | METHODS constructor 20 | IMPORTING 21 | !flight TYPE /dmo/flight. 22 | 23 | "!

Get a listing of in flight movies

24 | METHODS get_inflight_movies 25 | RETURNING VALUE(movies) TYPE zcl_5_composite_747=>movies_table. 26 | * EXPORTING !MOVIES TYPE ZCL_OO_TUTORIAL_6_747=>MOVIES_TABLE. 27 | 28 | METHODS zif_5_composite~calculate_flight_price 29 | REDEFINITION . 30 | 31 | PROTECTED SECTION. 32 | PRIVATE SECTION. 33 | "!

List of Movies on the Flight

34 | DATA MOVIES TYPE MOVIES_TABLE. 35 | ENDCLASS. 36 | 37 | 38 | 39 | CLASS zcl_5_composite_747 IMPLEMENTATION. 40 | 41 | METHOD CONSTRUCTOR. 42 | SUPER->CONSTRUCTOR( 43 | FLIGHT = FLIGHT ). 44 | 45 | INSERT VALUE #( MOVIE_TITLE = `Transformers: Revenge of the Fallen` RUNNING_TIME = `150 min` ) INTO TABLE me->movies. 46 | INSERT VALUE #( MOVIE_TITLE = `The Hangover` RUNNING_TIME = `100 min` ) INTO TABLE me->movies. 47 | 48 | ENDMETHOD. 49 | 50 | METHOD GET_INFLIGHT_MOVIES. 51 | MOVIES = ME->MOVIES. 52 | ENDMETHOD. 53 | 54 | 55 | METHOD zif_5_composite~CALCULATE_FLIGHT_PRICE. 56 | price = SUPER->CALCULATE_FLIGHT_PRICE( ). 57 | PRICE-PRICE = PRICE-PRICE + 35. 58 | 59 | ENDMETHOD. 60 | ENDCLASS. 61 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_2_static.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_2_static DEFINITION 2 | PUBLIC 3 | FINAL 4 | CREATE PUBLIC . 5 | 6 | PUBLIC SECTION. 7 | "!

Get Booking Details

8 | CLASS-METHODS get_flight_details 9 | IMPORTING 10 | !carrier_id TYPE /dmo/carrier_id 11 | !connection_id TYPE /dmo/connection_id 12 | !flight_date TYPE /dmo/flight_date 13 | RETURNING VALUE(flight) TYPE /dmo/flight. 14 | 15 | 16 | "!

Calculate Flight Price

17 | CLASS-METHODS calculate_flight_price 18 | IMPORTING 19 | !carrier_id TYPE /dmo/carrier_id 20 | !connection_id TYPE /dmo/connection_id 21 | !flight_date TYPE /dmo/flight_date 22 | EXPORTING 23 | !price TYPE /dmo/flight_price 24 | !currency_code TYPE /dmo/currency_code. 25 | PROTECTED SECTION. 26 | PRIVATE SECTION. 27 | ENDCLASS. 28 | 29 | 30 | 31 | CLASS zcl_2_static IMPLEMENTATION. 32 | METHOD calculate_flight_price. 33 | DATA plane_type TYPE /dmo/plane_type_id. 34 | 35 | SELECT SINGLE price, currency_code, plane_type_id FROM /dmo/flight 36 | WHERE carrier_id = @carrier_id 37 | AND connection_id = @connection_id 38 | AND flight_date = @flight_date 39 | INTO (@price, @currency_code, @plane_type). 40 | 41 | CASE plane_type. 42 | WHEN `747-400`. 43 | price = price + 40. 44 | WHEN `A321-200`. 45 | price = price + 25. 46 | WHEN OTHERS. 47 | price = price + 10. 48 | ENDCASE. 49 | ENDMETHOD. 50 | 51 | 52 | METHOD get_flight_details. 53 | 54 | SELECT SINGLE * FROM /dmo/flight 55 | WHERE carrier_id = @carrier_id 56 | AND connection_id = @connection_id 57 | AND flight_date = @flight_date 58 | INTO @flight. 59 | endmethod. 60 | ENDCLASS. 61 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_3.clas.abap: -------------------------------------------------------------------------------- 1 | "!

Flight Data as Instance Methods

2 | CLASS zcl_oo_tutorial_3 DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | INTERFACES if_serializable_object. 9 | "!

Flight

10 | DATA flight TYPE /dmo/flight. 11 | 12 | "!

CONSTRUCTOR

13 | METHODS constructor 14 | IMPORTING 15 | !carrier_id TYPE /dmo/carrier_id 16 | !connection_id TYPE /dmo/connection_id 17 | !flight_date TYPE /dmo/flight_date. 18 | 19 | "!

Get Booking Details

20 | METHODS get_flight_details 21 | RETURNING VALUE(flight) TYPE /dmo/flight . 22 | 23 | "!

Calculate Flight Price

24 | METHODS calculate_flight_price 25 | EXPORTING 26 | !price TYPE /dmo/flight_price 27 | !currency_code TYPE /dmo/currency_code. 28 | PROTECTED SECTION. 29 | PRIVATE SECTION. 30 | ENDCLASS. 31 | 32 | 33 | 34 | CLASS ZCL_OO_TUTORIAL_3 IMPLEMENTATION. 35 | 36 | 37 | METHOD calculate_flight_price. 38 | 39 | price = me->flight-price. 40 | currency_code = me->flight-currency_code. 41 | 42 | CASE me->flight-plane_type_id. 43 | WHEN `747-400`. 44 | PRICE = PRICE + 40. 45 | WHEN `A321-200`. 46 | PRICE = PRICE + 25. 47 | WHEN OTHERS. 48 | PRICE = PRICE + 10. 49 | ENDCASE. 50 | ENDMETHOD. 51 | 52 | 53 | METHOD constructor. 54 | SELECT SINGLE * FROM /dmo/flight 55 | WHERE carrier_id = @carrier_id 56 | AND connection_id = @connection_id 57 | AND flight_date = @flight_date 58 | INTO @flight. 59 | ENDMETHOD. 60 | 61 | 62 | METHOD get_flight_details. 63 | flight = me->flight. 64 | ENDMETHOD. 65 | ENDCLASS. 66 | -------------------------------------------------------------------------------- /REUSE.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | SPDX-PackageName = "abap-oo-basics" 3 | SPDX-PackageSupplier = "Thomas Jung " 4 | SPDX-PackageDownloadLocation = "https://github.com/sap-samples/abap-oo-basics" 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 = "2024 SAP SE or an SAP affiliate company and abap-oo-basics contributors" 11 | SPDX-License-Identifier = "Apache-2.0" 12 | -------------------------------------------------------------------------------- /src/zcl_hungarian_notation.clas.abap: -------------------------------------------------------------------------------- 1 | "!

ABAP Class examples with and without Hungarian Notation

2 | CLASS zcl_hungarian_notation DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | INTERFACES if_oo_adt_classrun. 9 | methods mu_export_flights 10 | exporting 11 | !et_flights type /dmo/t_flight. 12 | methods get_flights 13 | exporting 14 | !flights type /dmo/t_flight. 15 | PROTECTED SECTION. 16 | PRIVATE SECTION. 17 | "!

All Flights

18 | DATA flights TYPE /dmo/t_flight. 19 | "!

All Flights

20 | data git_flights TYPE /dmo/t_flight. 21 | 22 | 23 | ENDCLASS. 24 | 25 | 26 | 27 | CLASS ZCL_HUNGARIAN_NOTATION IMPLEMENTATION. 28 | 29 | 30 | METHOD if_oo_adt_classrun~main. 31 | 32 | select * from /dmo/flight into table @flights. 33 | select * from /dmo/flight into table @git_flights. 34 | select * from @git_flights as FLIGHTS where carrier_id = 'AA' into table @data(lt_flights) . 35 | select * from @flights as FLIGHTS where carrier_id = 'AA' into table @data(flights_american). 36 | 37 | loop at lt_flights REFERENCE INTO data(lr_flight). 38 | if lr_flight->connection_id = '0017'. 39 | endif. 40 | endloop. 41 | 42 | loop at flights_american REFERENCE INTO data(flight). 43 | if flight->connection_id = '0017'. 44 | endif. 45 | endloop. 46 | 47 | mu_export_flights( 48 | IMPORTING 49 | et_flights = data(li_flights) 50 | ). 51 | 52 | get_flights( 53 | IMPORTING 54 | flights = data(processed_flights) 55 | ). 56 | 57 | ENDMETHOD. 58 | 59 | 60 | METHOD mu_export_flights. 61 | et_flights = git_flights. 62 | ENDMETHOD. 63 | 64 | 65 | METHOD get_flights. 66 | flights = me->flights. 67 | ENDMETHOD. 68 | ENDCLASS. 69 | -------------------------------------------------------------------------------- /src/zobject_xml.tabl.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ZOBJECT_XML 7 | E 8 | TRANSP 9 | X 10 | Store ABAP Object instances as XML 11 | E 12 | A 13 | 1 14 | 5 15 | 16 | 17 | ZOBJECT_XML 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 | 0 39 | N 40 | 000010 41 | X 42 | NUMC 43 | 000005 44 | NUMC 45 | 46 | 47 | CONTENT 48 | 0 49 | y 50 | 000008 51 | RSTR 52 | RSTR 53 | 54 | 55 | 56 | 57 | ZOBJECT_XML 58 | CUS_DEV_SUP_DA 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_4.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS ZCL_OO_TUTORIAL_4 DEFINITION 2 | PUBLIC 3 | FINAL 4 | CREATE PUBLIC . 5 | 6 | PUBLIC SECTION. 7 | 8 | TYPES: 9 | BEGIN OF COST, 10 | PRICE TYPE /DMO/FLIGHT_PRICE, 11 | CURRENCY TYPE /DMO/CURRENCY_CODE, 12 | END OF COST . 13 | 14 | "!

CONSTRUCTOR

15 | METHODS CONSTRUCTOR 16 | IMPORTING 17 | !CARRIER_ID TYPE /DMO/CARRIER_ID 18 | !CONNECTION_ID TYPE /DMO/CONNECTION_ID 19 | !FLIGHT_DATE TYPE /DMO/FLIGHT_DATE. 20 | 21 | "!

Get Booking Details

22 | METHODS GET_FLIGHT_DETAILS 23 | RETURNING VALUE(FLIGHT) TYPE /DMO/FLIGHT. 24 | 25 | "!

Calculate Flight Price

26 | METHODS CALCULATE_FLIGHT_PRICE 27 | RETURNING 28 | VALUE(PRICE) TYPE COST. 29 | 30 | PROTECTED SECTION. 31 | PRIVATE SECTION. 32 | "!

Flight

33 | DATA FLIGHT TYPE /DMO/FLIGHT. 34 | ENDCLASS. 35 | 36 | 37 | 38 | CLASS ZCL_OO_TUTORIAL_4 IMPLEMENTATION. 39 | 40 | 41 | METHOD CALCULATE_FLIGHT_PRICE. 42 | 43 | PRICE-PRICE = ME->FLIGHT-PRICE. 44 | PRICE-CURRENCY = ME->FLIGHT-CURRENCY_CODE. 45 | 46 | CASE ME->FLIGHT-PLANE_TYPE_ID. 47 | WHEN '747-400'. 48 | PRICE-PRICE = PRICE-PRICE + 40. 49 | WHEN `A321-200`. 50 | PRICE-PRICE = PRICE-PRICE + 25. 51 | WHEN OTHERS. 52 | PRICE-PRICE = PRICE-PRICE + 10. 53 | ENDCASE. 54 | ENDMETHOD. 55 | 56 | 57 | METHOD CONSTRUCTOR. 58 | SELECT SINGLE * FROM /DMO/FLIGHT 59 | WHERE CARRIER_ID = @CARRIER_ID 60 | AND CONNECTION_ID = @CONNECTION_ID 61 | AND FLIGHT_DATE = @FLIGHT_DATE 62 | INTO @FLIGHT. 63 | ENDMETHOD. 64 | 65 | 66 | METHOD GET_FLIGHT_DETAILS. 67 | FLIGHT = ME->FLIGHT. 68 | ENDMETHOD. 69 | ENDCLASS. 70 | -------------------------------------------------------------------------------- /src/zcl_abap_to_json_id.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_abap_to_json_id DEFINITION 2 | PUBLIC 3 | FINAL 4 | CREATE PUBLIC . 5 | 6 | PUBLIC SECTION. 7 | INTERFACES if_oo_adt_classrun. 8 | PROTECTED SECTION. 9 | PRIVATE SECTION. 10 | ENDCLASS. 11 | 12 | 13 | 14 | CLASS ZCL_ABAP_TO_JSON_ID IMPLEMENTATION. 15 | 16 | 17 | METHOD if_oo_adt_classrun~main. 18 | 19 | DATA(ua_0058) = NEW zcl_oo_tutorial_5( 20 | carrier_id = `UA` 21 | connection_id = `0058` 22 | flight_date = `20220426` ). 23 | DATA(json_writer) = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ). 24 | CALL TRANSFORMATION id SOURCE flight = ua_0058 25 | RESULT XML json_writer. "data(json_out). "json_writer. DATA(json_out). 26 | * out->write( json_out ). 27 | * clear ua_0058. 28 | * data object_xml type zobject_xml. 29 | * object_xml-id = 1. 30 | * object_xml-content = json_out. 31 | * MODIFY ZOBJECT_XML from @object_xml. 32 | * data context2 type ref to zcl_oo_tutorial_5. 33 | * CALL TRANSFORMATION id SOURCE XML json_out 34 | * RESULT flight = context2. 35 | * out->write( context2->get_flight_details( ) ). 36 | 37 | TRY. 38 | DATA(reader) = cl_sxml_string_reader=>create( json_writer->get_output( ) ). 39 | DATA(writer) = CAST if_sxml_writer( 40 | cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ) ). 41 | writer->set_option( option = if_sxml_writer=>co_opt_linebreaks ). 42 | writer->set_option( option = if_sxml_writer=>co_opt_indent ). 43 | reader->next_node( ). 44 | reader->skip_node( writer ). 45 | DATA(json_output) = cl_abap_conv_codepage=>create_in( )->convert( CAST cl_sxml_string_writer( writer )->get_output( ) ). 46 | CATCH cx_sxml_parse_error into data(error). 47 | out->write( error->get_text( ) ). 48 | RETURN. 49 | ENDTRY. 50 | out->write( json_output ). 51 | ENDMETHOD. 52 | ENDCLASS. 53 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_5a_tester.clas.abap: -------------------------------------------------------------------------------- 1 | "!

OO Tutorial #5A - Tester with iTab of references

2 | CLASS ZCL_OO_TUTORIAL_5A_TESTER DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | INTERFACES IF_OO_ADT_CLASSRUN. 9 | PROTECTED SECTION. 10 | PRIVATE SECTION. 11 | ENDCLASS. 12 | 13 | 14 | 15 | CLASS ZCL_OO_TUTORIAL_5A_TESTER IMPLEMENTATION. 16 | 17 | 18 | METHOD IF_OO_ADT_CLASSRUN~MAIN. 19 | 20 | TYPES: BEGIN OF T_FLIGHT_REF, 21 | CARRIER_ID TYPE /DMO/CARRIER_ID, 22 | CONNECTION_ID TYPE /DMO/CONNECTION_ID, 23 | FLIGHT_DATE TYPE /DMO/FLIGHT_DATE, 24 | FLIGHT_OBJECT TYPE REF TO ZCL_OO_TUTORIAL_5, 25 | END OF T_FLIGHT_REF. 26 | DATA FLIGHTS TYPE STANDARD TABLE OF T_FLIGHT_REF WITH EMPTY KEY. 27 | TRY. 28 | SELECT CARRIER_ID, CONNECTION_ID, FLIGHT_DATE 29 | FROM /DMO/FLIGHT 30 | INTO CORRESPONDING FIELDS OF TABLE @FLIGHTS. 31 | INSERT VALUE #( CARRIER_ID = `UA` CONNECTION_ID = `0058` FLIGHT_DATE = `20220426` ) INTO TABLE FLIGHTS. 32 | 33 | LOOP AT FLIGHTS REFERENCE INTO DATA(FLIGHT). 34 | FLIGHT->FLIGHT_OBJECT = NEW ZCL_OO_TUTORIAL_5( 35 | CARRIER_ID = FLIGHT->CARRIER_ID 36 | CONNECTION_ID = FLIGHT->CONNECTION_ID 37 | FLIGHT_DATE = FLIGHT->FLIGHT_DATE ). 38 | DATA(FLIGHT_PRICE) = FLIGHT->FLIGHT_OBJECT->CALCULATE_FLIGHT_PRICE( ). 39 | OUT->WRITE( |Flight Price for { FLIGHT->CARRIER_ID }-{ FLIGHT->CONNECTION_ID } on { FLIGHT->FLIGHT_DATE DATE = ENVIRONMENT }: | && 40 | |{ FLIGHT_PRICE-PRICE CURRENCY = FLIGHT_PRICE-CURRENCY } { FLIGHT_PRICE-CURRENCY }| ). 41 | OUT->WRITE( FLIGHT->FLIGHT_OBJECT->GET_FLIGHT_DETAILS( ) ). 42 | OUT->WRITE( ` `). 43 | ENDLOOP. 44 | 45 | 46 | CATCH ZCX_OO_TUTORIAL INTO DATA(CX_FLIGHT). 47 | OUT->WRITE( CX_FLIGHT->GET_TEXT( ) ). 48 | ENDTRY. 49 | ENDMETHOD. 50 | ENDCLASS. 51 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_6_747.clas.abap: -------------------------------------------------------------------------------- 1 | "!

OO Tutorial #6 - Planetype 747

2 | CLASS ZCL_OO_TUTORIAL_6_747 DEFINITION 3 | PUBLIC 4 | INHERITING FROM ZCL_OO_TUTORIAL_6_BASE 5 | FINAL 6 | CREATE PROTECTED 7 | GLOBAL FRIENDS ZCL_OO_TUTORIAL_6_BASE. 8 | 9 | PUBLIC SECTION. 10 | 11 | TYPES: 12 | BEGIN OF MOVIE, 13 | MOVIE_TITLE TYPE string, 14 | RUNNING_TIME TYPE string, 15 | END OF MOVIE. 16 | TYPES: 17 | MOVIES_TABLE TYPE STANDARD TABLE OF MOVIE WITH EMPTY KEY. 18 | 19 | "!

CONSTRUCTOR

20 | METHODS CONSTRUCTOR 21 | IMPORTING 22 | !FLIGHT TYPE /DMO/FLIGHT. 23 | 24 | 25 | "!

Get a listing of in flight movies

26 | METHODS GET_INFLIGHT_MOVIES 27 | returning value(movies) type ZCL_OO_TUTORIAL_6_747=>MOVIES_TABLE. 28 | * EXPORTING !MOVIES TYPE ZCL_OO_TUTORIAL_6_747=>MOVIES_TABLE. 29 | 30 | METHODS ZIF_OO_TUTORIAL~CALCULATE_FLIGHT_PRICE 31 | REDEFINITION . 32 | PROTECTED SECTION. 33 | *"* protected components of class ZCL_OO_TUTORIAL_6_747 34 | *"* do not include other source files here!!! 35 | PRIVATE SECTION. 36 | *"* private components of class ZCL_OO_TUTORIAL_6_747 37 | *"* do not include other source files here!!! 38 | 39 | "!

List of Movies on the Flight

40 | DATA MOVIES TYPE MOVIES_TABLE. 41 | 42 | ENDCLASS. 43 | 44 | 45 | 46 | CLASS ZCL_OO_TUTORIAL_6_747 IMPLEMENTATION. 47 | 48 | 49 | METHOD CONSTRUCTOR. 50 | SUPER->CONSTRUCTOR( 51 | FLIGHT = FLIGHT ). 52 | 53 | INSERT VALUE #( MOVIE_TITLE = `Transformers: Revenge of the Fallen` RUNNING_TIME = `150 min` ) INTO TABLE me->movies. 54 | INSERT VALUE #( MOVIE_TITLE = `The Hangover` RUNNING_TIME = `100 min` ) INTO TABLE me->movies. 55 | 56 | ENDMETHOD. 57 | 58 | 59 | METHOD GET_INFLIGHT_MOVIES. 60 | MOVIES = ME->MOVIES. 61 | ENDMETHOD. 62 | 63 | 64 | METHOD ZIF_OO_TUTORIAL~CALCULATE_FLIGHT_PRICE. 65 | price = SUPER->CALCULATE_FLIGHT_PRICE( ). 66 | PRICE-PRICE = PRICE-PRICE + 35. 67 | 68 | ENDMETHOD. 69 | ENDCLASS. 70 | -------------------------------------------------------------------------------- /src/zcl_simple_example.clas.abap: -------------------------------------------------------------------------------- 1 | "!

Simple Example Class

2 | CLASS ZCL_SIMPLE_EXAMPLE DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | 9 | TYPES: 10 | BEGIN OF FLIGHT_NESTED, 11 | CARRIER_ID TYPE /DMO/CARRIER_ID, 12 | CONNECTION_ID TYPE /DMO/CONNECTION_ID, 13 | FLIGHT_DATE TYPE /DMO/FLIGHT_DATE, 14 | PRICE TYPE /DMO/FLIGHT_PRICE, 15 | CURRENCY_CODE TYPE /DMO/CURRENCY_CODE, 16 | PLANE_TYPE_ID TYPE /DMO/PLANE_TYPE_ID, 17 | BOOKING TYPE STANDARD TABLE OF /DMO/BOOKING WITH EMPTY KEY, 18 | END OF FLIGHT_NESTED. 19 | 20 | TYPES: 21 | BEGIN OF EXAMPLE_TYPE, 22 | C1 TYPE I, 23 | C2 TYPE C LENGTH 10, 24 | CARRIER_ID TYPE /DMO/CARRIER_ID, 25 | CONNECTION_ID TYPE /DMO/CONNECTION_ID, 26 | FLIGHT TYPE STANDARD TABLE OF FLIGHT_NESTED WITH EMPTY KEY, 27 | END OF EXAMPLE_TYPE. 28 | TYPES: 29 | EXAMPLE_TABLE_TYPE TYPE STANDARD TABLE OF EXAMPLE_TYPE WITH EMPTY KEY. 30 | 31 | METHODS CONSTRUCTOR 32 | IMPORTING 33 | !INPUT1 TYPE STRING 34 | !INPUT2 TYPE STRING . 35 | CLASS-METHODS METHOD1 36 | IMPORTING 37 | !TABLE TYPE EXAMPLE_TABLE_TYPE . 38 | CLASS-METHODS METHOD2 39 | IMPORTING 40 | !FLIGHT TYPE /DMO/FLIGHT. 41 | CLASS-METHODS METHOD3 42 | IMPORTING 43 | !FLIGHT TYPE REF TO /DMO/FLIGHT. 44 | CLASS-METHODS METHOD4 45 | IMPORTING 46 | !CONNECTION_ID TYPE /DMO/CONNECTION_ID 47 | RETURNING 48 | VALUE(CONNECTION_OUTPUT) TYPE /DMO/CONNECTION_ID. 49 | CLASS-METHODS GET_SIZE 50 | RETURNING 51 | VALUE(SIZE) TYPE I . 52 | CLASS-METHODS SIZE_OK 53 | IMPORTING 54 | !SIZE TYPE I 55 | RETURNING 56 | VALUE(OK) TYPE ABAP_BOOL . 57 | PROTECTED SECTION. 58 | PRIVATE SECTION. 59 | ENDCLASS. 60 | 61 | 62 | 63 | CLASS ZCL_SIMPLE_EXAMPLE IMPLEMENTATION. 64 | 65 | 66 | METHOD CONSTRUCTOR. 67 | ENDMETHOD. 68 | 69 | 70 | METHOD GET_SIZE. 71 | SIZE = 10. 72 | ENDMETHOD. 73 | 74 | 75 | METHOD METHOD1. 76 | ENDMETHOD. 77 | 78 | 79 | METHOD METHOD2. 80 | ENDMETHOD. 81 | 82 | 83 | METHOD METHOD3. 84 | ENDMETHOD. 85 | 86 | 87 | METHOD METHOD4. 88 | CONNECTION_OUTPUT = CONNECTION_ID. 89 | ENDMETHOD. 90 | 91 | 92 | METHOD SIZE_OK. 93 | OK = XSDBOOL( SIZE > 0 ). 94 | ENDMETHOD. 95 | ENDCLASS. 96 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_2_static_and_inst_tester.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_2_static_and_inst_tester DEFINITION 2 | PUBLIC 3 | FINAL 4 | CREATE PUBLIC . 5 | 6 | PUBLIC SECTION. 7 | INTERFACES if_oo_adt_classrun. 8 | PROTECTED SECTION. 9 | PRIVATE SECTION. 10 | ENDCLASS. 11 | 12 | 13 | 14 | CLASS zcl_2_static_and_inst_tester IMPLEMENTATION. 15 | METHOD if_oo_adt_classrun~main. 16 | 17 | 18 | **** Static 19 | zcl_2_static=>calculate_flight_price( 20 | EXPORTING 21 | carrier_id = `AA` 22 | connection_id = `0017` 23 | flight_date = `20230222` 24 | IMPORTING 25 | price = DATA(price) 26 | currency_code = DATA(currency_code) ). 27 | out->write( |Flight Price for AA-0017 on { CONV /dmo/flight_date( `20230222` ) DATE = ENVIRONMENT }: | && 28 | |{ price CURRENCY = currency_code } { currency_code }| ). 29 | 30 | zcl_2_static=>calculate_flight_price( 31 | EXPORTING 32 | carrier_id = `UA` 33 | connection_id = `0058` 34 | flight_date = `20220426` 35 | IMPORTING 36 | price = DATA(price_bad) 37 | currency_code = DATA(currency_code_bad) ). 38 | out->write( |Flight Price for UA-0058 on { CONV /dmo/flight_date( `20220426` ) DATE = ENVIRONMENT }: | && 39 | |{ price_bad CURRENCY = currency_code_bad } { currency_code_bad }| ). 40 | 41 | out->write( zcl_2_static=>get_flight_details( 42 | carrier_id = `AA` 43 | connection_id = `0017` 44 | flight_date = `20230222` ) ). 45 | 46 | out->write( zcl_2_static=>get_flight_details( 47 | carrier_id = `UA` 48 | connection_id = `0058` 49 | flight_date = `20220426` ) ). 50 | 51 | **** Instance 52 | DATA(aa_0017) = NEW zcl_oo_tutorial_3( 53 | carrier_id = `AA` 54 | connection_id = `0017` 55 | flight_date = `20230222` ). 56 | 57 | aa_0017->flight-price = `0.01`. 58 | aa_0017->calculate_flight_price( 59 | IMPORTING 60 | price = price 61 | currency_code = currency_code ). 62 | 63 | out->write( |\nFlight Price for AA-0017 on { CONV /dmo/flight_date( `20230222` ) DATE = ENVIRONMENT }: | && 64 | |{ price CURRENCY = currency_code } { currency_code }| ). 65 | out->write( aa_0017->get_flight_details( ) ). 66 | 67 | out->write( ` ` ). 68 | DATA(ua_0017) = NEW zcl_oo_tutorial_3( 69 | carrier_id = `UA` 70 | connection_id = `0058` 71 | flight_date = `20200426` ). 72 | 73 | ua_0017->calculate_flight_price( 74 | IMPORTING 75 | price = price_bad 76 | currency_code = currency_code_bad ). 77 | 78 | out->write( |\nFlight Price for UA-0058 on { CONV /dmo/flight_date( `20200426` ) DATE = ENVIRONMENT }: | && 79 | |{ price_bad CURRENCY = currency_code_bad } { currency_code_bad }| ). 80 | out->write( ua_0017->get_flight_details( ) ). 81 | ENDMETHOD. 82 | ENDCLASS. 83 | -------------------------------------------------------------------------------- /src/zcl_obj_xml_test.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_obj_xml_test DEFINITION 2 | PUBLIC 3 | CREATE PUBLIC . 4 | 5 | PUBLIC SECTION. 6 | 7 | INTERFACES if_http_service_extension . 8 | PROTECTED SECTION. 9 | PRIVATE SECTION. 10 | ENDCLASS. 11 | 12 | 13 | 14 | CLASS ZCL_OBJ_XML_TEST IMPLEMENTATION. 15 | 16 | 17 | METHOD if_http_service_extension~handle_request. 18 | CASE request->get_method( ). 19 | WHEN CONV string( if_web_http_client=>get ). 20 | TRY. 21 | DATA(key) = request->get_form_field( 'key' ). 22 | IF key IS INITIAL. 23 | response->set_status( i_code = if_web_http_status=>bad_request i_reason = `Key Not Supplied` ). 24 | response->set_text( `Key Not Supplied` ). 25 | RETURN. 26 | ENDIF. 27 | SELECT SINGLE * FROM zobject_xml 28 | WHERE id = @( CONV #( key ) ) INTO @DATA(object_xml). 29 | if sy-subrc ne 0. 30 | response->set_status( i_code = if_web_http_status=>bad_request i_reason = `Invalid Key` ). 31 | response->set_text( `Invalid Key` ). 32 | RETURN. 33 | endif. 34 | 35 | DATA context2 TYPE REF TO zcl_oo_tutorial_5. 36 | 37 | CALL TRANSFORMATION id SOURCE XML object_xml-content 38 | RESULT flight = context2. 39 | DATA(json_writer) = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ). 40 | CALL TRANSFORMATION id SOURCE flight = context2 41 | RESULT XML json_writer. "DATA(json_out). 42 | * response->set_header_field( i_name = 'Content-Type' i_value = 'application/xml' ). 43 | * response->set_binary( object_xml-content ). 44 | 45 | TRY. 46 | DATA(reader) = cl_sxml_string_reader=>create( json_writer->get_output( ) ). 47 | DATA(writer) = CAST if_sxml_writer( 48 | cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ) ). 49 | writer->set_option( option = if_sxml_writer=>co_opt_linebreaks ). 50 | writer->set_option( option = if_sxml_writer=>co_opt_indent ). 51 | reader->next_node( ). 52 | reader->skip_node( writer ). 53 | DATA(json_output) = cl_abap_conv_codepage=>create_in( )->convert( CAST cl_sxml_string_writer( writer )->get_output( ) ). 54 | response->set_header_field( i_name = 'Content-Type' i_value = 'application/json' ). 55 | response->set_text( json_output ). 56 | CATCH cx_sxml_parse_error INTO DATA(error). 57 | response->set_status( i_code = if_web_http_status=>bad_request i_reason = error->get_text( ) ). 58 | response->set_text( error->get_text( ) ). 59 | RETURN. 60 | ENDTRY. 61 | CATCH cx_web_message_error INTO DATA(web_error). 62 | response->set_status( i_code = if_web_http_status=>bad_request i_reason = web_error->get_text( ) ). 63 | response->set_text( web_error->get_text( ) ). 64 | ENDTRY. 65 | ENDCASE. 66 | 67 | ENDMETHOD. 68 | ENDCLASS. 69 | -------------------------------------------------------------------------------- /src/zabap_oo_patterns/zcl_5_composite_base.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_5_composite_base DEFINITION 2 | PUBLIC 3 | ABSTRACT 4 | CREATE PROTECTED. 5 | 6 | PUBLIC SECTION. 7 | INTERFACES zif_5_composite. 8 | 9 | ALIASES calculate_flight_price 10 | FOR zif_5_composite~calculate_flight_price . 11 | ALIASES get_flight_details 12 | FOR zif_5_composite~get_flight_details . 13 | ALIASES cost 14 | FOR zif_5_composite~cost . 15 | 16 | CONSTANTS: 17 | "!

Plane Type Enumerator

18 | BEGIN OF plane_type, 19 | b747 TYPE /dmo/plane_type_id VALUE `747`, 20 | a340 TYPE /dmo/plane_type_id VALUE `A340`, 21 | END OF plane_type . 22 | 23 | "!

CONSTRUCTOR

24 | METHODS constructor 25 | IMPORTING 26 | !flight TYPE /dmo/flight . 27 | 28 | "!

Get Filght Object

29 | CLASS-METHODS factory 30 | IMPORTING 31 | !carrier_id TYPE /dmo/carrier_id 32 | !connection_id TYPE /dmo/connection_id 33 | !flight_date TYPE /dmo/flight_date 34 | RETURNING 35 | VALUE(flight) TYPE REF TO zcl_5_composite_base 36 | RAISING 37 | zcx_5_composite. 38 | PROTECTED SECTION. 39 | "!

Flight

40 | DATA flight TYPE /dmo/flight . 41 | 42 | PRIVATE SECTION. 43 | "!

Base Class Name

44 | CONSTANTS class_base_name TYPE string VALUE `ZCL_5_COMPOSITE_`. "#EC NOTEXT 45 | "!

Class Name Other

46 | CONSTANTS class_other TYPE string VALUE `OTHER`. "#EC NOTEXT 47 | ENDCLASS. 48 | 49 | 50 | 51 | CLASS zcl_5_composite_base IMPLEMENTATION. 52 | METHOD constructor. 53 | me->flight = flight. 54 | ENDMETHOD. 55 | 56 | METHOD factory. 57 | 58 | SELECT SINGLE * FROM /dmo/flight 59 | WHERE carrier_id = @carrier_id 60 | AND connection_id = @connection_id 61 | AND flight_date = @flight_date 62 | INTO @DATA(flight_temp). 63 | IF sy-subrc NE 0. 64 | RAISE EXCEPTION NEW zcx_5_composite( textid = zcx_5_composite=>flight_not_found 65 | carrid = carrier_id ). 66 | ENDIF. 67 | 68 | DATA class_name TYPE string. 69 | IF flight_temp-plane_type_id CS ZCL_5_COMPOSITE_BASE=>plane_type-b747. 70 | class_name = ZCL_5_COMPOSITE_BASE=>class_base_name && 71 | ZCL_5_COMPOSITE_BASE=>plane_type-b747. 72 | 73 | ELSEIF flight_temp-plane_type_id CS ZCL_5_COMPOSITE_BASE=>plane_type-a340. 74 | class_name = ZCL_5_COMPOSITE_BASE=>class_base_name && 75 | ZCL_5_COMPOSITE_BASE=>plane_type-a340. 76 | ELSE. 77 | class_name = ZCL_5_COMPOSITE_BASE=>class_base_name && 78 | ZCL_5_COMPOSITE_BASE=>class_other. 79 | ENDIF. 80 | 81 | CREATE OBJECT flight TYPE (class_name) 82 | EXPORTING 83 | flight = flight_temp. 84 | 85 | ENDMETHOD. 86 | 87 | 88 | METHOD zif_5_composite~calculate_flight_price. 89 | 90 | price-price = me->flight-price + 100. 91 | price-currency = me->flight-currency_code. 92 | 93 | ENDMETHOD. 94 | 95 | 96 | METHOD zif_5_composite~get_flight_details. 97 | flight = me->flight. 98 | ENDMETHOD. 99 | 100 | ENDCLASS. 101 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_5.clas.abap: -------------------------------------------------------------------------------- 1 | CLASS zcl_oo_tutorial_5 DEFINITION 2 | PUBLIC 3 | FINAL 4 | CREATE PUBLIC . 5 | 6 | PUBLIC SECTION. 7 | INTERFACES if_serializable_object. 8 | 9 | TYPES: 10 | BEGIN OF cost, 11 | price TYPE /dmo/flight_price, 12 | currency TYPE /dmo/currency_code, 13 | END OF cost . 14 | DATA nested TYPE zcl_simple_example=>example_table_type. 15 | "!

CONSTRUCTOR

16 | METHODS constructor 17 | IMPORTING 18 | !carrier_id TYPE /dmo/carrier_id 19 | !connection_id TYPE /dmo/connection_id 20 | !flight_date TYPE /dmo/flight_date 21 | RAISING zcx_oo_tutorial. 22 | 23 | "!

Get Booking Details

24 | METHODS get_flight_details 25 | RETURNING VALUE(flight) TYPE /dmo/flight. 26 | 27 | "!

Calculate Flight Price

28 | METHODS calculate_flight_price 29 | RETURNING 30 | VALUE(price) TYPE cost. 31 | 32 | "!

Flight

33 | 34 | DATA test TYPE c LENGTH 10 VALUE 'HI'. 35 | DATA test_string_table TYPE string_table. 36 | PROTECTED SECTION. 37 | PRIVATE SECTION. 38 | DATA flight TYPE /dmo/flight. 39 | DATA obj3 TYPE REF TO zcl_oo_tutorial_3. 40 | "DATA nested TYPE zcl_simple_example=>example_table_type. 41 | 42 | ENDCLASS. 43 | 44 | 45 | 46 | CLASS ZCL_OO_TUTORIAL_5 IMPLEMENTATION. 47 | 48 | 49 | METHOD calculate_flight_price. 50 | 51 | price-price = me->flight-price. 52 | price-currency = me->flight-currency_code. 53 | 54 | CASE me->flight-plane_type_id. 55 | WHEN '747-400'. 56 | price-price = price-price + 40. 57 | WHEN `A321-200`. 58 | price-price = price-price + 25. 59 | WHEN OTHERS. 60 | price-price = price-price + 10. 61 | ENDCASE. 62 | ENDMETHOD. 63 | 64 | 65 | METHOD constructor. 66 | 67 | SELECT * FROM /dmo/connection WHERE carrier_id = 'AA' INTO CORRESPONDING FIELDS OF TABLE @nested. 68 | LOOP AT nested REFERENCE INTO DATA(connection). 69 | SELECT * FROM /dmo/flight 70 | WHERE carrier_id = @connection->carrier_id AND connection_id = @connection->connection_id 71 | INTO CORRESPONDING FIELDS OF TABLE @connection->flight. 72 | LOOP AT connection->flight REFERENCE INTO DATA(flightTemp). 73 | SELECT * FROM /dmo/booking 74 | WHERE carrier_id = @connection->carrier_id AND connection_id = @connection->connection_id AND flight_date = @flightTemp->flight_date 75 | INTO CORRESPONDING FIELDS OF TABLE @flightTemp->booking. 76 | ENDLOOP. 77 | ENDLOOP. 78 | 79 | SELECT SINGLE * FROM /dmo/flight 80 | WHERE carrier_id = @carrier_id 81 | AND connection_id = @connection_id 82 | AND flight_date = @flight_date 83 | INTO @flight. 84 | IF sy-subrc NE 0. 85 | RAISE EXCEPTION NEW zcx_oo_tutorial( 86 | textid = zcx_oo_tutorial=>flight_not_found 87 | carrid = carrier_id ). 88 | ELSE. 89 | me->obj3 = NEW zcl_oo_tutorial_3( 90 | carrier_id = flight-carrier_id 91 | connection_id = flight-connection_id 92 | flight_date = flight-flight_date ). 93 | ENDIF. 94 | ENDMETHOD. 95 | 96 | 97 | METHOD get_flight_details. 98 | flight = me->flight. 99 | ENDMETHOD. 100 | ENDCLASS. 101 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_2.clas.abap: -------------------------------------------------------------------------------- 1 | "!

Flight Data as Static Methods

2 | CLASS ZCL_OO_TUTORIAL_2 DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | INTERFACES IF_OO_ADT_CLASSRUN. 9 | 10 | "!

Get Booking Details

11 | CLASS-METHODS GET_FLIGHT_DETAILS 12 | IMPORTING 13 | !CARRIER_ID TYPE /DMO/CARRIER_ID 14 | !CONNECTION_ID TYPE /DMO/CONNECTION_ID 15 | !FLIGHT_DATE TYPE /DMO/FLIGHT_DATE 16 | RETURNING VALUE(FLIGHT) TYPE /DMO/FLIGHT. 17 | 18 | 19 | "!

Calculate Flight Price

20 | CLASS-METHODS CALCULATE_FLIGHT_PRICE 21 | IMPORTING 22 | !CARRIER_ID TYPE /DMO/CARRIER_ID 23 | !CONNECTION_ID TYPE /DMO/CONNECTION_ID 24 | !FLIGHT_DATE TYPE /DMO/FLIGHT_DATE 25 | EXPORTING 26 | !PRICE TYPE /DMO/FLIGHT_PRICE 27 | !CURRENCY_CODE TYPE /DMO/CURRENCY_CODE. 28 | 29 | PROTECTED SECTION. 30 | PRIVATE SECTION. 31 | ENDCLASS. 32 | 33 | 34 | 35 | CLASS ZCL_OO_TUTORIAL_2 IMPLEMENTATION. 36 | 37 | 38 | METHOD CALCULATE_FLIGHT_PRICE. 39 | DATA PLANE_TYPE TYPE /DMO/PLANE_TYPE_ID. 40 | 41 | SELECT SINGLE PRICE, CURRENCY_CODE, PLANE_TYPE_ID FROM /DMO/FLIGHT 42 | WHERE CARRIER_ID = @CARRIER_ID 43 | AND CONNECTION_ID = @CONNECTION_ID 44 | AND FLIGHT_DATE = @FLIGHT_DATE 45 | INTO (@PRICE, @CURRENCY_CODE, @PLANE_TYPE). 46 | 47 | CASE PLANE_TYPE. 48 | WHEN `747-400`. 49 | PRICE = PRICE + 40. 50 | WHEN `A321-200`. 51 | PRICE = PRICE + 25. 52 | WHEN OTHERS. 53 | PRICE = PRICE + 10. 54 | ENDCASE. 55 | ENDMETHOD. 56 | 57 | 58 | METHOD GET_FLIGHT_DETAILS. 59 | 60 | SELECT SINGLE * FROM /DMO/FLIGHT 61 | WHERE CARRIER_ID = @CARRIER_ID 62 | AND CONNECTION_ID = @CONNECTION_ID 63 | AND FLIGHT_DATE = @FLIGHT_DATE 64 | INTO @FLIGHT. 65 | 66 | ENDMETHOD. 67 | 68 | 69 | METHOD IF_OO_ADT_CLASSRUN~MAIN. 70 | 71 | ME->CALCULATE_FLIGHT_PRICE( 72 | EXPORTING 73 | CARRIER_ID = `AA` 74 | CONNECTION_ID = `0017` 75 | FLIGHT_DATE = `20230222` 76 | IMPORTING 77 | PRICE = DATA(PRICE) 78 | CURRENCY_CODE = DATA(CURRENCY_CODE) ). 79 | OUT->WRITE( |Flight Price for AA-0017 on { CONV /DMO/FLIGHT_DATE( `20230222` ) DATE = ENVIRONMENT }: | && 80 | |{ PRICE CURRENCY = CURRENCY_CODE } { CURRENCY_CODE }| ). 81 | 82 | ME->CALCULATE_FLIGHT_PRICE( 83 | EXPORTING 84 | CARRIER_ID = `UA` 85 | CONNECTION_ID = `0058` 86 | FLIGHT_DATE = `20220426` 87 | IMPORTING 88 | PRICE = DATA(PRICE_BAD) 89 | CURRENCY_CODE = DATA(CURRENCY_CODE_BAD) ). 90 | OUT->WRITE( |Flight Price for UA-0058 on { CONV /DMO/FLIGHT_DATE( `20220426` ) DATE = ENVIRONMENT }: | && 91 | |{ PRICE_BAD CURRENCY = CURRENCY_CODE_BAD } { CURRENCY_CODE_BAD }| ). 92 | 93 | OUT->WRITE( ME->GET_FLIGHT_DETAILS( 94 | CARRIER_ID = `AA` 95 | CONNECTION_ID = `0017` 96 | FLIGHT_DATE = `20230222` ) ). 97 | 98 | OUT->WRITE( ME->GET_FLIGHT_DETAILS( 99 | CARRIER_ID = `UA` 100 | CONNECTION_ID = `0058` 101 | FLIGHT_DATE = `20220426` ) ). 102 | ENDMETHOD. 103 | ENDCLASS. 104 | -------------------------------------------------------------------------------- /src/zcl_oo_tutorial_6_base.clas.abap: -------------------------------------------------------------------------------- 1 | "!

Flight Data Basic Class

2 | CLASS ZCL_OO_TUTORIAL_6_BASE DEFINITION 3 | PUBLIC 4 | abstract 5 | CREATE PROTECTED. 6 | 7 | PUBLIC SECTION. 8 | INTERFACES ZIF_OO_TUTORIAL. 9 | 10 | 11 | ALIASES CALCULATE_FLIGHT_PRICE 12 | FOR ZIF_OO_TUTORIAL~CALCULATE_FLIGHT_PRICE . 13 | ALIASES GET_FLIGHT_DETAILS 14 | FOR ZIF_OO_TUTORIAL~GET_FLIGHT_DETAILS . 15 | ALIASES COST 16 | FOR ZIF_OO_TUTORIAL~COST . 17 | 18 | CONSTANTS: 19 | "!

Plane Type Enumerator

20 | BEGIN OF PLANE_TYPE, 21 | B747 TYPE /DMO/PLANE_TYPE_ID VALUE `747`, 22 | A340 TYPE /DMO/PLANE_TYPE_ID VALUE `A340`, 23 | END OF PLANE_TYPE . 24 | 25 | "!

CONSTRUCTOR

26 | METHODS CONSTRUCTOR 27 | IMPORTING 28 | !FLIGHT TYPE /DMO/FLIGHT . 29 | 30 | "!

Get Filght Object

31 | CLASS-METHODS GET_FLIGHT_OBJECT 32 | IMPORTING 33 | !CARRIER_ID TYPE /DMO/CARRIER_ID 34 | !CONNECTION_ID TYPE /DMO/CONNECTION_ID 35 | !FLIGHT_DATE TYPE /DMO/FLIGHT_DATE 36 | RETURNING 37 | VALUE(FLIGHT) TYPE REF TO ZCL_OO_TUTORIAL_6_BASE 38 | RAISING 39 | ZCX_OO_TUTORIAL. 40 | PROTECTED SECTION. 41 | *"* protected components of class ZCL_OO_TUTORIAL_6_BASE 42 | *"* do not include other source files here!!! 43 | 44 | "!

Flight

45 | DATA FLIGHT TYPE /DMO/FLIGHT . 46 | 47 | PRIVATE SECTION. 48 | "!

Base Class Name

49 | CONSTANTS CLASS_BASE_NAME TYPE STRING VALUE `ZCL_OO_TUTORIAL_6_`. "#EC NOTEXT 50 | "!

Class Name Other

51 | CONSTANTS CLASS_OTHER TYPE STRING VALUE `OTHER`. "#EC NOTEXT 52 | ENDCLASS. 53 | 54 | 55 | 56 | CLASS ZCL_OO_TUTORIAL_6_BASE IMPLEMENTATION. 57 | 58 | 59 | METHOD CONSTRUCTOR. 60 | ME->FLIGHT = FLIGHT. 61 | ENDMETHOD. 62 | 63 | 64 | METHOD GET_FLIGHT_OBJECT. 65 | 66 | SELECT SINGLE * FROM /DMO/FLIGHT 67 | WHERE CARRIER_ID = @CARRIER_ID 68 | AND CONNECTION_ID = @CONNECTION_ID 69 | AND FLIGHT_DATE = @FLIGHT_DATE 70 | INTO @DATA(FLIGHT_TEMP). 71 | IF SY-SUBRC NE 0. 72 | RAISE EXCEPTION NEW ZCX_OO_TUTORIAL( 73 | TEXTID = ZCX_OO_TUTORIAL=>FLIGHT_NOT_FOUND 74 | CARRID = CARRIER_ID ). 75 | ENDIF. 76 | 77 | DATA CLASS_NAME TYPE STRING. 78 | IF FLIGHT_TEMP-PLANE_TYPE_ID CS ZCL_OO_TUTORIAL_6_BASE=>PLANE_TYPE-B747. 79 | CLASS_NAME = ZCL_OO_TUTORIAL_6_BASE=>CLASS_BASE_NAME && 80 | ZCL_OO_TUTORIAL_6_BASE=>PLANE_TYPE-B747. 81 | 82 | ELSEIF FLIGHT_TEMP-PLANE_TYPE_ID CS ZCL_OO_TUTORIAL_6_BASE=>PLANE_TYPE-A340. 83 | CLASS_NAME = ZCL_OO_TUTORIAL_6_BASE=>CLASS_BASE_NAME && 84 | ZCL_OO_TUTORIAL_6_BASE=>PLANE_TYPE-A340. 85 | ELSE. 86 | CLASS_NAME = ZCL_OO_TUTORIAL_6_BASE=>CLASS_BASE_NAME && 87 | ZCL_OO_TUTORIAL_6_BASE=>CLASS_OTHER. 88 | ENDIF. 89 | 90 | CREATE OBJECT FLIGHT TYPE (CLASS_NAME) 91 | EXPORTING 92 | FLIGHT = FLIGHT_TEMP. 93 | 94 | ENDMETHOD. 95 | 96 | 97 | METHOD ZIF_OO_TUTORIAL~CALCULATE_FLIGHT_PRICE. 98 | 99 | PRICE-PRICE = ME->FLIGHT-PRICE + 100. 100 | PRICE-CURRENCY = ME->FLIGHT-CURRENCY_CODE. 101 | 102 | ENDMETHOD. 103 | 104 | 105 | METHOD ZIF_OO_TUTORIAL~GET_FLIGHT_DETAILS. 106 | FLIGHT = ME->FLIGHT. 107 | ENDMETHOD. 108 | ENDCLASS. 109 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ABAP Object Oriented Basics 2019 2 | 3 | [![REUSE status](https://api.reuse.software/badge/github.com/SAP-samples/abap-oo-basics)](https://api.reuse.software/info/github.com/SAP-samples/abap-oo-basics) 4 | 5 | ## Description 6 | 7 | This is an update to the 10 year old ABAP Object Oriented eLearning series. What started as an update to improve the video resolution also turned into modernizing the tooling and ABAP syntax used to teach the basic Object Oriented concepts. 8 | Here is the YouTube Playlist that goes along with this code sample: 9 | https://youtube.com/playlist?list=PL6RpkC85SLQB-vyEFpUj1xkrIhH4UiV4D 10 | 11 | ABAP OO Part 1 - Introduction 12 | 13 | [![Part 1](http://img.youtube.com/vi/GUh7QyCwxGk/0.jpg)](https://youtu.be/GUh7QyCwxGk "ABAP OO Part 1 - Introduction") 14 | 15 | ABAP OO Part 2 - Static vs. Instance 16 | 17 | [![Part 2](http://img.youtube.com/vi/SwqNRez4itg/0.jpg)](https://youtu.be/SwqNRez4itg "ABAP OO Part 2 - Static vs. Instance") 18 | 19 | ABAP OO Part 3 - Visibility 20 | 21 | [![Part 3](http://img.youtube.com/vi/A9IPfLJBV5w/0.jpg)](https://youtu.be/A9IPfLJBV5w "ABAP OO Part 3 - Visibility") 22 | 23 | ABAP OO Part 4 - Exceptions 24 | 25 | [![Part 4](http://img.youtube.com/vi/2p4SJpYv7uQ/0.jpg)](https://youtu.be/2p4SJpYv7uQ "ABAP OO Part 4 - Exceptions") 26 | 27 | ABAP OO Part 5 - Inheritance 28 | 29 | [![Part 5](http://img.youtube.com/vi/zlp0CHaeSfw/0.jpg)](https://youtu.be/zlp0CHaeSfw "ABAP OO Part 5 - Inheritance") 30 | 31 | ## Requirements 32 | 33 | Make sure to fulfill the following requirements: 34 | 35 | * You have access to an SAP BTP, ABAP Environment instance (see [here](https://blogs.sap.com/2018/09/04/sap-cloud-platform-abap-environment) for additional information). 36 | * You have downloaded and installed ABAP Development Tools (ADT). Make sure to use the most recent version as indicated on the [installation page](https://tools.hana.ondemand.com/#abap). 37 | * You have created an ABAP Cloud Project in ADT that allows you to access your SAP BTP, ABAP Environment instance (see [here](https://help.sap.com/viewer/5371047f1273405bb46725a417f95433/Cloud/en-US/99cc54393e4c4e77a5b7f05567d4d14c.html) for additional information). Your log-on language is English. 38 | * You have installed the [abapGit](https://github.com/abapGit/eclipse.abapgit.org) plug-in for ADT from the update site `http://eclipse.abapgit.org/updatesite/`. 39 | 40 | ## Download and Installation 41 | 42 | Use the abapGit plug-in to install the ABAP OO Examples by executing the following steps: 43 | 44 | 1. In your ABAP cloud project, create an ABAP package for the demo content to be downloaded (leave the suggested values unchanged when following the steps in the package creation wizard). 45 | 2. To add the abapGit Repositories view to the ABAP perspective, click `Window` > `Show View` > `Other...` from the menu bar and choose `abapGit Repositories`. 46 | 3. In the abapGit Repositories view, click the `+` icon to clone an abapGit repository. 47 | 4. Enter the following URL of this repository: `https://github.com/SAP-samples/abap-oo-basics` and choose Next. 48 | 5. Create a new transport request that you only use for this demo content installation (recommendation) and choose Finish to link the Git repository to your ABAP cloud project. The repository appears in the abapGit Repositories View with status Linked. 49 | 6. Right-click on the new ABAP repository and choose `pull` to start the cloning of the repository contents. Note that this procedure may take a few minutes. 50 | 7. Once the cloning has finished, the status is set to `Pulled Successfully`. Then refresh your project tree. 51 | 52 | As a result of the installation procedure above, the ABAP system creates an inactive version of all artifacts from the demo content 53 | 54 | To activate all development objects from this sample: 55 | 56 | 1. Click the mass-activation icon (Activate Inactive ABAP Development Objects) in the toolbar. 57 | 2. In the dialog that appears, select all development objects in the transport request (that you created for the demo content installation) and choose `Activate`. 58 | 59 | ## Known Issues 60 | 61 | In the ABAP Trial on SAP Business Technology Platform you sharing an ABAP instance with many other users. Only one user on this system may import this sample as all object names must be globally unique. If you receive an error that the objects already exists upon import, search the system for classes named ZCL_OO_TUTORIAL*. Someone has already imported the content in your trial system and you can simply start with that imported version. 62 | 63 | ## How to obtain support 64 | 65 | This project is provided "as-is": there is no guarantee that raised issues will be answered or addressed in future releases. 66 | 67 | ## License 68 | 69 | Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. 70 | This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the [LICENSE](LICENSES/Apache-2.0.txt) file. 71 | -------------------------------------------------------------------------------- /src/zcl_table_expressions.clas.abap: -------------------------------------------------------------------------------- 1 | "!

ABAP Table Expressions Examples

2 | CLASS ZCL_TABLE_EXPRESSIONS DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | INTERFACES IF_OO_ADT_CLASSRUN. 9 | PROTECTED SECTION. 10 | PRIVATE SECTION. 11 | ENDCLASS. 12 | 13 | 14 | 15 | CLASS ZCL_TABLE_EXPRESSIONS IMPLEMENTATION. 16 | 17 | 18 | METHOD IF_OO_ADT_CLASSRUN~MAIN. 19 | DATA FLIGHTS TYPE STANDARD TABLE OF /DMO/FLIGHT 20 | WITH NON-UNIQUE SORTED KEY PLTYPE COMPONENTS PLANE_TYPE_ID. 21 | SELECT * FROM /DMO/FLIGHT INTO TABLE @FLIGHTS. 22 | 23 | TRY. 24 | ****Old 25 | READ TABLE FLIGHTS INDEX 1 INTO DATA(WA). 26 | 27 | ****New 28 | DATA(WA1) = FLIGHTS[ 1 ]. 29 | 30 | ****Old 31 | READ TABLE FLIGHTS INDEX 1 32 | USING KEY PLTYPE INTO DATA(WA3). 33 | 34 | ****New 35 | DATA(WA4) = FLIGHTS[ KEY PLTYPE INDEX 1 ]. 36 | 37 | ****Old 38 | READ TABLE FLIGHTS WITH KEY 39 | CARRIER_ID = 'AA' CONNECTION_ID = '0322' INTO DATA(WA5). 40 | 41 | ****New 42 | DATA(WA6) = FLIGHTS[ CARRIER_ID = 'AA' CONNECTION_ID = '0322' ]. 43 | 44 | ****Old 45 | READ TABLE FLIGHTS WITH TABLE KEY PLTYPE 46 | COMPONENTS PLANE_TYPE_ID = '747-400' INTO DATA(WA7). 47 | 48 | ****New 49 | DATA(WA8) = FLIGHTS[ KEY PLTYPE PLANE_TYPE_ID = '747-400' ]. 50 | 51 | ****Old 52 | READ TABLE FLIGHTS INDEX 1 ASSIGNING FIELD-SYMBOL(). 53 | -PLANE_TYPE_ID = 'A310-300'. 54 | 55 | ****New 56 | FLIGHTS[ 1 ]-PLANE_TYPE_ID = 'A319'. 57 | 58 | ****Old 59 | READ TABLE FLIGHTS INDEX 1 INTO DATA(LINE2). 60 | IF SY-SUBRC <> 0. 61 | LINE2 = WA3. 62 | ENDIF. 63 | ZCL_SIMPLE_EXAMPLE=>METHOD2( LINE2 ). 64 | CATCH CX_SY_ITAB_LINE_NOT_FOUND. 65 | ENDTRY. 66 | 67 | ****New 68 | ZCL_SIMPLE_EXAMPLE=>METHOD2( VALUE #( FLIGHTS[ 1 ] DEFAULT WA3 ) ). 69 | 70 | ****Old 71 | READ TABLE FLIGHTS INDEX 1 REFERENCE INTO DATA(LINEREF1). 72 | ZCL_SIMPLE_EXAMPLE=>METHOD3( LINEREF1 ). 73 | 74 | ****New 75 | ZCL_SIMPLE_EXAMPLE=>METHOD3( REF #( FLIGHTS[ 1 ] ) ). 76 | 77 | ****Setup for nested internal table 78 | DATA NESTED TYPE ZCL_SIMPLE_EXAMPLE=>EXAMPLE_TABLE_TYPE. 79 | SELECT * FROM /DMO/CONNECTION WHERE CARRIER_ID = 'AA' INTO CORRESPONDING FIELDS OF TABLE @NESTED. 80 | LOOP AT NESTED REFERENCE INTO DATA(CONNECTION). 81 | SELECT * FROM /DMO/FLIGHT 82 | WHERE CARRIER_ID = @CONNECTION->CARRIER_ID AND CONNECTION_ID = @CONNECTION->CONNECTION_ID 83 | INTO CORRESPONDING FIELDS OF TABLE @CONNECTION->FLIGHT. 84 | LOOP AT CONNECTION->FLIGHT REFERENCE INTO DATA(FLIGHT). 85 | SELECT * FROM /DMO/BOOKING 86 | WHERE CARRIER_ID = @CONNECTION->CARRIER_ID AND CONNECTION_ID = @CONNECTION->CONNECTION_ID AND FLIGHT_DATE = @FLIGHT->FLIGHT_DATE 87 | INTO CORRESPONDING FIELDS OF TABLE @FLIGHT->BOOKING. 88 | ENDLOOP. 89 | ENDLOOP. 90 | 91 | ****Old 92 | READ TABLE NESTED INTO DATA(NEST1) INDEX 2. 93 | READ TABLE NEST1-FLIGHT INTO DATA(NEST2) INDEX 1. 94 | READ TABLE NEST2-BOOKING INTO DATA(NEST3) INDEX 2. 95 | OUT->WRITE( NEST3-CUSTOMER_ID ). 96 | 97 | 98 | ****New 99 | DATA(CUSTOMER2) = NESTED[ 2 ]-FLIGHT[ 1 ]-BOOKING[ 2 ]-CUSTOMER_ID. 100 | OUT->WRITE( CUSTOMER2 ). 101 | 102 | 103 | ****Old 104 | READ TABLE FLIGHTS WITH KEY 105 | CARRIER_ID = 'AA' CONNECTION_ID = '0322' TRANSPORTING NO FIELDS. 106 | DATA(INDEX1) = SY-TABIX. 107 | OUT->WRITE( INDEX1 ). 108 | 109 | ****New 110 | DATA(INDEX2) = LINE_INDEX( FLIGHTS[ CARRIER_ID = 'AA' CONNECTION_ID = '0322' ] ). 111 | OUT->WRITE( INDEX2 ). 112 | 113 | 114 | ****Old 115 | DATA HTML TYPE STRING. 116 | HTML = ``. 117 | LOOP AT FLIGHTS ASSIGNING FIELD-SYMBOL(). 118 | HTML = 119 | |{ HTML }|. 121 | ENDLOOP. 122 | HTML = HTML && `
{ -CARRIER_ID }| & 120 | |{ -CONNECTION_ID }
`. 123 | 124 | ****New 125 | DATA(HTML2) = REDUCE STRING( 126 | INIT H = `` 127 | FOR SFLIGHT2 IN FLIGHTS 128 | NEXT H = |{ H }| ) && `
{ SFLIGHT2-CARRIER_ID }| & 129 | |{ SFLIGHT2-CONNECTION_ID }
`. 130 | 131 | ****New 132 | SELECT * FROM /DMO/CONNECTION INTO TABLE @DATA(CONNECTIONS). 133 | LOOP AT CONNECTIONS REFERENCE INTO DATA(FLG) 134 | GROUP BY COND #( WHEN FLG->DISTANCE < 120 THEN 0 135 | WHEN FLG->DISTANCE > 600 THEN 99 136 | ELSE TRUNC( FLG->DISTANCE / '60' ) ) 137 | ASCENDING 138 | REFERENCE INTO DATA(FD). 139 | OUT->WRITE( |Distance: { COND #( WHEN FD->* = 0 THEN `less than 2` 140 | WHEN FD->* = 99 THEN `more than 10` 141 | ELSE FD->* ) } hours | ). 142 | LOOP AT GROUP FD REFERENCE INTO DATA(FLG2). 143 | OUT->WRITE( | { FLG2->AIRPORT_FROM_ID }-{ FLG2->AIRPORT_TO_ID }: { FLG2->DISTANCE }| ). 144 | ENDLOOP. 145 | ENDLOOP. 146 | 147 | ****Breakpoint helper 148 | IF SY-SUBRC = 0. 149 | ENDIF. 150 | ENDMETHOD. 151 | ENDCLASS. 152 | -------------------------------------------------------------------------------- /src/zcl_constructor_expression.clas.abap: -------------------------------------------------------------------------------- 1 | "!

ABAP Constructor Expression Examples

2 | CLASS ZCL_CONSTRUCTOR_EXPRESSION DEFINITION 3 | PUBLIC 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | INTERFACES IF_OO_ADT_CLASSRUN. 9 | PROTECTED SECTION. 10 | PRIVATE SECTION. 11 | 12 | TYPES: BEGIN OF STRUCT, 13 | C1 TYPE I, 14 | C2 TYPE C LENGTH 10, 15 | END OF STRUCT. 16 | TYPES T_TAB TYPE STANDARD TABLE OF STRUCT WITH EMPTY KEY. 17 | DATA OTHERTAB TYPE ZCL_SIMPLE_EXAMPLE=>EXAMPLE_TABLE_TYPE. 18 | 19 | constants: EXPORTING type string value 'E'. 20 | 21 | ENDCLASS. 22 | 23 | 24 | 25 | CLASS ZCL_CONSTRUCTOR_EXPRESSION IMPLEMENTATION. 26 | 27 | 28 | METHOD IF_OO_ADT_CLASSRUN~MAIN. 29 | 30 | ****Old Way 31 | DATA DREF TYPE REF TO DATA. 32 | FIELD-SYMBOLS TYPE STRUCT. 33 | CREATE DATA DREF TYPE STRUCT. 34 | ASSIGN DREF->* TO . 35 | -C1 = 10. 36 | -C2 = 'a'. 37 | 38 | 39 | ****New Way 40 | DATA DREF2 TYPE REF TO DATA. 41 | DREF2 = NEW STRUCT( C1 = 10 C2 = 'a' ). 42 | 43 | 44 | ****Old Way 45 | DATA OREF TYPE REF TO ZCL_SIMPLE_EXAMPLE. 46 | CREATE OBJECT OREF 47 | EXPORTING 48 | INPUT1 = 'a1' 49 | INPUT2 = 'a2'. 50 | 51 | 52 | ****New Way 53 | DATA(OREF2) = NEW ZCL_SIMPLE_EXAMPLE( 54 | INPUT1 = 'a1' 55 | INPUT2 = 'a2' ). 56 | 57 | ****Old Way 58 | DATA TAB TYPE ZCL_SIMPLE_EXAMPLE=>EXAMPLE_TABLE_TYPE. 59 | DATA LINE LIKE LINE OF TAB. 60 | LINE-C1 = 10. 61 | LINE-C2 = 'a'. 62 | APPEND LINE TO TAB. 63 | LINE-C2 = 'b'. 64 | APPEND LINE TO TAB. 65 | APPEND LINES OF OTHERTAB TO TAB. 66 | ZCL_SIMPLE_EXAMPLE=>METHOD1( TAB ). 67 | 68 | ****New Way 69 | DATA(TAB2) = VALUE ZCL_SIMPLE_EXAMPLE=>EXAMPLE_TABLE_TYPE( 70 | ( C1 = 10 C2 = 'a' ) 71 | ( C1 = 10 C2 = 'b' ) 72 | ( LINES OF OTHERTAB ) ). 73 | ZCL_SIMPLE_EXAMPLE=>METHOD1( TAB2 ). 74 | 75 | ****New Way - Extreme 76 | ZCL_SIMPLE_EXAMPLE=>METHOD1( VALUE #( 77 | C1 = 10 78 | ( C2 = 'a' ) 79 | ( C2 = 'b' ) 80 | ( LINES OF OTHERTAB ) ) ). 81 | 82 | 83 | ****Dynamic Parameter - Somewhat New Way 84 | DATA DATAREF TYPE REF TO ZCL_SIMPLE_EXAMPLE=>EXAMPLE_TABLE_TYPE. 85 | GET REFERENCE OF TAB INTO DATAREF. 86 | DATA(PTAB) = VALUE ABAP_PARMBIND_TAB( 87 | ( NAME = 'TABLE' 88 | KIND = EXPORTING 89 | VALUE = DATAREF ) ). 90 | CALL METHOD ('ZCL_SIMPLE_EXAMPLE')=>('METHOD1') PARAMETER-TABLE PTAB. 91 | 92 | ****Dynamic Parameter - Really New Way 93 | DATA(PTAB2) = VALUE ABAP_PARMBIND_TAB( 94 | ( NAME = 'TABLE' 95 | KIND = EXPORTING 96 | VALUE = REF #( TAB ) ) ). 97 | CALL METHOD ('ZCL_SIMPLE_EXAMPLE')=>('METHOD1') PARAMETER-TABLE PTAB2. 98 | 99 | 100 | ****Old Way 101 | DATA HELPER TYPE STRING. 102 | HELPER = CL_ABAP_CONTEXT_INFO=>GET_USER_FORMATTED_NAME( ). 103 | DATA(XSTR) = CL_ABAP_CONV_CODEPAGE=>CREATE_OUT( )->CONVERT( SOURCE = HELPER ). 104 | 105 | ****New Way 106 | DATA(XSTR2) = CL_ABAP_CONV_CODEPAGE=>CREATE_OUT( )->CONVERT( SOURCE = CONV #( CL_ABAP_CONTEXT_INFO=>GET_USER_FORMATTED_NAME( ) ) ). 107 | 108 | ****Old 109 | DATA(I) = 1 / 4. 110 | OUT->WRITE( I ). "output 0 111 | 112 | ****New 113 | DATA(DF) = CONV DECFLOAT34( 1 / 4 ). 114 | OUT->WRITE( DF ). "output .25 115 | 116 | 117 | *****Old 118 | * CHECK ` ` = abap_false. 119 | * 120 | *****New 121 | * CHECK CONV abap_bool( ` ` ) = abap_false. 122 | 123 | ****New 124 | DATA(SQSIZE) = CONV I( LET S = ZCL_SIMPLE_EXAMPLE=>GET_SIZE( ) 125 | IN S * S ). 126 | 127 | ****Old 128 | * DATA STRUCTDESCR TYPE REF TO CL_ABAP_STRUCTDESCR. 129 | * STRUCTDESCR ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME( 'T100' ). 130 | * DATA(COMPONENTS) = STRUCTDESCR->COMPONENTS. 131 | 132 | ****New 133 | * DATA(COMPONENTS2) = CAST CL_ABAP_STRUCTDESCR( 134 | * CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME( 'T100' ) )->COMPONENTS. 135 | 136 | ****Old 137 | TYPES NUMTEXT TYPE N LENGTH 255. 138 | DATA NUMBER TYPE NUMTEXT. 139 | TRY. 140 | * MOVE EXACT '4 Apples + 3 Oranges' TO number. "Not allowed in Steampunk 141 | CATCH CX_SY_CONVERSION_ERROR INTO DATA(EXC). 142 | OUT->WRITE( 'Caught Exact #1' ). 143 | ENDTRY. 144 | 145 | ****New 146 | TRY. 147 | DATA(NUMBER2) = EXACT NUMTEXT( '4 Apples + 3 Oranges' ). 148 | CATCH CX_SY_CONVERSION_ERROR INTO DATA(EXC2). 149 | OUT->WRITE( 'Caught Exact #2' ). 150 | ENDTRY. 151 | 152 | 153 | ***Old 154 | DATA TIME TYPE STRING. 155 | DATA(NOW) = CL_ABAP_CONTEXT_INFO=>GET_SYSTEM_TIME( ). " sy-timlo. 156 | IF NOW < '120000'. 157 | TIME = |{ NOW TIME = ISO } AM |. 158 | ELSEIF NOW > '120000'. 159 | TIME = |{ CONV T( NOW - 12 * 3600 ) TIME = ISO } PM|. 160 | ELSEIF NOW = '120000'. 161 | TIME = `High Noon`. 162 | ELSE. 163 | TIME = `Call The Doctor, the Tardis is broken`. 164 | ENDIF. 165 | OUT->WRITE( TIME ). 166 | 167 | ***New 168 | DATA(TIME2) = 169 | COND STRING( 170 | LET NOW2 = CL_ABAP_CONTEXT_INFO=>GET_SYSTEM_TIME( ) IN 171 | WHEN NOW2 < '120000' THEN 172 | |{ NOW2 TIME = ISO } AM | 173 | WHEN NOW2 > '120000' THEN 174 | |{ CONV T( NOW2 - 12 * 3600 ) TIME = ISO } PM| 175 | WHEN NOW2 = '120000' THEN 176 | `High Noon` 177 | ELSE 178 | `Call The Doctor, the Tardis is broken` ). 179 | OUT->WRITE( TIME2 ). 180 | 181 | ****Old 182 | DATA NUMBER3 TYPE STRING. 183 | CASE SY-INDEX. 184 | WHEN 1. 185 | NUMBER3 = 'one'. 186 | WHEN 2. 187 | NUMBER3 = 'two'. 188 | WHEN 3. 189 | NUMBER3 = 'three'. 190 | WHEN OTHERS. 191 | NUMBER3 = `Who cares?`. 192 | ENDCASE. 193 | OUT->WRITE( NUMBER3 ). 194 | 195 | ****New 196 | DATA(NUMBER4) = SWITCH STRING( SY-INDEX 197 | WHEN 1 THEN 'one' 198 | WHEN 2 THEN 'two' 199 | WHEN 3 THEN 'three' 200 | ELSE `Who cares?` ). 201 | OUT->WRITE( NUMBER4 ). 202 | 203 | DATA FLIGHTS TYPE STANDARD TABLE OF /DMO/FLIGHT. 204 | DATA FLIGHTS2 TYPE STANDARD TABLE OF /DMO/FLIGHT. 205 | DATA LINE2 LIKE LINE OF FLIGHTS2. 206 | SELECT * FROM /DMO/FLIGHT INTO TABLE @FLIGHTS. 207 | ****Old 208 | LOOP AT FLIGHTS ASSIGNING FIELD-SYMBOL(). 209 | MOVE-CORRESPONDING TO LINE2. 210 | LINE2-SEATS_MAX = -SEATS_MAX - 10. "Make more room in plane 211 | INSERT LINE2 INTO TABLE FLIGHTS2. 212 | ENDLOOP. 213 | 214 | CLEAR: FLIGHTS2, LINE2. 215 | ****New 216 | FLIGHTS2 = CORRESPONDING #( FLIGHTS 217 | MAPPING SEATS_MAX = SEATS_MAX "Entire flight is now business class 218 | EXCEPT SEATS_OCCUPIED ). "Empty the plane 219 | 220 | 221 | ****Breakpoint helper 222 | IF SY-SUBRC = 0. 223 | ENDIF. 224 | ENDMETHOD. 225 | ENDCLASS. 226 | -------------------------------------------------------------------------------- /LICENSES/Apache-2.0.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | 3 | Version 2.0, January 2004 4 | 5 | http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, 6 | AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | 11 | 12 | "License" shall mean the terms and conditions for use, reproduction, and distribution 13 | as defined by Sections 1 through 9 of this document. 14 | 15 | 16 | 17 | "Licensor" shall mean the copyright owner or entity authorized by the copyright 18 | owner that is granting the License. 19 | 20 | 21 | 22 | "Legal Entity" shall mean the union of the acting entity and all other entities 23 | that control, are controlled by, or are under common control with that entity. 24 | For the purposes of this definition, "control" means (i) the power, direct 25 | or indirect, to cause the direction or management of such entity, whether 26 | by contract or otherwise, or (ii) ownership of fifty percent (50%) or more 27 | of the outstanding shares, or (iii) beneficial ownership of such entity. 28 | 29 | 30 | 31 | "You" (or "Your") shall mean an individual or Legal Entity exercising permissions 32 | granted by this License. 33 | 34 | 35 | 36 | "Source" form shall mean the preferred form for making modifications, including 37 | but not limited to software source code, documentation source, and configuration 38 | files. 39 | 40 | 41 | 42 | "Object" form shall mean any form resulting from mechanical transformation 43 | or translation of a Source form, including but not limited to compiled object 44 | code, generated documentation, and conversions to other media types. 45 | 46 | 47 | 48 | "Work" shall mean the work of authorship, whether in Source or Object form, 49 | made available under the License, as indicated by a copyright notice that 50 | is included in or attached to the work (an example is provided in the Appendix 51 | below). 52 | 53 | 54 | 55 | "Derivative Works" shall mean any work, whether in Source or Object form, 56 | that is based on (or derived from) the Work and for which the editorial revisions, 57 | annotations, elaborations, or other modifications represent, as a whole, an 58 | original work of authorship. For the purposes of this License, Derivative 59 | Works shall not include works that remain separable from, or merely link (or 60 | bind by name) to the interfaces of, the Work and Derivative Works thereof. 61 | 62 | 63 | 64 | "Contribution" shall mean any work of authorship, including the original version 65 | of the Work and any modifications or additions to that Work or Derivative 66 | Works thereof, that is intentionally submitted to Licensor for inclusion in 67 | the Work by the copyright owner or by an individual or Legal Entity authorized 68 | to submit on behalf of the copyright owner. For the purposes of this definition, 69 | "submitted" means any form of electronic, verbal, or written communication 70 | sent to the Licensor or its representatives, including but not limited to 71 | communication on electronic mailing lists, source code control systems, and 72 | issue tracking systems that are managed by, or on behalf of, the Licensor 73 | for the purpose of discussing and improving the Work, but excluding communication 74 | that is conspicuously marked or otherwise designated in writing by the copyright 75 | owner as "Not a Contribution." 76 | 77 | 78 | 79 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf 80 | of whom a Contribution has been received by Licensor and subsequently incorporated 81 | within the Work. 82 | 83 | 2. Grant of Copyright License. Subject to the terms and conditions of this 84 | License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, 85 | no-charge, royalty-free, irrevocable copyright license to reproduce, prepare 86 | Derivative Works of, publicly display, publicly perform, sublicense, and distribute 87 | the Work and such Derivative Works in Source or Object form. 88 | 89 | 3. Grant of Patent License. Subject to the terms and conditions of this License, 90 | each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, 91 | no-charge, royalty-free, irrevocable (except as stated in this section) patent 92 | license to make, have made, use, offer to sell, sell, import, and otherwise 93 | transfer the Work, where such license applies only to those patent claims 94 | licensable by such Contributor that are necessarily infringed by their Contribution(s) 95 | alone or by combination of their Contribution(s) with the Work to which such 96 | Contribution(s) was submitted. If You institute patent litigation against 97 | any entity (including a cross-claim or counterclaim in a lawsuit) alleging 98 | that the Work or a Contribution incorporated within the Work constitutes direct 99 | or contributory patent infringement, then any patent licenses granted to You 100 | under this License for that Work shall terminate as of the date such litigation 101 | is filed. 102 | 103 | 4. Redistribution. You may reproduce and distribute copies of the Work or 104 | Derivative Works thereof in any medium, with or without modifications, and 105 | in Source or Object form, provided that You meet the following conditions: 106 | 107 | (a) You must give any other recipients of the Work or Derivative Works a copy 108 | of this License; and 109 | 110 | (b) You must cause any modified files to carry prominent notices stating that 111 | You changed the files; and 112 | 113 | (c) You must retain, in the Source form of any Derivative Works that You distribute, 114 | all copyright, patent, trademark, and attribution notices from the Source 115 | form of the Work, excluding those notices that do not pertain to any part 116 | of the Derivative Works; and 117 | 118 | (d) If the Work includes a "NOTICE" text file as part of its distribution, 119 | then any Derivative Works that You distribute must include a readable copy 120 | of the attribution notices contained within such NOTICE file, excluding those 121 | notices that do not pertain to any part of the Derivative Works, in at least 122 | one of the following places: within a NOTICE text file distributed as part 123 | of the Derivative Works; within the Source form or documentation, if provided 124 | along with the Derivative Works; or, within a display generated by the Derivative 125 | Works, if and wherever such third-party notices normally appear. The contents 126 | of the NOTICE file are for informational purposes only and do not modify the 127 | License. You may add Your own attribution notices within Derivative Works 128 | that You distribute, alongside or as an addendum to the NOTICE text from the 129 | Work, provided that such additional attribution notices cannot be construed 130 | as modifying the License. 131 | 132 | You may add Your own copyright statement to Your modifications and may provide 133 | additional or different license terms and conditions for use, reproduction, 134 | or distribution of Your modifications, or for any such Derivative Works as 135 | a whole, provided Your use, reproduction, and distribution of the Work otherwise 136 | complies with the conditions stated in this License. 137 | 138 | 5. Submission of Contributions. Unless You explicitly state otherwise, any 139 | Contribution intentionally submitted for inclusion in the Work by You to the 140 | Licensor shall be under the terms and conditions of this License, without 141 | any additional terms or conditions. Notwithstanding the above, nothing herein 142 | shall supersede or modify the terms of any separate license agreement you 143 | may have executed with Licensor regarding such Contributions. 144 | 145 | 6. Trademarks. This License does not grant permission to use the trade names, 146 | trademarks, service marks, or product names of the Licensor, except as required 147 | for reasonable and customary use in describing the origin of the Work and 148 | reproducing the content of the NOTICE file. 149 | 150 | 7. Disclaimer of Warranty. Unless required by applicable law or agreed to 151 | in writing, Licensor provides the Work (and each Contributor provides its 152 | Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 153 | KIND, either express or implied, including, without limitation, any warranties 154 | or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR 155 | A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness 156 | of using or redistributing the Work and assume any risks associated with Your 157 | exercise of permissions under this License. 158 | 159 | 8. Limitation of Liability. In no event and under no legal theory, whether 160 | in tort (including negligence), contract, or otherwise, unless required by 161 | applicable law (such as deliberate and grossly negligent acts) or agreed to 162 | in writing, shall any Contributor be liable to You for damages, including 163 | any direct, indirect, special, incidental, or consequential damages of any 164 | character arising as a result of this License or out of the use or inability 165 | to use the Work (including but not limited to damages for loss of goodwill, 166 | work stoppage, computer failure or malfunction, or any and all other commercial 167 | damages or losses), even if such Contributor has been advised of the possibility 168 | of such damages. 169 | 170 | 9. Accepting Warranty or Additional Liability. While redistributing the Work 171 | or Derivative Works thereof, You may choose to offer, and charge a fee for, 172 | acceptance of support, warranty, indemnity, or other liability obligations 173 | and/or rights consistent with this License. However, in accepting such obligations, 174 | You may act only on Your own behalf and on Your sole responsibility, not on 175 | behalf of any other Contributor, and only if You agree to indemnify, defend, 176 | and hold each Contributor harmless for any liability incurred by, or claims 177 | asserted against, such Contributor by reason of your accepting any such warranty 178 | or additional liability. END OF TERMS AND CONDITIONS 179 | 180 | APPENDIX: How to apply the Apache License to your work. 181 | 182 | To apply the Apache License to your work, attach the following boilerplate 183 | notice, with the fields enclosed by brackets "[]" replaced with your own identifying 184 | information. (Don't include the brackets!) The text should be enclosed in 185 | the appropriate comment syntax for the file format. We also recommend that 186 | a file or class name and description of purpose be included on the same "printed 187 | page" as the copyright notice for easier identification within third-party 188 | archives. 189 | 190 | Copyright [2024] [SAP SE] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | 194 | you may not use this file except in compliance with the License. 195 | 196 | You may obtain a copy of the License at 197 | 198 | http://www.apache.org/licenses/LICENSE-2.0 199 | 200 | Unless required by applicable law or agreed to in writing, software 201 | 202 | distributed under the License is distributed on an "AS IS" BASIS, 203 | 204 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 205 | 206 | See the License for the specific language governing permissions and 207 | 208 | limitations under the License. 209 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 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, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [2024] [SAP SE] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------