Show TOC

Example documentationRepeated Read-and-Confirm Cycles Locate this document in the navigation structure

 

Repeated Read-and-Confirm Cycles Using the LDQ API ("Read")

In the same session several read - read - … - read-confirm-commit cycles can occur. Here is a simplified illustration of the single cycle described in the example before.

Sequence Diagram:

This graphic is explained in the accompanying text.

The following outline illustrates n_cycles repetitions of a cycle with n_times reads of n_units units at once, with an explicit commit at the end of each cycle.

Syntax Syntax

Input Parameters
  1.       ap_name           TYPE ldq_application_name DEFAULT 'Perf_TEST',
  2.       qp_name           TYPE ldq_queue_name DEFAULT 'LDQ_TEST_',
  3.       n_queues          TYPE i DEFAULT 5,
  4.       n_units           TYPE i DEFAULT 10,
  5.       n_times           TYPE i DEFAULT 3.
  6.       n_cycles          TYPE i DEFAULT 4.
End of the code.

Syntax Syntax

Declarations
  1. DATA: l_ldq_reader      TYPE REF TO if_ldq_reader,
  2.       l_ldq_unit_reader TYPE REF TO if_ldq_unit_reader.
  3. DATA: l_queue_name_tab  TYPE ldq_queue_name_tab,
  4.       l_queue_name      TYPE ldq_queue_name.
  5. DATA: l_xdata           TYPE xstring,
  6.       l_cdata           TYPE string.
  7. DATA: l_size            TYPE i.
  8. DATA: l_content_tab     TYPE ldq_unit_content_reader_tab.
  9. DATA: l_state_tab       TYPE ldq_unit_state_reader_tab.
  10. DATA: l_del             TYPE i.
  11. DATA: l_seq_nr          TYPE ldq_unit_id.
  12. DATA: l_queue_nr(4)     TYPE n.
  13. DATA: l_lines           TYPE i.
  14. DATA: l_last_lines      TYPE i.
  15. DATA: l_unit            TYPE i.
  16. DATA: l_state_wa        TYPE REF TO if_ldq_unit_state_reader,
  17.       l_content_wa      TYPE REF TO if_ldq_unit_content_reader.
  18. DATA: l_format          TYPE ldq_data_format.
  19. DATA: l_next_state_nr   TYPE i.
  20. DATA: l_number          TYPE i.
  21. TYPES: BEGIN OF lt_my_unit_reader,
  22.          unit_reader TYPE REF TO if_ldq_unit_reader,
  23.          queue_name    TYPE ldq_queue_name,
  24.       END OF lt_my_unit_reader.
  25. DATA: l_my_unit_reader_tab TYPE TABLE OF lt_my_unit_reader.
  26. DATA: l_my_unit_reader TYPE lt_my_unit_reader.
  27. FIELD-SYMBOLS: <l_content_wa> TYPE REF TO if_ldq_unit_content_reader.
  28. FIELD-SYMBOLS: <l_state_wa>   TYPE REF TO if_ldq_unit_state_reader.
End of the code.

Syntax Syntax

Creation of Queue Names
  1. CLEAR: l_queue_name_tab[], l_content_tab[].
  2. DO n_queues TIMES.
  3.   l_queue_nr = sy-index.
  4.   CONCATENATE qp_name l_queue_nr INTO l_queue_name.
  5.   CONDENSE l_queue_name NO-GAPS.
  6.   APPEND l_queue_name TO l_queue_name_tab.
  7. ENDDO.
  8. LOOP AT l_queue_name_tab INTO l_queue_name.
End of the code.

Syntax Syntax

Creation of LDQ Application Object
  1.   l_ldq_reader       = cl_ldq_application=>get_reader( ap_name ).
End of the code.

Syntax Syntax

Creation of LDQ Queue Objects for each Queue Name
  1. *
  2.   l_my_unit_reader-unit_reader = l_ldq_reader->set_queue_name( l_queue_name ).
  3.   l_my_unit_reader-queue_name  = l_queue_name.
  4.   APPEND l_my_unit_reader TO l_my_unit_reader_tab.
  5. ENDLOOP.
End of the code.

Syntax Syntax

Several read-read-…-read-confirm cycles
  1. *
  2. DO n_cycles TIMES.
  3. *
End of the code.

Syntax Syntax

Read the Block Units over all Queues n_times
  1. *
  2. DO n_times TIMES.
  3.   LOOP AT l_my_unit_reader_tab INTO l_my_unit_reader.
End of the code.

Syntax Syntax

Get n_units in one Block
  1.     l_content_tab = l_my_unit_reader-unit_reader->get_next_contents( n_units ).
  2.     l_unit = LINES( l_content_tab ).
End of the code.

Syntax Syntax

Retrieve contained Information out of Content Object
  1.     CLEAR l_number.
  2.     WRITE: / l_unit, 'Qname:', l_my_unit_reader-queue_name.
  3.     LOOP AT l_content_tab  ASSIGNING <l_content_wa>.
  4.       l_format = <l_content_wa>->get_format( ).
  5.       IF cl_ldq_unit_writer=>co_character_data_type = l_format.
  6.         l_cdata = <l_content_wa>->get_cdata( ).
  7.       ELSE.
  8.         l_xdata = <l_content_wa>->get_xdata( ).
  9.       ENDIF.
  10.       l_seq_nr  = <l_content_wa>->get_sequence_number( ).
  11.       l_size = <l_content_wa>->get_size( ).
  12.       l_number = l_number + 1.
  13.       WRITE: /10 'number:', l_number, 'sequence number =', l_seq_nr, 'size in kb:', l_size.
  14.     ENDLOOP.
End of the code.

Syntax Syntax

Confirm Read Units in the Database
  1. *
  2.     l_my_unit_reader-unit_reader->confirm( ).
End of the code.

Syntax Syntax

Persist the Read Status of LDQ Data into the Database
  1.     COMMIT WORK.
  2.   ENDLOOP.      next read-read-…-read-confirm cycle
  3.   ENDLOOP.      next queue
End of the code.