CL_DATA_CONTAINER - Data Container for Any Data

CPI1466 during Backup   CL_GUI_FRONTEND_SERVICES - Frontend Services  
This documentation is copyright by SAP AG.

Functionality

Instances of the class CL_DATA_CONTAINER can manage any data (except references)and store them on the database. It does not matter whether the data consists of simple data elements,nested structures of any depth, or tables. It is not necessary for the type on which the data is based to exist in the DDIC. The container is able to work with dynamically generated types.

For more information on dynamic types, see the ABAP keyword documentation. Choose RTTS Run Time Type Services

To access the ABAP keyword documentation:

  1. Start transaction SE80.
  2. Display any program code.
  3. Position the cursor anywhere in the code.
  4. Call the F1 Help.
  5. Choose ABAP overview

To see the documentation, choose ABAP Keyword Documentation ->ABAP REFERENCE -> ABAP System Classes and Interfaces -> RTTS Run Time Type Services.

The SETDATA method writes any type of data to the data container with the name IV_NAME.

The CHANGE_DATA method is redundant and should no longer be used. Instead, use the SETDATA method.

The GETDATA method returns either the actual data or a reference to anobject of the type of the data. This can be useful, for example, if you want to copy a container but do not know what data is contained in the container (see the second example below).

The SAVE method writes the data to the database. Caution: The method does not execute a COMMIT.

Relationships

The container was originally developed for the FPP (Framework for Parallel Processing) but can be used independently of it.

Example

Creating and Saving a Container

DATA:     lcl_container  TYPE REF TO CL_DATA_CONTAINER,

          lv_data        TYPE string.

TRY.

   CREATE OBJECT lcl_container EXPORTING ev_guid = 'MY_CONTAINER'.

   lv_data = 'This is a test'.

   CALL METHOD lcl_cont->setdata EXPORTING iv_name = 'NUMMER1'

                                          data    = lv_data.

   CALL METHOD lcl_cont->save IMPORTING ev_guid = lv_guid.

   COMMIT WORK.

   CLEAR lcl_container.

   CREATE OBJECT lcl_container EXPORTING ev_guid = 'MY_CONTAINER'.

  CATCH cx_fpp_exception.

    BREAK-POINT.

ENDTRY.

Copying a Container

DATA: lcl_old_cont      TYPE REF TO cl_data_container,

      lcl_new_cont      TYPE REF TO cl_data_container,

      lt_info           TYPE fpp_ts_data_container_info,

      ls_info           TYPE fpp_s_data_container_info.

      

FIELD-SYMBOLS:  <data>  TYPE ANY.

CREATE OBJECT lcl_old_cont EXPORTING ev_guid = 'OLD_CONTAINER'.

CREATE OBJECT lcl_old_cont EXPORTING ev_guid = 'NEW_CONTAINER'.

lt_info = lcl_old_cont->getinfo( ).

LOOP AT lt_info INTO ls_info.

    CALL METHOD lcl_old_cont->getdata

      EXPORTING

        name     = ls_info-name

      CHANGING

        data_ref = data_ref.

    ASSIGN data_ref->* TO <data>.

    CALL METHOD lcl_old_cont->getdata

      EXPORTING

        name = ls_info-name

      CHANGING

        data = <data>.

    CALL METHOD lcl_new_cont->setdata

      EXPORTING

        iv_name = ls_info-name

        data    = <data>.

  ENDLOOP.

Notes

  • No identification of the container needs to be specified when an instance is generated. In this case an ID (GUID) is automatically assigned to the container when the constructor is called.
  • The SAVE method returns the ID of the container ("MY_CONTAINER" in the example).
  • If an instance is generated with an ID of a container that already exists on the database, the data of that container is loaded automatically.
  • There is no restriction on the volume of data that the container can handle.
  • When reading data, there are almost no restrictions regarding the target area. Only the generaltype (SIMPLE, STRUCTURE, TABLE) must match the stored data. The container then performs an extended MOVE-CORRESPONDING.
  • If the structure of the stored data changes due to modifications of the underlying DDIC elements,the container can still read the data as long as no fields are truncated (since that would result in loss of data). Deleting entire fields from structures and adding new fields is not a problem.
  • The container should not be used to store transaction data because internal data management uses XML serialization and data clusters, which is performance-intensive.

Further information



CPI1466 during Backup   BAL Application Log Documentation  
This documentation is copyright by SAP AG.


Length: 6986 Date: 20120526 Time: 133014     triton ( 152 ms )