Professional Documents
Culture Documents
Learning Objectives
Agenda
Overall Memory Architecture Buffered Database Tables EXPORT/IMPORT to/from Different Media Classes CL_ABAP_EXPIMP_* for Administrating EXP/IMP Media Shared Objects: Sneak Preview Summary
Task 1
Task i
Task n
Process 1
Process i
Process n
Local memory
Local memory
Local memory
Shared memory
Task Dispatching
Task i Task 1 Task 1 Task 1 Task 1 Task 1 Task 1 Context i Task i Context 1 Context 1 Context 1 Context 1 Context 1 Context 1 Context i
Process i Process i Process i Process i Process i Process i Process i Process i Process i Process j
Shared memory
Roll (1st try) Extended memory Context i Roll (2nd helping) Local memory (heap) Shared memory (task contexts)
Calendar buffer
OTR buffer
Shared memory
ST02
Dictionary buffers Dev. obj. buffers Calendar & OTR buffer Table buffers EXP/IMP buffers Memory settings
Dictionary buffers
Calendar buffer
OTR buffer
Efficiency
Size
Directory entries
Swaps
Resets
abap/ buffersize
abap/ pxa
Maximum
Default value
Profile value
Current value
Version 20:52:35
Text Pool
Version 20:55:57
Version 20:56:39
Efficiency
Size
Directory entries
Swaps
Resets
rsdb/obj/ buffersize
rsdb/obj/ max_objects
rsdb/obj/ large_obj_size
rsdb/obj/ mutex_n
Maximum
Default value
Profile value
Current value
Exercises Chapter 1
1. What are the system's current memory settings ? 2. How are the EXPORT/IMPORT buffers configured ? 3. What is the advantage of using shared memory instead of process local memory for task/transaction contexts ? 4. What is the advantage of still using paging for EXPORT TO MEMORY ?
Generic areas buffered, no. of key fields = 2 All messages for a given keyword in a given language are buffered
When using more advanced SELECT variants, the buffer will be silently bypassed in many cases
DISTINCT aggregate functions COUNT, SUM, AVG, MIN, MAX GROUP BY, HAVING joins, subqueries IS NULL ORDER BY (<> PRIMARY KEY) BYPASSING BUFFER
High performance data access Well understood, flexible query language (though somewhat restricted) Simple programming model for buffer updates
Exercises Chapter 2
1. Is client table t000 buffered ? If yes, how ? 2. When should you specify "Buffering not allowed" for a database table ?
Persistent memory:
DATABASE DATASET (obsolete)
Although SHARED MEMORY and SHARED BUFFER are accessible in parallel, normally no locking on application level is necessary:
EXPORT and IMPORT are atomic operations (from an application logic point of view) But: when
items stored under different keys are logically related or the whole process of importing, processing, and exporting must not be uninterrupted by concurrent exports,
application level locks become necessary When using enqueue/dequeue for shared memory synchronization, keep in mind that enqueue/dequeue uses remote resources
Storing Arbitrary (Data) Object Graphs in Whatever Media by Using CALL TRANSFORMATION id
1. CALL TRANSFORMATION id SOURCE item = obj1 RESULT XML xmlstr. 2. Write xmlstr with whatever wrapping to whatever (semi-)persistent data store (shared memory, database, file, ) 3. seconds or hours or years pass by 4. Read xmlstr from whatever data store 5. CALL TRANSFORMATION id SOURCE XML xmlstr RESULT item = obj2 What you get is a customizable, self-controlled (de-)serialization of arbitrary (data) object graphs Beware! For a class to be serializable, it has to implement tag interface IF_SERIALIZABLE_OBJECT.
Exercises Chapter 3
1. Export some data structure containing object and/or data references to shared buffer. Use the following framework:
* ... CALL TRANSFORMATION id SOURCE item = src RESULT XML xmlstr. EXPORT ser FROM xmlstr TO SHARED BUFFER ... * ... IMPORT ser TO xmlstr FROM SHARED BUFFER ... CALL TRANSFORMATION id SOURCE XML xmlstr RESULT item = dest. * ... IF equal( op1 = src op2 = dest ) <> abap_true. * ... ENDIF.
ENDCLASS.
*---------------------------------------------------------------------* * METHOD equal_items *---------------------------------------------------------------------* METHOD equal_items. DATA: lines1 lines2 ref1 ref2 TYPE TYPE TYPE TYPE i, i, REF TO item, REF TO item.
equal = abap_false.
*---------------------------------------------------------------------* * METHOD main *---------------------------------------------------------------------* METHOD main. DATA: items1 items2 xmlstr id
* *
* *
cl_abap_expimp_mem
+get_next_level(id generic_key) ->level_tab +get_keys(id generic_key)->keytab +get_directory(id)->directory +delete(id generic_key) +delete_all()
cl_abap_expimp_shmem
cl_abap_expimp_shbuf
cl_abap_expimp_db
cl_abap_expimp_shmem cl_abap_expimp_shbuf
+get_next_level(tabname client area id generic_key client_specified) ->level_tab +get_keys(tabname client area id generic_key client_specified) ->keytab +get_directory(tabname client area id) ->directory +delete(tabname client area id generic_key client_specified) +delete_all()
cl_abap_expimp_db
+get_next_level(tabname client area id generic_key client_specified) ->level_tab +get_keys(tabname client area id generic_key client_specified) ->keytab +get_directory(tabname client area id) ->directory +delete(tabname client area id generic_key client_specified)
CL_ABAP_EXPIMP_* - Functionality
Administration is especially important for SHARED MEMORY, because there is no automatic displacement of items that are buffered in SHARED MEMORY !
get_next_level(): return next key level (tables, clients, areas, or ids) for a given partial sequential key get_keys(): return key list for a given partial sequential key get_directory(): return directory for a given fully qualified key; analogous to IMPORT DIRECTORY delete(): delete for a given partial sequential key; for a fully qualified, equivalent to DELETE FROM delete_all(): delete everything generic_key: flag, indicating that trailing blanks in the last key field supplied are to be replaced by pattern '*' client_specified: flag, as in Open SQL, indicating explicit client handling
CLASS main DEFINITION. PUBLIC SECTION. CLASS-METHODS: display_keys. PRIVATE SECTION. CLASS-METHODS: client_dependent IMPORTING tabname TYPE csequence RETURNING value(client_dependent) TYPE flag. ENDCLASS.
"main DEFINITION
"client_dependent
CLASS cl_items_wrapper IMPLEMENTATION. METHOD fill_items. * ... Fill items depending on id ENDMETHOD. "fill_items
Pure itab Buffered DB-Tab Data Buffer Internal Table Memory Shared Memory Shared Buffer Database Input size:
Pure itab Buffered DB-Tab Data Buffer Internal Table Memory Shared Memory Shared Buffer Database Input size:
Exercises Chapter 4
1. Write a class that encapsulates a shared-buffer-based ressource identified by some id. Provide methods for
getting items out of the buffer, reading the keys (= ids) of the items currently stored in the buffer, deleting items in the buffer.
* *
*---------------------------------------------------------------------* * CLASS items_wrapper DEFINITION *---------------------------------------------------------------------* * Encapsulated buffered access to some items via get_item_ref( ) *---------------------------------------------------------------------* CLASS items_wrapper DEFINITION. PUBLIC SECTION. * Method providing buffered access to some items identified by some key CLASS-METHODS: get_item_ref IMPORTING key TYPE item_key RETURNING value(ref) TYPE REF TO item.
ENDCLASS.
ENDMETHOD.
"fill_item
*---------------------------------------------------------------------* * METHOD get_item_ref *---------------------------------------------------------------------* * Public method providing buffered access to some items identified by * some key *---------------------------------------------------------------------* METHOD get_item_ref. DATA: admin TYPE item_admin, cx TYPE REF TO cx_sy_export_buffer_no_memory. * (1) Item(key) alread loaded into local context ? READ TABLE item_admin_tab WITH TABLE KEY key = key INTO admin. IF sy-subrc = 0. Item(key) already loaded into local context WRITE: /(8) key, 'from local context:'. ELSE.
* *
* *
ENDCLASS.
"items_wrapper IMPLEMENTATION
*---------------------------------------------------------------------* * METHOD show_items *---------------------------------------------------------------------* METHOD show_items. DATA: shbuf TYPE REF TO cl_abap_expimp_shbuf, keys TYPE TABLE OF expimp_c_key, dir TYPE TABLE OF cdir.
GET RUN TIME FIELD t1. item_ref = items_wrapper=>get_item_ref( key ). GET RUN TIME FIELD t2. t2 = t2 - t1. LOOP AT item_ref->* INTO item_line. WRITE: item_line. ENDLOOP. IF sy-colno > pos. pos = sy-colno + 2. ENDIF. WRITE: AT pos t2, 's'. NEW-LINE. ENDMETHOD. "access_item
*---------------------------------------------------------------------* * METHOD delete_items *---------------------------------------------------------------------* METHOD delete_items. DATA: shbuf TYPE REF TO cl_abap_expimp_shbuf. show_items( ). CREATE OBJECT shbuf. shbuf->delete( tabname = 'INDX' area = 'XK' ). ENDMETHOD.
"delete_items
Place arbitrary (data) objects directly in Shared Objects Memory Area Instances,
including all kinds of references and dynamically created (data) objects and without any need for (de-)serialization.
Use versioning of Shared Objects Memory Area Instances for uninterrupted buffer availability even when reconstructing the buffer. Realize buffers with partially transparent (re-)load:
Provide area constructors Define
build kind (read request, invalidation, start-up), start-up-lists for area, refresh time and/or invalidation time
Summary
There's a lot of transparent shared memory support built into the system Use buffered database tables or SHARED BUFFER|MEMORY for application specific shared memory buffers Be patient if you need to operate directly without copy - on shared memory: Shared Objects will be the answer
Questions?
Q&A
Feedback
Please complete your session evaluation and drop it in the box on your way out. Be courteous deposit your trash, and do not take the handouts for the following session.