From 3c1ec86a5b2c3cf8a86122df2d8951c795e1d5a1 Mon Sep 17 00:00:00 2001 From: danrega <16720986+danrega@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:14:33 +0100 Subject: [PATCH] Update --- 04_ABAP_Object_Orientation.md | 82 +++++++++++++- 07_String_Processing.md | 4 +- 08_EML_ABAP_for_RAP.md | 207 ++++++++++++++++++++++++++++++++-- 22_Released_ABAP_Classes.md | 159 +++++++++++--------------- 4 files changed, 347 insertions(+), 105 deletions(-) diff --git a/04_ABAP_Object_Orientation.md b/04_ABAP_Object_Orientation.md index a99d2a5..9d9d8fc 100644 --- a/04_ABAP_Object_Orientation.md +++ b/04_ABAP_Object_Orientation.md @@ -561,7 +561,7 @@ In the simplest form, methods can have no parameter at all. Apart from that, met - If passing by reference is used, a local data object is not created for the actual parameter. Instead, the procedure is given a [reference](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenreference_glosry.htm "Glossary Entry") to the actual parameter during the call and works with the actual parameter itself. - Note that parameters that are input and passed by reference cannot be modified in the procedure. However, the use of a reference is beneficial regarding the performance compared to creating a local data object. -The following example shows a class with a simple method demonstrating the syntax for formal parameter specifications. Complete types are used. +The following example (which anticipates aspects described in the following sections, such as calling methods) shows a class with a simple method demonstrating the syntax for formal parameter specifications. Complete types are used. ```abap CLASS zcl_some_class DEFINITION @@ -725,7 +725,7 @@ ENDCLASS. #### Generic Typing of Formal Parameters -Find more information on generic types in the [Data Types and Data Objects](16_Data_Types_and_Objects.md#generic-types) cheat sheet. +Find more information on generic types in the [Data Types and Data Objects](16_Data_Types_and_Objects.md#generic-types) cheat sheet. The following code snippet anticipates aspects described in the following sections, such as calling methods. ```abap CLASS zcl_some_class DEFINITION @@ -964,7 +964,7 @@ ENDCLASS. - The preferred parameter is implicitly optional, but you should explicitly specify it as `OPTIONAL` or `DEFAULT`, or a warning will be displayed. - When you call a method and specify a single actual parameter without specifying the name of the formal parameter in an assignment, the actual parameter is automatically assigned to the preferred parameter. -The following example shows a simple method with input parameters of type `i` (an addition is performed using the actual parameter values), where one parameter is preferred. The `IS SUPPLIED` addition in `COND` statements checks whether parameters are supplied. The final output shows the preferred parameter assigned automatically when the formal parameter is not specified explicitly. +The following example (which anticipates aspects described in the following sections, such as calling methods) shows a simple method with input parameters of type `i` (an addition is performed using the actual parameter values), where one parameter is preferred. The `IS SUPPLIED` addition in `COND` statements checks whether parameters are supplied. The final output shows the preferred parameter assigned automatically when the formal parameter is not specified explicitly. To try the example out, create a demo class named `zcl_some_class` and paste the code into it. After activation, choose *F9* in ADT to execute the class. The example is set up to display output in the console. The example should display the following: ``` @@ -1066,6 +1066,82 @@ ENDCLASS. instantiated and an instance is created. - Can have `IMPORTING` parameters and raise exceptions. +The following example (which anticipates aspects described in the following sections, such as creating instances of classes) demonstrates static and instance constructors. To try the example out, create a demo class named `zcl_some_class` and paste the code into it. After activation, choose *F9* in ADT to execute the class. The example is set up to display output in the console. + +Notes: +- The example class defines the instance and static constructors. +- The instance constructor includes an optional importing parameter, which static constructors do not allow. If the parameter were not optional, the class would not run with F9, as it could not pass an actual parameter. In the example, the actual parameter indicates the name of the instance created for output purposes. +- The example class creates multiple instances. +- Both instance and static attributes of each instance are accessed and added to an internal table, which is then output. +- The constructor implementations include: + - Instance constructor: + - Stores the current timestamp in an instance attribute. + - Maintains a call counter for the number of times the instance constructor is called, stored in a static attribute to reflect the count per internal session. + - Stores the manually provided instance name in an instance attribute. + - Static constructor: + - Stores the current timestamp in a static attribute. + - Maintains a call counter for static constructor calls, stored in a static attribute. +- The constructors demonstrate: + - The static constructor is called only once, even when multiple class instances are created, leading to a constant `static_timestamp` value and `stat_constr_call_count` value, which remains 1. + - The `instance_timestamp` attribute shows different timestamps for each created instance. + - The static attribute `instance_constr_call_count` increases with each instance. Note that running the class with F9 in ADT also calls the instance and static constructors. Thus, the final `instance_constr_call_count` totals the number of `DO` loop passes plus 1, starting with 2 for `inst1` instead of 1. + + +```abap +CLASS zcl_some_class DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + INTERFACES if_oo_adt_classrun. + METHODS constructor IMPORTING text TYPE string OPTIONAL. + CLASS-METHODS class_constructor. + PROTECTED SECTION. + PRIVATE SECTION. + DATA instance_timestamp TYPE utclong. + CLASS-DATA static_timestamp TYPE utclong. + DATA instance_name TYPE string. + CLASS-DATA stat_constr_call_count TYPE i. + CLASS-DATA instance_constr_call_count TYPE i. +ENDCLASS. + +CLASS zcl_some_class IMPLEMENTATION. + METHOD if_oo_adt_classrun~main. + + DATA itab TYPE string_table. + + DO 5 TIMES. + DATA(inst) = NEW zcl_some_class( |inst{ sy-index }| ). + APPEND |-------------- Instance "{ inst->instance_name }" --------------| TO itab. + APPEND |instance_timestamp: { inst->instance_timestamp }| TO itab. + APPEND |static_timestamp: { inst->static_timestamp }| TO itab. + APPEND |instance_constr_call_count: { inst->instance_constr_call_count }| TO itab. + APPEND |stat_constr_call_count: { inst->stat_constr_call_count }| TO itab. + APPEND INITIAL LINE TO itab. + ENDDO. + + out->write( itab ). + ENDMETHOD. + + METHOD class_constructor. + static_timestamp = utclong_current( ). + stat_constr_call_count += 1. + ENDMETHOD. + + METHOD constructor. + instance_timestamp = utclong_current( ). + instance_constr_call_count += 1. + + IF text IS SUPPLIED AND text IS NOT INITIAL. + instance_name = text. + ENDIF. + ENDMETHOD. + +ENDCLASS. +``` + +

⬆️ back to top

#### Example for Method Definitions diff --git a/07_String_Processing.md b/07_String_Processing.md index bd37747..536b718 100644 --- a/07_String_Processing.md +++ b/07_String_Processing.md @@ -2415,7 +2415,7 @@ SPLIT xstr AT blank_xstr INTO TABLE DATA(xstr_tab) IN BYTE MODE. #### SET BIT and GET BIT Statements - Unlike the ABAP statements in the previous section, the following statements are are only for byte string processing: - - [`SET BIT`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/ABAPSET_BIT.html) and . + - [`SET BIT`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/ABAPSET_BIT.html) - Syntax pattern: `SET BIT pos OF byte_string [TO value].` - In a byte-like data object, the bit is set to 1 by default at a specified position, or to 0 or 1 as specified after `TO`. - Alternatively, you can use the built-in function [`bit-set`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/ABENBIT_FUNCTIONS.html). @@ -2424,7 +2424,7 @@ SPLIT xstr AT blank_xstr INTO TABLE DATA(xstr_tab) IN BYTE MODE. - Reads a bit at a specified position in a byte string into a target data object. -Expand the following collapsible section for example code, which experiments with byte string processing (converting a hexadecimal value to the character-like representation of the binary values by reading bits, getting hexadecimal values from from the character-like representation of the binary values, setting bits). To try it out, create a demo class named `zcl_some_class` and paste the code into it. After activation, choose *F9* in ADT to execute the class. The example is set up to display output in the console. +Expand the following collapsible section for example code, which experiments with byte string processing (converting a hexadecimal value to the character-like representation of the binary values by reading bits, getting hexadecimal values from the character-like representation of the binary values, setting bits). To try it out, create a demo class named `zcl_some_class` and paste the code into it. After activation, choose *F9* in ADT to execute the class. The example is set up to display output in the console.
🟢 Click to expand for example code diff --git a/08_EML_ABAP_for_RAP.md b/08_EML_ABAP_for_RAP.md index 3865da8..d1f3c01 100644 --- a/08_EML_ABAP_for_RAP.md +++ b/08_EML_ABAP_for_RAP.md @@ -42,7 +42,7 @@ The following points cover RAP-related terms such as *RAP business objects* and of [CDS entities](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencds_entity_glosry.htm "Glossary Entry") of a data model - - Such a structure of entities consists of [parent + - Such a structure of entities can consist of [parent entities](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenparent_entity_glosry.htm "Glossary Entry") and [child entities](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenchild_entity_glosry.htm "Glossary Entry") @@ -614,7 +614,7 @@ METHODS some_action FOR MODIFY - The saver class is implicitly `ABSTRACT` and `FINAL` since the instantiating and calling only happens through the RAP runtime engine. -- A saver class can be defined in the CCIMP include of an ABAP +- A saver class can be defined in the CCIMP include (*Local Types* tab in ADT) of an ABAP behavior pool. It includes the definitions and implementations of RAP saver methods. - The saver methods consist of a set of predefined methods having @@ -736,7 +736,7 @@ DATA d2 TYPE TABLE FOR UPDATE zdemo_abap_rap_ch_m. "Long form: Specifying the name of the RAP BO root entity, followed "by \\ and an entity of the composition tree -"Since an alias name is specified for the example entities,it must +"Since an alias name is specified for the example entities, it must "be specified after \\. Otherwise, the entity name can be specified. "t3/d3 are the same as t1/d1. TYPES t3 TYPE TABLE FOR CREATE zdemo_abap_rap_ro_m\\root. @@ -1602,7 +1602,7 @@ READ ENTITIES OPERATIONS op_tab. in behavior implementations. - There are multiple variants available for the statement as described in the ABAP Keyword Documentation - [here](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapcommit_entities.htm). For example, RAP responses can be retrieved, key conversion in late numbering scenarios, checking a RAP transaction in a simulation mode. + [here](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapcommit_entities.htm). They deal with different variants of how to handle RAP responses, among others. - `COMMIT ENTITIES` statements set the system field `sy-subrc`. When using `COMMIT ENTITIES`, it is not guaranteed that `COMMIT WORK` is carried out successfully. @@ -1610,14 +1610,33 @@ READ ENTITIES OPERATIONS op_tab. `COMMIT ENTITIES` so that you can react to failures accordingly. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Variant/Addition Notes
+ +Short form of `COMMIT ENTITIES` + + + The following snippet shows a create operation. This operation has only an impact on the database with the `COMMIT ENTITIES` statement. Triggering the save sequence means that the execution of the statement triggers the calling of the saver methods available in the saver class of a behavior implementation. In managed scenarios (except for some special variants), the saving is done automatically without implementing -a dedicated saver method. -``` abap +a dedicated saver method. Optionally, you can specify the `RESPONSES` addition followed by a data object of type `ABP_BEHV_RESPONSE_TAB` to retrieve information returned by the response parameters of RAP saver methods. + +
+ +```abap MODIFY ENTITIES OF root_ent ENTITY root_ent CREATE FIELDS ( key_field field1 field2 ) WITH @@ -1629,11 +1648,185 @@ MODIFY ENTITIES OF root_ent COMMIT ENTITIES. +IF sy-subrc <> 0. + ... +ENDIF. + +... "Some modifications + +DATA f_resp TYPE abp_behv_response_tab. +DATA r_resp TYPE abp_behv_response_tab. +"Note: Inline declarations for the data objects are also possible. +COMMIT ENTITIES RESPONSES FAILED f_resp REPORTED r_resp. + IF sy-subrc <> 0. ... ENDIF. ``` +
+ +Long form of `COMMIT ENTITIES` + + + +The long syntax form includes the retrieval of information for one or more RAP BO entities. Root entities must be specified. + +
+ +``` abap +COMMIT ENTITIES + RESPONSE OF zdemo_abap_rap_ro_m + FAILED DATA(f1) + REPORTED DATA(r1) + RESPONSE OF zdemo_abap_rap_draft_m + FAILED DATA(f2) + REPORTED DATA(r2). + +IF sy-subrc <> 0. + ... +ENDIF. +``` + +
+ +Dynamic form of `COMMIT ENTITIES` + + + +The dynamic syntax form allows you to retrieve RAP responses from RAP saver methods by dynamically specifying one or more RAP BO root entities. + + +
+ +``` abap +DATA: root_name1 TYPE abp_root_entity_name VALUE 'ZDEMO_ABAP_RAP_RO_M', + root_name2 TYPE abp_root_entity_name VALUE 'ZDEMO_ABAP_RAP_DRAFT_M', + failed_resp TYPE abp_behv_response_tab. + +DATA(dyn_tab) = VALUE abp_entity_name_tab( ( root_name1 ) + ( root_name2 ) ). + +COMMIT ENTITIES RESPONSES OF dyn_tab + FAILED failed_resp + REPORTED DATA(reported_resp). + +IF sy-subrc <> 0. + ... +ENDIF. +``` + +
+ +Specifying a commit scope + + + +- Especially used in late numbering scenarios to get the final keys from the preliminary keys (using the [`CONVERT KEY`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapconvert_key.htm) addition) +- The commit scope is opened by `COMMIT ENTITIES BEGIN ...` (`...` stands for further syntax options such as the specification of `RESPONSES ...` or `RESPONSE OF ...` ), and closed by `COMMIT ENTITIES END.`. + + +
+ +``` abap +COMMIT ENTITIES BEGIN. + +... + +"CONVERT KEY OF some_bo FROM ...-%pid TO DATA(some_key). + +"For example, converting the preliminary keys (e.g. %pid components) +"based on entries in the MAPPED table of a RAP BO entity. +"Using a CONVERT KEY statement, you can retrieve the final keys of +"individual instances, and store them in a local variable. + +COMMIT ENTITIES END. +``` + +
+ +Simulating a commit + + + +- The optional `IN SIMULATION MODE` addition can be specified with `COMMIT ENTITIES` statements allowing a RAP transaction to be checked. +- With this addition, only the RAP early save phase is processed without saving data, i.e. a final `COMMIT WORK` is not performed. +- The addition can be used to check the consistency of the transaction by evaluating, for example, the `sy-subrc` value as a result of executing the commit in simulation mode. + + +
+ +``` abap +DELETE FROM zdemo_abap_rapt1. + +DO 2 TIMES. + MODIFY ENTITIES OF zdemo_abap_rap_ro_m + ENTITY root + CREATE FIELDS ( key_field ) + AUTO FILL CID WITH VALUE #( ( key_field = 100 ) ) + MAPPED DATA(m1) + FAILED DATA(f1) + REPORTED DATA(r1). + + IF sy-index = 1. + COMMIT ENTITIES IN SIMULATION MODE. + ELSE. + COMMIT ENTITIES. + ENDIF. + + IF sy-subrc <> 0. + ... + ENDIF. + +"Data is not saved + SELECT FROM zdemo_abap_rapt1 + FIELDS key_field + ORDER BY key_field + INTO TABLE @DATA(tab). + + IF sy-index = 1. + ASSERT tab IS INITIAL. + "Clearing the transactional buffer + ROLLBACK ENTITIES. + ELSE. + ASSERT lines( tab ) = 1. + ASSERT tab[ 1 ]-key_field = 100. + ENDIF. +ENDDO. +``` + +
+ + + +

⬆️ back to top

### Raising RAP Business Events @@ -1643,7 +1836,7 @@ ENDIF. - `event` specifications are available in the BDEF (e.g. `... event some_evt; ...`). For more details, refer to the [BDL documentation](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenbdl_event.htm) - A [RAP event handler class](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_event_handler_class_glosry.htm) is available that is used to implement [RAP event handler methods](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_event_handler_meth_glosry.htm). - Note that these methods are called asynchronously. - - Similar to RAP handler and saver methods, RAP event handler methods are implemented in the CCIMP include of the RAP event handler class. + - Similar to RAP handler and saver methods, RAP event handler methods are implemented in the CCIMP include (*Local Types* tab in ADT) of the RAP event handler class. - To locally consume RAP business events, a local class that inherits from `CL_ABAP_BEHAVIOR_EVENT_HANDLER` can be implemented in the CCIMP include of a RAP event handler class. - More information: - [ABAP for RAP Business Events](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_events.htm) in the ABAP Keyword Documentation diff --git a/22_Released_ABAP_Classes.md b/22_Released_ABAP_Classes.md index 20138aa..6c6ddc8 100644 --- a/22_Released_ABAP_Classes.md +++ b/22_Released_ABAP_Classes.md @@ -2502,10 +2502,33 @@ ENDTRY. CL_ABAP_PARALLEL -For performing the parallel processing for instances of ABAP Objects. The following example class is intended to be a self-contained example that tries to visualize the functionality of the CL_ABAP_PARALLEL class. For more information, refer to the class documentation. +For performing the parallel processing for instances of ABAP Objects. For more information, refer to the class documentation.

-``` abap +The following example class demonstrates parallel processing using the `CL_ABAP_PARALLEL` class. + +
+ 🟢 Click to expand for more information and example code + + +Notes on the example: +- As a prerequisite, ensure you have a class implementing the `IF_ABAP_PARALLEL` interface. In this self-contained example, the executable class itself implements it. +- Before running the class with F9 in ADT, set a breakpoint for the `ASSERT` statement in the implementation of the `if_oo_adt_classrun~main` method. +- The example visualizes parallel processing by adding timestamps to an internal table. When program execution stops, you can check the table contents. +- First, instances of the example class are created for the parallel processing of instances. +- Next, an instance of the `CL_ABAP_PARALLEL` class is created. The example omits optional parameters; refer to the class documentation for details. +- Parallel processing begins with the `run_inst` method, adding the instances to the input parameter. +- A table of result information for tasks is returned and stored in a data object. +- After starting the parallel processing, the `if_abap_parallel~do` method is called for each instance. This method includes a `DO` loop that populates the `info` table with timestamps. +- The example includes a `WAIT` statement to pause program execution to ensure that all the parallel processing runs have completed. +- The result information table is then looped over, and details are accessed by casting to the respective class (in this case, the example class). +- The `info` table is sorted by timestamps. In the debugger, you can explore the functionality of the parallel processing in the following ways: + - The `instance` component may show a random instance, like `inst3`, processed first. + - Due to many loop passes, other instances might start in parallel before the current instance finishes. The `instance` component might show, for example, that `inst3` was processed first while `inst1` began. Some `time_stamp` values may even show identical values. + +
+ +```abap CLASS zcl_some_class DEFINITION PUBLIC FINAL @@ -2514,127 +2537,77 @@ CLASS zcl_some_class DEFINITION PUBLIC SECTION. INTERFACES if_oo_adt_classrun. INTERFACES if_abap_parallel. - METHODS: constructor. + METHODS constructor IMPORTING text TYPE string OPTIONAL. + PROTECTED SECTION. PRIVATE SECTION. - "This table holds entries that are added when - "calling the 'do' method. - DATA info_parallel_proc TYPE string_table. + DATA instance_name TYPE string. + DATA time_stamp TYPE utclong. + + TYPES: BEGIN OF struct, + time_stamp TYPE utclong, + instance TYPE string, + comment TYPE string, + END OF struct. + DATA info TYPE TABLE OF struct WITH EMPTY KEY. + DATA parallel_proc LIKE info. - "Data types and objects for the data cluster - "that contains information to be output - CLASS-DATA buffer TYPE xstring. - DATA obj TYPE string. - DATA parallel_log TYPE string_table. - DATA inst_name TYPE string. - "Structure to hold information for the output - DATA: BEGIN OF info, - name TYPE string, - tmstmp TYPE utclong, - END OF info. - "Preparing the data cluster - METHODS handle_cluster IMPORTING name TYPE string. ENDCLASS. CLASS zcl_some_class IMPLEMENTATION. METHOD if_oo_adt_classrun~main. - "This is a self-contained example class trying to visualize the - "functionality of the cl_abap_parallel class. - "As a prerequisite, you have a class that implements the interface - "IF_ABAP_PARALLEL. In the self-contained example, it is this class - "itself that implements it. - "When running the class with F9, the following code is executed. + APPEND VALUE #( time_stamp = time_stamp instance = `----` comment = `Time stamp stored when first running/calling the class` ) TO info. + + DATA(inst1) = NEW zcl_some_class( `inst1` ). + DATA(inst2) = NEW zcl_some_class( `inst2` ). + DATA(inst3) = NEW zcl_some_class( `inst3` ). + DATA(inst4) = NEW zcl_some_class( `inst4` ). + DATA(inst5) = NEW zcl_some_class( `inst5` ). + + APPEND VALUE #( time_stamp = utclong_current( ) instance = `----` comment = `Time stamp stored before starting parallel processing` ) TO info. - "Creating an instance of class cl_abap_parallel DATA(parallel) = NEW cl_abap_parallel( ). - "Creating instances of this example class for demonstration - "purposes. The handle_cluster method is used to manually - "provide the name of the object reference variable for - "output purposes. - handle_cluster( `inst1` ). - DATA(inst1) = NEW zcl_some_class( ). - - handle_cluster( `inst2` ). - DATA(inst2) = NEW zcl_some_class( ). - - handle_cluster( `inst3` ). - DATA(inst3) = NEW zcl_some_class( ). - - handle_cluster( `inst4` ). - DATA(inst4) = NEW zcl_some_class( ). - - WAIT UP TO 1 SECONDS. - - "Starting the parallel processing for objects with the 'run_inst' method. - "As input parameters, instances of the classes to be processed are expected. - "The importing parameter is an internal table. It contains result information - "for the tasks that were processed in parallel. parallel->run_inst( EXPORTING p_in_tab = VALUE #( ( inst1 ) ( inst2 ) ( inst3 ) - ( inst4 ) ) + ( inst4 ) + ( inst5 ) ) IMPORTING p_out_tab = DATA(result_info) ). + APPEND VALUE #( time_stamp = utclong_current( ) instance = `----` comment = `Time stamp stored after starting parallel processing` ) TO info. + WAIT UP TO 1 SECONDS. - LOOP AT result_info INTO DATA(wa). - "For accessing the details, a cast to the respective class is required (in this - "case, it is this very class). - DATA(res) = CAST zcl_some_class( wa-inst ). + APPEND VALUE #( time_stamp = utclong_current( ) instance = `----` comment = `Time stamp stored after the WAIT statement` ) TO info. - "Adding information to a string table that is output - APPEND |**** Instance "{ res->info-name }" created at { res->info-tmstmp } ****| TO parallel_log. - LOOP AT res->info_parallel_proc INTO DATA(wap). - APPEND |{ wap }| TO parallel_log. - ENDLOOP. - APPEND `-----------------------------------------------------------------` TO parallel_log. + LOOP AT result_info INTO DATA(wa). + DATA(res) = CAST zcl_some_class( wa-inst ). + APPEND LINES OF res->parallel_proc TO info. + APPEND VALUE #( time_stamp = res->time_stamp instance = res->instance_name comment = `Time stamp stored in constructor implementation when instantiating class` ) TO info. ENDLOOP. - out->write( parallel_log ). + SORT info BY time_stamp ASCENDING. + + ASSERT 1 = 1. ENDMETHOD. METHOD if_abap_parallel~do. - "The following code is executed in parallel. - "In the simplified example, some text is added to a string table that - "is output later on. It includes a time stamp to compare the different - "outputs. - DO 3 TIMES. - APPEND |This text was added at { utclong_current( ) }| TO info_parallel_proc. + DO 1000 TIMES. + APPEND VALUE #( time_stamp = utclong_current( ) instance = instance_name comment = |Entry { sy-index } added within "do" method| ) TO parallel_proc. ENDDO. ENDMETHOD. METHOD constructor. - "The purpose of the implementation in the instance constructor - "is to pass the manually added name of the object reference - "variable for output purposes. - "A data cluster is used to have a self-contained example class - "that can be run with F9. - TRY. - IMPORT str = inst_name FROM DATA BUFFER buffer. - CATCH cx_sy_import_format_error INTO DATA(error). - ENDTRY. - - IF error IS INITIAL. - "The information provided here is used for output purposes. - "The name of the object reference variable is - "expected to be the only input in the table, as well as - "a time stamp to compare with other time stamps that are - "output. - info = VALUE #( name = inst_name - tmstmp = utclong_current( ) ). + IF text IS SUPPLIED AND text IS NOT INITIAL. + instance_name = text. ENDIF. + time_stamp = utclong_current( ). ENDMETHOD. - METHOD handle_cluster. - "This method is used to prepare the data cluster and - "pass the name of the object reference variable that - "was added manually via the input parameter 'name'. - CLEAR buffer. - obj = name. - EXPORT str = obj TO DATA BUFFER buffer. - ENDMETHOD. ENDCLASS. -``` +``` + +