Display protocol of batch input processing - transaction SM35

I haven't found any standard SAP function modules to read the protocols of batch input session created by transaction SM35. These protocols are contained in TemSe - a store for temporary sequential data. There can be many protocols associated with one map. The protocols in TemSe consist of message class, number and a field which stores values of possible variables. The format of this field with values of variables is quite inconvenient to handle, I'm really missing the standard SAP function module to read it.
The example below shows how to read batch input protocol with maximal utilization of standard coding from the includes. Please change the value of variable 'lv_queueid' for a valid queue id in your system.
INCLUDE rsbdcil1.
INCLUDE rsbdcil2.
INCLUDE rsbdcil3.

START-OF-SELECTION.

  DATA:
    lv_queueid  TYPE apq_quid VALUE '11091214143070865804',
    lt_protocol TYPE string_table,
    ls_protocol TYPE string.

  PERFORM get_sm35_log USING lv_queueid
                       CHANGING lt_protocol.

  LOOP AT lt_protocol INTO ls_protocol.
    WRITE: / ls_protocol.
  ENDLOOP.

*&---------------------------------------------------------------------*
*&      Form  get_sm35_log
*&---------------------------------------------------------------------*
FORM get_sm35_log USING    pi_queueid  TYPE apq_quid
                  CHANGING pt_protocol TYPE string_table.

  DATA:
    lt_apql TYPE TABLE OF apql,
    ls_apql TYPE apql.

  CALL FUNCTION 'BDC_PROTOCOL_SELECT_QID'
    EXPORTING
      queue_id     = pi_queueid
    TABLES
      apqltab      = lt_apql
    EXCEPTIONS
      invalid_data = 1
      OTHERS       = 2.

  ASSERT sy-subrc = 0.

  ASSERT LINES( lt_apql ) > 0.

  READ TABLE lt_apql INTO ls_apql INDEX 1.

  bdcld-temseid = ls_apql-temseid.
  bdcld-mandant = ls_apql-mandant.
  PERFORM log_mes.

  LOOP AT bdclm.
    PERFORM get_text.
    APPEND mtext TO lt_protocol.
  ENDLOOP.
ENDFORM.                    "get_sm35_log
See other related notes in my infodepot:
Background job - ensure sequential processing Submit program RFBIBL00 and display protocol from your ABAP
Full list of examples in my infodepot

If you have a question, have found an error or just want to contact me, please use this form.

Copyright (C) 2011 http://www.kerum.pl/infodepot/

Disclaimer: I am not affiliated or related to any division or subsidiary of SAP AG.
Trademarks or registered trademarks of any products or companies referred to on this site belong to those companies.
Anyone using the given solutions, is doing it under his/her own responsibility and at own risk.