Ansicht
Dokumentation

ABENDERIVED_TYPE_HIERARCHY_ABEXA - DERIVED TYPE HIERARCHY ABEXA

ABENDERIVED_TYPE_HIERARCHY_ABEXA - DERIVED TYPE HIERARCHY ABEXA

CL_GUI_FRONTEND_SERVICES - Frontend Services   BAL Application Log Documentation  
This documentation is copyright by SAP AG.
SAP E-Book

Using TYPE TABLE/TYPE STRUCTURE FOR HIERARCHY

This example demonstrates actions whose deep input parameters and deep output parameters use the BDEF derived types TYPE TABLE FOR HIERARCHY and TYPE STRUCTURE FOR HIERARCHY with a managed RAP BO.

Data model

The CDS data model consists of the root entity DEMO_MANAGED_HIERARCHY:

Furthermore, the example uses the following abstract entities:

Behavior definition

The CDS behavior definition DEMO_MANAGED_HIERARCHY is defined in CDS BDL as follows:

Using the notation numbering : managed for the key field, the value of the key field gets automatically created for each RAP BO instance.

Further BDEFs for root abstract entities that are relevant for the example:

Behavior implementation

For the above CDS behavior definition, one ABAP behavior pool (ABP) is created. The global class of the behavior pool is BP_DEMO_MANAGED_HIERARCHY. The actual behavior implementation takes place in local classes that are defined and implemented in the BP_DEMO_MANAGED_HIERARCHY=====CCIMP of the behavior pool.

The following methods are relevant for the example:

  • action_flat_param
The method loops at the flat input parameter. In the loop, the components of a structure are filled with values from the input parameter. These values are also changed within the loop. This change includes adding characters to the character fields and a calculation for the numeric fields. The output parameter result returns the changed instances. Furthermore, the instances are added to an internal table that is typed with the BDEF derived type TYPE TABLE FOR CREATE. This internal table with RAP BO instances is used as input for a RAP create operation.
  • action_deep_param
The method loops at the deep input parameter which includes a structure of type TYPE STRUCTURE FOR HIERARCHY. In the loop, the components of a structure are filled with selected values from the abstract entities. Similar to the previous method, these values are changed. The structure is added to the output parameter result and to an internal table on whose bases a RAP create operation is carried out.
  • action_deep_table_param
The method loops at the deep input parameter which includes a table of type TYPE TABLE FOR HIERARCHY. In the loop, the components of a structure are filled with selected values from the abstract entities. Similar to the previous methods, these values are changed. The structure is added to the output parameter result and to an internal table on whose bases a RAP create operation is carried out.
  • returnhdata
The method returns hierarchy data. The focus of this method is the use of variables that are typed with either TYPE TABLE FOR HIERARCHY or TYPE STRUCTURE FOR HIERARCHY. It visualizes how the BDEF derived type component %param, which is contained in the output parameter result, might be set up, i. e. the component itself can contain subcomponents of type TYPE TABLE FOR HIERARCHY and TYPE STRUCTURE FOR HIERARCHY. The variables, i. e. the structures and internal tables, are filled with demo data. This data is added to the output parameter result.
  • storehdata
The method loops at the deep input parameter which includes a structure of type TYPE STRUCTURE FOR HIERARCHY. In the loop, an internal table, which is typed with TYPE TABLE FOR CREATE, is filled with selected values from the abstract entities. A RAP create operation is carried out creating those instances that have been added to the internal table. Furthermore, the instances are added to the output parameter result.

Source Code

Execute

Description

Access with ABAP using EML

The program includes multiple MODIFY requests executing actions. Before the actions are carried out, the input parameters for those actions is prepared. In this case, multiple internal tables and structures that are typed with the BDEF derived types TYPE TABLE FOR HIERARCHY or TYPE STRUCTURE FOR HIERARCHY respectively are created. The structures and internal tables are filled with demo values to provide input parameters for the actions that have deep parameters. In case of the action action_deep_param, the input parameter is a structure. In case of the action action_deep_table_param, the input parameter is an internal table. The value assignment just visualizes the hierarchy data and possible components of the BDEF derived types, i. e. multiple types with FOR HIERARCHY can occur in those BDEF derived types.

The following MODIFY requests executing actions are covered in the example:

  1. Executing action action_flat_param
A content ID %cid and a flat parameter %param are provided as input parameter. A COMMIT ENTITIES statement triggers the saving of the RAP BO instances to the database. Based on the method implementation mentioned above, the action result is output. The database table entries are retrieved using a SELECT statement and output as well as a consequence of the action execution.
  1. Executing action action_deep_param
A content ID %cid and a deep parameter %param are provided as input parameter. Here, %param is a structure. A COMMIT ENTITIES statement triggers the saving of the RAP BO instances to the database. Based on the method implementation mentioned above, the action result is output. The database table entries are retrieved using a SELECT statement and output as well.
  1. Executing action action_deep_table_param
A content ID %cid and a deep parameter %param are provided as input parameter. Here, %param is an internal table. A COMMIT ENTITIES statement triggers the saving of the RAP BO instances to the database. Based on the method implementation mentioned above, the action result is output. The database table entries are output, too.
  1. Executing actions returnhdata and storehdata
A content ID %cid is provided as input parameter for the returnhdata method. Based on the method implementation mentioned above, the method returns data. This data is used as input parameter for the storehdata method which includes a RAP create operations that create RAP BO instances. A COMMIT ENTITIES statement triggers the saving of the RAP BO instances to the database. The result of both actions is output as well as the database table entries.





CL_GUI_FRONTEND_SERVICES - Frontend Services   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.

Length: 10545 Date: 20240511 Time: 064344     sap01-206 ( 162 ms )