Skip to Content
Author's profile photo Roberto Forti dos Santos

ABAP Object Services Technique

ABAP Object Services

#1. Creating Persistent Object with single-table

SAP Community has introduced excellent Professionals to SAP world as well as providing opportunity for all to writing blog posts which has helped us to improve SAP knowledge.

One of many important SAP techniques which I have been reading about is ABAP Object Services applying object-oriented concept.

This first blog post will show a simple way of creating persistence class working with single-table.

1. ABAP Object Services – Creating Persistent Object with single-table

  • Objective: handling the synchronization of data stored in objects with database table creating a method to synchronize object data with a relational database table considering object relational mapping (ORM) tool.
  • Following simple steps to create persistence class.

1.1. Creating Persistent Class (SE80)

  • Start transaction SE80 to create a Persistence class without “Final” class checked.

  • Confirm “Yes” to activate Class Agent – “At runtime, Class Agent run between persistent objects and the ABAP Object Services”.

  • Agent ABAP Persistent Class implemented.

1.2. Working with single-table using Mapping Assistant tool

  • Going to Persistence Representant to add single-table

  • Insert table/structure for corresponding class.

  • By Business Key – ABAP Dictionary tables which use exiting primary key.

  • Mapping Assistant tool  – Click on Generator Settings button and uncheck the minimum Interface for methods CREATE_PERSISTENT and CREATE_TRANSIENT.

1.3. Persistent objects – Consumer Perspective

  • Persistent objects are managed by object services.

1.4. Creating Persistent Object Instance with class agent

  • ABAP code example: Simple report with corresponding statement Persistent Class and Agent Class working with synchronization of data stored in objects with a relational database table.
REPORT zabap_persistent_object.

DATA: lo_cl_persist TYPE REF TO zcl_single_table_persistent,
      lx_os_ex      TYPE REF TO cx_os_object_existing,
      lv_text       TYPE string.


      lo_cl_persist = zca_single_table_persistent=>agent->create_persistent(
                        i_char20 = 'TEST01'
                        i_int4   = 1
                        i_char50 = 'TEST-01'
                        i_fltp   = '100.50'
                        i_tims   = sy-uzeit ).

    CATCH cx_os_object_existing INTO lx_os_ex.
      lv_text = lx_os_ex->get_text( ).

* COMMIT WORK: Persistence Service convert in-memory record into the Database table.

1.5. Record converted into Database table

  • Transactions SE11, SE16 and SE16N to check it.


Certainly, learning ABAP Object Services technique will improve technical knowledge as well as makes the ABAP code flexible to implement persistence without writing SQL.

Is recommended reading SAP documentation and practicing it to understanding each detail.

Following excellent SAP documentation to support understanding ABAP Object Services technique.

Thank you for reading this post.


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Flavio de Souza
      Flavio de Souza

      Nice post Roberto. Thanks for sharing this useful topic in such easy and understandable way. Keep up the good job!

      Author's profile photo Andre Ricardo da Silva Miranda
      Andre Ricardo da Silva Miranda

      Awesome topic Roberto.

      Thanks for sharing!