Start of Content Area

This graphic is explained in the accompanying text Repeated Read-and-Confirm Cycles  Locate the document in its SAP Library structure

 

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

Several read – read - … - read-confirm-commit cycles can occur in the same session. Here is a simplified illustration of the single cycle described in the previous example.

 

Flow Chart:

This graphic is explained in the accompanying text

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

 

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

      n_cycles          TYPE i DEFAULT 4.

 

 

 

 

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.

ENDDO.

 

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) Creation of LDQ Queue 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.

ENDLOOP.

 

f) Several read-read-…-read-confirm cycles.

*

DO n_cycles TIMES.

 

*

 

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

 

 

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

 

 

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

      ELSE.

        l_xdata = <l_content_wa>->get_xdata( ).

      ENDIF.

      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.

    ENDLOOP.

 

j) Confirm read Units in the Database:

*

    l_my_unit_reader-unit_reader->confirm( ).

 

k) Persist the read Status of LDQ Data into the Database:

    COMMIT WORK.

 

  ENDLOOP.      next read-read-…-read-confirm cycle

 

  ENDLOOP.      next queue

 

End of Content Area