Show TOC

Example documentationLDQ API "Write" Locate this document in the navigation structure

 

Creating units using the LDQ API ("Write")

To write a given table of queues, a writer object and a unit writer object are created. The units are written in blocks of n. Status information and payload are assigned to each unit. Then the block of units is written to the database.

Sequence Diagram:

This graphic is explained in the accompanying text.

Draft:

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_unit TYPE i DEFAULT 100,

u_size TYPE i DEFAULT 2,

b_data AS CHECKBOX.

b) Variable Declarations:

DATA: l_ldq_write TYPE REF TO if_ldq_writer,

l_ldq_unit_writer TYPE REF TO if_ldq_unit_writer,

l_ldq_unit_content_writer TYPE REF TO if_ldq_unit_content_writer.

DATA: l_queue_name_tab TYPE ldq_queue_name_tab,

l_queue_name TYPE ldq_queue_name.

DATA: l_cdata TYPE string.

DATA: l_cdata2 TYPE string.

DATA: l_seq_nr TYPE ldq_unit_id.

DATA: l_queue_nr(4) TYPE n.

DATA: l_size TYPE i.

DATA: l_xdata TYPE xstring.

DATA: l_times TYPE i.

DATA: l_rt_ubegin TYPE i,

l_rt_uend TYPE i,

l_rt_qbegin TYPE i,

l_rt_qend TYPE i.

c) Creation of queue names:

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.

WRITE: / 'Qname: ', l_queue_name.

ENDDO.

ULINE.

d) Creation of binary payload:

IF b_data IS NOT INITIAL.

l_cdata2 = '01234'.

DO 100 TIMES.

CONCATENATE l_cdata2 l_cdata INTO l_cdata.

ENDDO.

l_xdata = l_cdata.

l_size = XSTRLEN( l_xdata ).

l_times = u_size * 1000 / l_size.

CLEAR l_cdata2.

DO l_times TIMES.

CONCATENATE l_cdata2 l_cdata INTO l_cdata2.

ENDDO.

l_xdata = l_cdata2.

l_size = XSTRLEN( l_xdata ).

ELSE.

IF cl_abap_char_utilities=>charsize = 1.

l_cdata2 = '0123456789'.

ELSE.

l_cdata2 = '01234'.

ENDIF.

DO 100 TIMES.

CONCATENATE l_cdata2 l_cdata INTO l_cdata.

ENDDO.

l_size = u_size - 1.

DO l_size TIMES.

CONCATENATE l_cdata l_cdata INTO l_cdata.

ENDDO.

ENDIF.

e) Creation of LDQ application object:

l_ldq_write = cl_ldq_application=>get_writer( ap_name ).

f) Initialisation of the target queues for the units in this application:

l_ldq_unit_writer = l_ldq_write->set_queue_names( l_queue_name_tab ).

GET RUN TIME FIELD l_rt_ubegin. "aktuelle Zeit holen

DO n_unit TIMES.

g) Request a unit content, i. e. status and payload of a unit, for inserting into specified queues:

l_ldq_unit_content_writer = l_ldq_unit_writer->get_next_content( ).

h) Ask for sequence number of this content:

l_seq_nr = l_ldq_unit_content_writer->get_sequence_number( ).

i) Insert the relevant data into the content:

IF b_data IS INITIAL.

* character payload

l_ldq_unit_content_writer->set_cdata( l_cdata ).

ELSE.

* binary payload

l_ldq_unit_content_writer->set_xdata( l_xdata ).

ENDIF.

ENDDO.

j) Persist unit contents into database:

COMMIT WORK.