Skip to Content

We have several applications running in the background using our LDAP directory. From time to time, the connector goes into the inactive state for an unknown reason. All background processes fails now until the LDAP connector is activated again with transaction LDAP. Here’s a short report on how to start the LDAP connector in background, i scheduled this small report every day in the morning. The coding is part of the LDAP transaction made suitable for batch processing and is able to start the connector only.

***********************************************************************
****************************
*                                                                     *
* Short functional description                                        *
* ----------------------------                                        *
*                                                                     *
* Starts the LDAP connector                                           *
*                                                                     *
***********************************************************************
***********************************************************************
REPORT zca_start_ldap.
TYPE-POOLS: icon, abap.
CONSTANTS:
  ldap_rfc                TYPE ldap_gate VALUE 'LDAP_RFC',
  c_up                    TYPE ldap_stat VALUE 'UP'.
DATA:
  ldapgatew               TYPE ldapgatew,
  lf_command              TYPE trfile,
  lf_msg_text             TYPE c LENGTH 200,
  actstat                 TYPE ldap_stat.
SELECT SINGLE rfcdest applserver stat
  INTO (ldapgatew-rfcdest
       ,ldapgatew-applserver
       ,ldapgatew-stat
       )
  FROM
    ldapgatew
  WHERE
    rfcdest = ldap_rfc.
IF sy-subrc <> 0.
  MESSAGE 'Cant find LDAP connector' TYPE 'E'.
ENDIF.
IF ldapgatew-stat = c_up.
  MESSAGE 'Connector is up without restarting' TYPE 'I'.
  STOP.
ENDIF.
CALL FUNCTION 'LDAP_STARTRFC_LOCAL'
  DESTINATION
  ldapgatew-applserver
  EXPORTING
    rfcdest               = ldapgatew-rfcdest
  IMPORTING
    ef_command            = lf_command
  EXCEPTIONS
    no_authoriz           = 1
    no_connector          = 2
    no_rfcdest            = 3
    not_local             = 4
    config_error          = 5
    multiple_reg          = 6
    gateway_failure       = 7
    communication_failure = 8  MESSAGE lf_msg_text
    system_failure        = 9  MESSAGE lf_msg_text
    OTHERS                = 10.
CASE sy-subrc.
  WHEN 0.
    "OK
  WHEN 8 OR 9.
    MESSAGE e032(ldap) WITH lf_msg_text.
  WHEN OTHERS.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDCASE.
**       Errors during the startup on OS level cannot be seen
**       directly because the call is asynchronous.
**       Therefore: Periodically check that the LDAP Connector
**       is available. If this fails within 10 seconds, issue a
**       useful error message.
DO 10 TIMES.
  CALL FUNCTION 'LDAP_CHECKRFC_LOAD'
    EXPORTING
      ldapconn       = ldapgatew-rfcdest
    IMPORTING
      ldapstat       = actstat
    EXCEPTIONS
      internal_error = 0
      OTHERS         = 0.
  IF actstat = c_up.
    EXIT.
  ENDIF.
  CALL FUNCTION 'RZL_SLEEP'
    EXPORTING
      seconds        = 1
    EXCEPTIONS
      argument_error = 0
      OTHERS         = 0.
ENDDO.
IF actstat <> c_up.
  MESSAGE lf_command+0(50) TYPE 'I'.
  MESSAGE lf_command+50(50) TYPE 'I'.
  MESSAGE lf_command+100(50) TYPE 'I'.
  MESSAGE lf_command+150(50) TYPE 'I'.
  MESSAGE 'Error starting LDAP Connector at operating system level' TYPE 'E'.
ELSE.
  MESSAGE 'Connector is now UP with restarting' TYPE 'I'.
ENDIF.
To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply