[ABAP] KPRO: Prüfen, ob Verbindung zum Content-Repository eingerichtet ist

CONSTANTS: c_none TYPE string VALUE '0 '.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE title.
* CR
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT (17) lbl1 FOR FIELD p_crep.
    PARAMETERS: p_crep TYPE scms_crep MATCHCODE OBJECT h_crep_http.
  SELECTION-SCREEN END OF LINE.
* 'N'
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT (17) lbl2 FOR FIELD p_rbs1.
    PARAMETERS: p_rbs1 RADIOBUTTON GROUP rbg DEFAULT 'X'.
  SELECTION-SCREEN END OF LINE.
* 'S'
  SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT (17) lbl3 FOR FIELD p_rbs2.
    PARAMETERS: p_rbs2 RADIOBUTTON GROUP rbg.
  SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK b1.

INITIALIZATION.

  title = 'Auswahl'.
  lbl1 = 'Content Repository:'.
  lbl2 = 'Security (N):'.
  lbl3 = 'Security (S):'.

START-OF-SELECTION.
* CREP_HTTP (KPRO CMS: Content-Repositories (HTTP))
  SELECT SINGLE
    FROM crep_http
    FIELDS crep_id,
           http_serv,
           http_port,
           http_sport,
           http_scrpt,
           version
    WHERE crep_id = @p_crep
    INTO @DATA(lv_crep).

  IF sy-subrc EQ 0.
    IF NOT lv_crep-http_port CO c_none OR lv_crep-http_sport CO c_none.

      DATA(lv_sec) = 'N'.

* Security-Typ unterscheiden
      CASE abap_true.
        WHEN p_rbs1.
          lv_sec = 'N'.
        WHEN p_rbs2.
          lv_sec = 'S'.
      ENDCASE.

* CMS: HTTP Verbindungstest
      CALL FUNCTION 'SCMS_HTTP_PING'
        EXPORTING
          crep_id    = lv_crep-crep_id
          http_serv  = lv_crep-http_serv
          http_port  = lv_crep-http_port
          http_sport = lv_crep-http_sport
          http_scrpt = lv_crep-http_scrpt
          version    = lv_crep-version
          security   = lv_sec
        EXCEPTIONS
          error_http = 1
          OTHERS     = 2.

      IF sy-subrc = 0.
        WRITE: / |{ lv_crep-crep_id } ok.|.
      else.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO DATA(lv_msg).
        WRITE: / lv_msg.
      ENDIF.
    ELSE.
      WRITE: / 'No port.'.
    ENDIF.
  ELSE.
    WRITE: / 'No CS.'.
  ENDIF.