ABAP to content server check

A content server can be used to store attachments and other documents. In some cases both the ABAP stack and content server are up and running, but the connection between the two is broken for some reason.

This blog will provide a check program which you can plan in a batch job to check the connection between the ABAP stack content repository and the the content server.

Questions that will be answered in this blog are:

  • How can I automate the content server check?
  • How can I be alerted if the connection between ABAP stack and content server is broken?

The OAC0 connection check

In transaction OAC0 for maintaining the content server link there is a check button:

We will use the function module SCMS_HTTP_PING which is behind this button for our custom code ABAP test program.

Custom code ABAP check program for testing the ABAP to content server connection

Load this ABAP code into your system and create the texts:

*&---------------------------------------------------------------------*
*& Report ZCSCHECK
*&---------------------------------------------------------------------*
REPORT ZCSCHECK.

DATA: z_ok TYPE boolean.
CONSTANTS: c_mesid      TYPE char3 VALUE 'ZZZ', "system log message ID defined in SE92
           c_zero       TYPE string VALUE '0 ',
           c_secirity_n TYPE c VALUE 'N',
           c_secirity_s TYPE c VALUE 'S'.
PARAMETERS p_crep TYPE scms_crep MATCHCODE OBJECT h_crep_http.

* initialize ok code
  z_ok = abap_true.

*Fetch http server details
  SELECT SINGLE crep_id, http_serv, http_port, http_sport, http_scrpt, version
         FROM   crep_http INTO @DATA(ls_crep)
         WHERE  crep_id = @p_crep.
  IF sy-subrc EQ 0.
    IF NOT ls_crep-http_port CO c_zero OR
            ls_crep-http_sport CO c_zero.
      CALL FUNCTION 'SCMS_HTTP_PING'
        EXPORTING
          crep_id    = ls_crep-crep_id
          http_serv  = ls_crep-http_serv
          http_port  = ls_crep-http_port
          http_sport = ls_crep-http_sport
          http_scrpt = ls_crep-http_scrpt
          version    = ls_crep-version
          security   = c_secirity_n"'N'
        EXCEPTIONS
          error_http = 1
          OTHERS     = 2.
      IF sy-subrc <> 0.
        z_ok = abap_false. "not ok
      ENDIF.
    ENDIF.
*Check Security with S
    IF z_ok <> abap_false AND NOT ls_crep-http_sport CO c_zero.
      CALL FUNCTION 'SCMS_HTTP_PING'
        EXPORTING
          crep_id    = ls_crep-crep_id
          http_serv  = ls_crep-http_serv
          http_port  = ls_crep-http_port
          http_sport = ls_crep-http_sport
          http_scrpt = ls_crep-http_scrpt
          version    = ls_crep-version
          security   = c_secirity_n"'S'
        EXCEPTIONS
          error_http = 1
          OTHERS     = 2.
      IF sy-subrc <> 0.
        z_ok = abap_false. "not ok
      ENDIF.
    ENDIF.

    IF z_ok = abap_false. "not ok
* write to SM21 system log
      WRITE: / TEXT-004. "ping not ok
      CALL FUNCTION 'RSLG_WRITE_SYSLOG_ENTRY'
        EXPORTING
          sl_message_area    = c_mesid(2)
          sl_message_subid   = c_mesid+2
          data_word1         = ls_crep-crep_id
        EXCEPTIONS
          data_missing       = 1
          data_words_problem = 2
          other_problem      = 3
          pre_params_problem = 4
          OTHERS             = 5.

      IF sy-subrc EQ 0.
        WRITE: / TEXT-001  , ls_crep-crep_id. "succes to write to SM21
      ELSE.
        WRITE: / TEXT-002  , ls_crep-crep_id. "fail to write to SM21
      ENDIF.
    ELSE.
      WRITE: / TEXT-003  ,  ls_crep-crep_id. "ping ok
    ENDIF.
  ELSE.
    WRITE: / TEXT-004  ,  ls_crep-crep_id. "Ping to webservice not ok
  ENDIF.

The program uses function module SCMS_HTTP_PING to test the connection. In case of issues it will write an entry to the application log. Use SE92 to create a new system log message. You can choose to replace this code by sending a mail or do anything else.

Running the check program

Running the program is simple:

If the connection fails it writes an entry to SM21.

In case you have multiple content repositories to check: create multiple variants and run the program in background with multiple steps.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.