Skip to end of metadata
Go to start of metadata

Below is a routine to get log of a given batch input session. You can get the ID by looking at SM35, or directly getting it in table APQI (field QID).

Here is an example how to call the routine, the result is stored in an internal table

PARAMETERS p_qid LIKE apqi-qid DEFAULT '16071414545955287485'.

START-OF-SELECTION.
DATA: lt_bdclm TYPE TABLE OF bdclm,
      l_message TYPE string.
FIELD-SYMBOLS:
     <ls_bdclm> TYPE bdclm.

PERFORM get_bdc_session_log  USING p_qid CHANGING lt_bdclm.

LOOP AT lt_bdclm ASSIGNING <ls_bdclm>.
  PERFORM get_bdc_session_log_msg_text USING <ls_bdclm> CHANGING l_message.
  WRITE / l_message.
ENDLOOP.

Main routine:

TYPES ty_t_bdclm TYPE TABLE OF bdclm.
*----------------------------------------------------------------------*
FORM get_bdc_session_log USING i_qid TYPE apqi-qid CHANGING et_bdclm TYPE ty_t_bdclm.
  DATA: lt_apqltab TYPE TABLE OF apql,
  ls_apqltab TYPE apql,
  l_fbhandle TYPE rststype-fbhandle.

  REFRESH et_bdclm.
  CALL FUNCTION 'BDC_PROTOCOL_SELECT_QID'
    EXPORTING
      queue_id     = i_qid
    TABLES
      apqltab      = lt_apqltab
    EXCEPTIONS
      invalid_data = 1
      OTHERS       = 2.
  " A QID log may contain several TemSe IDs for technical reasons,
  " just merge them
  LOOP AT lt_apqltab INTO ls_apqltab.
    CALL FUNCTION 'RSTS_OPEN_RLC'
      EXPORTING
        authority = 'BATCH'
        name      = ls_apqltab-temseid
      IMPORTING
        fbhandle  = l_fbhandle
      EXCEPTIONS
        OTHERS    = 10.
    " RSTS_READ appends entries to DATATAB parameter (not emptied)
    CALL FUNCTION 'RSTS_READ'
      EXPORTING
        fbhandle = l_fbhandle
      TABLES
        datatab  = et_bdclm
      EXCEPTIONS
        OTHERS   = 5.
    CALL FUNCTION 'RSTS_CLOSE'
      EXPORTING
        fbhandle = l_fbhandle
      EXCEPTIONS
        OTHERS   = 4.
  ENDLOOP.
ENDFORM.                    "get_bdc_session_log
 
 

*----------------------------------------------------------------------*
FORM get_bdc_session_log_msg_text USING is_bdclm TYPE bdclm CHANGING e_text TYPE string.
  DATA: l_offset TYPE i,
        l_length TYPE i,
        BEGIN OF ls_symsgv,
          v1 TYPE symsgv,
          v2 TYPE symsgv,
          v3 TYPE symsgv,
          v4 TYPE symsgv,
          END OF ls_symsgv.
  FIELD-SYMBOLS:
        <l_symsgv> TYPE symsgv.

  l_offset = 0.
  DO is_bdclm-mparcnt TIMES.
    ASSIGN COMPONENT sy-index OF STRUCTURE ls_symsgv TO <l_symsgv>.
    l_length = is_bdclm-mpar+l_offset(2).
    ADD 2 TO l_offset.
    IF l_length <> 0.
      <l_symsgv> = is_bdclm-mpar+l_offset(l_length).
    ENDIF.
    ADD l_length TO l_offset.
  ENDDO.
  MESSAGE ID is_bdclm-mid TYPE 'S' NUMBER is_bdclm-mnr
        WITH ls_symsgv-v1 ls_symsgv-v2 ls_symsgv-v3 ls_symsgv-v4
        INTO e_text.
ENDFORM.                    "get_bdc_session_log_msg_text

 

 

  • No labels