Show TOC

LDQ API "Read"Locate this document in the navigation structure


Reading Units Using the LDQ API ("Read")

To read a given table of queues, for every queue a reader object and a unit reader object are created. For every queue, the units are read in blocks of n. For every unit, the format of the payload is determined, then the payload extracted, and the unit size determined. After all n units in a block have been read and analyzed in this way, they are confirmed (that is marked for deletion) in the database.

Sequence Diagram:


a) Input parameters:

ap_name TYPE ldq_application_name DEFAULT 'Perf_TEST',

qp_name TYPE ldq_queue_name DEFAULT 'LDQ_TEST_',

n_queues TYPE i DEFAULT 5,

n_units TYPE i DEFAULT 10,

n_times TYPE i DEFAULT 1.

b) Declarations:

DATA: l_ldq_reader TYPE REF TO if_ldq_reader,

l_ldq_unit_reader TYPE REF TO if_ldq_unit_reader.

DATA: l_queue_name_tab TYPE ldq_queue_name_tab,

l_queue_name TYPE ldq_queue_name.

DATA: l_xdata TYPE xstring,

l_cdata TYPE string.

DATA: l_size TYPE i.

DATA: l_content_tab TYPE ldq_unit_content_reader_tab.

DATA: l_state_tab TYPE ldq_unit_state_reader_tab.

DATA: l_del TYPE i.

DATA: l_seq_nr TYPE ldq_unit_id.

DATA: l_queue_nr(4) TYPE n.

DATA: l_lines TYPE i.

DATA: l_last_lines TYPE i.

DATA: l_unit TYPE i.

DATA: l_state_wa TYPE REF TO if_ldq_unit_state_reader,

l_content_wa TYPE REF TO if_ldq_unit_content_reader.

DATA: l_format TYPE ldq_data_format.

DATA: l_next_state_nr TYPE i.

DATA: l_number TYPE i.

TYPES: BEGIN OF lt_my_unit_reader,

unit_reader TYPE REF TO if_ldq_unit_reader,

queue_name TYPE ldq_queue_name,

END OF lt_my_unit_reader.

DATA: l_my_unit_reader_tab TYPE TABLE OF lt_my_unit_reader.

DATA: l_my_unit_reader TYPE lt_my_unit_reader.

FIELD-SYMBOLS: <l_content_wa> TYPE REF TO if_ldq_unit_content_reader.

FIELD-SYMBOLS: <l_state_wa> TYPE REF TO if_ldq_unit_state_reader.

c) Creation of queue names:

CLEAR: l_queue_name_tab[], l_content_tab[].

DO n_queues TIMES.

l_queue_nr = sy-index.

CONCATENATE qp_name l_queue_nr INTO l_queue_name.

CONDENSE l_queue_name NO-GAPS.

APPEND l_queue_name TO l_queue_name_tab.


LOOP AT l_queue_name_tab INTO l_queue_name.

d) Creation of LDQ application object:

l_ldq_reader = cl_ldq_application=>get_reader( ap_name ).


* Creation of LDQ queu objects for each queue name


l_my_unit_reader-unit_reader = l_ldq_reader->set_queue_name( l_queue_name ).

l_my_unit_reader-queue_name = l_queue_name.

APPEND l_my_unit_reader TO l_my_unit_reader_tab.



* Read the block units over all queues n_times


DO n_times TIMES.


LOOP AT l_my_unit_reader_tab INTO l_my_unit_reader.

e) Get n_units in one block:

l_content_tab = l_my_unit_reader-unit_reader->get_next_contents( n_units ).

l_unit = LINES( l_content_tab ).

f) Retrieve contained information out of content object:

CLEAR l_number.

WRITE: / l_unit, 'Qname:', l_my_unit_reader-queue_name.

LOOP AT l_content_tab ASSIGNING <l_content_wa>.

l_format = <l_content_wa>->get_format( ).

IF cl_ldq_unit_writer=>co_character_data_type = l_format.

l_cdata = <l_content_wa>->get_cdata( ).


l_xdata = <l_content_wa>->get_xdata( ).


l_seq_nr = <l_content_wa>->get_sequence_number( ).

l_size = <l_content_wa>->get_size( ).

l_number = l_number + 1.

WRITE: /10 'number:', l_number, 'sequence number =', l_seq_nr, 'size in kb:', l_size.


g) Confirm the read unit in the database:


l_my_unit_reader-unit_reader->confirm( ).

h) Persist the read status of LDQ data into the database: