Show TOC

"Read" with Initial Confirm and ForecastLocate this document in the navigation structure


Reading units using the LDQ API ("Read") with Initial Confirm and Forecast

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 10 to extract their state information only, which includes the units'sizes. As soon as a given u_size is reached, the contents of the corresponding units is read and the payload extracted as in the previous scenario. Afterwards the read units are deleted (confirmed) 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_times TYPE i DEFAULT 1,

u_size TYPE i DEFAULT 2.

last_received_seq_nr TYPE ldq_unit_id.

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_next_content_nr TYPE i.

data: l_number type i.

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.


u_size = u_size * 1000. "in kbytes

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 ).

e) Confirm the read units from previous sessions, up to a given sequence number:


l_ldq_reader->confirm_queue_units( l_queue_name, last_received_seq_nr ).

* Note: This method executes an implicit commit.


f) Initialisation of the queue name to retrieve the units:


l_ldq_unit_reader = l_ldq_reader->set_queue_name( l_queue_name ).

DO n_times TIMES. "n_read TIMES.

g) Retrieve as many units as fit into the u_size:


l_next_state_nr = l_lines = 0.


l_next_state_nr = l_next_state_nr + 10.

l_state_tab = l_ldq_unit_reader->get_next_states( l_next_state_nr ).

l_last_lines = LINES( l_state_tab ).

IF l_lines >= l_last_lines.

* not enough units on the database to reach the required u_size

* therfore use the existing one

l_next_content_nr = l_lines.



l_lines = l_last_lines.


l_size = 0.

LOOP AT l_state_tab ASSIGNING <l_state_wa>.

l_size = l_size + <l_state_wa>->get_size( ).

IF l_size >= u_size.

l_next_content_nr = sy-tabix.




IF l_size < u_size.



* the requested size is reached





h) Get the (maximum) l_next_content_nr contents, i. e. unit state plus its payload, from the queue:


l_content_tab = l_ldq_unit_reader->get_next_contents( l_next_content_nr ).

l_unit = LINES( l_content_tab ).

i) Retrieve contained information out of content object:


l_number = l_number + 1.

WRITE: / l_number, 'Qname:', l_queue_name, 'unit number:', l_unit.

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_sequence number = <l_content_wa>->get_sequence_number( ).

l_size = <l_content_wa>->get_size( ).

WRITE: /13 'sequence number:', l_seq_nr, 'size:', l_size.


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