SAP Process Orchestration, SAP Process Integration

SAP PI/PO Communication Channel Tool

Purpose

In this blog post I will show you how can you work this a new communication channel tool in order to start or stop a channel in SAP PO from a SAP ABAP Program.

My system

My System: SAP S/4HANA 1909 and SAP PO 7.5

SAP Note relevant

2691666 – How to extract PI Communication Channel list

Steps

1. You need to create a new program in the sap transaction SE38 as you can see in the developer system.

Write the name of the program, change the attributes/Type as “Executable program” and click on SAVE

SAP Process Orchestration, SAP Process Integration

In the following window you can select a Package and a transportation request or you just can select Local Object.

2. Paste the following code and activate it.

*&---------------------------------------------------------------------*
*& Report  ZPO_TOOL_CHANNEL.
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&INFORMATION
*&WRICEF                 :   001
*&Program                :   ZPO_TOOL CHANNEL
*&Títle                  :   ZPO_TOOL CHANNEL
*&Autor                  :   Freddy Valderrama
*&Date                   :   26.04.2021 10:58:37
*&Description            :   Program for administration of communications channel of SAP PO, you can START or STOP a channel with double click in the name of channel.
*&                           with double click in the first four lines you can, stop all the channel, start all the channel,
*&                           download the current status or update with the previus saved status.
*&Prerequisites          :   it is necessary the communication channel has the control data in the communication channel monitor in External
*&*************************************************************************


REPORT  ZPO_TOOL_CHANNEL.

INCLUDE <icon>.
INCLUDE <symbol>.

DATA: v_url  TYPE string,
      client TYPE REF TO if_http_client.
DATA: response_code TYPE  sysubrc,
      response_text TYPE  string.
DATA: fields_tab    TYPE tihttpnvp,
      status_code   TYPE string,
      status_reason TYPE string,
      number        TYPE i.
DATA: w_result   TYPE string,
      result_tab TYPE TABLE OF string,
      result_wa  LIKE LINE OF result_tab.
DATA : lv_file_string TYPE xstring,
       te_t_xml_data  TYPE TABLE OF smum_xmltb,
       te_return      TYPE TABLE OF bapiret2,
       ls_return      TYPE bapiret2.
DATA: BEGIN OF ls_w_zgraymarketinfo ,
        party           TYPE string,
        service         TYPE string,
        channelname     TYPE string,
        adaptertype     TYPE string,
        channelstate    TYPE string,
        activationstate TYPE string,
        color           TYPE lvc_t_scol,
      END OF ls_w_zgraymarketinfo.
DATA: BEGIN OF ls_w_zgraymarketinfos ,
        party           TYPE string,
        service         TYPE string,
        channelname     TYPE string,
        adaptertype     TYPE string,
        channelstate    TYPE string,
        activationstate TYPE string,
      END OF ls_w_zgraymarketinfos.
DATA: te_t_zgraymarketinfo  LIKE STANDARD TABLE OF ls_w_zgraymarketinfo,
      te_t_zgraymarketinfo2 LIKE STANDARD TABLE OF ls_w_zgraymarketinfo,
      te_t_zgraymarketinfos LIKE STANDARD TABLE OF ls_w_zgraymarketinfos,
      ls_s_zgraymarketinfo  LIKE ls_w_zgraymarketinfo.
DATA :xml_table    TYPE TABLE OF smum_xmltb,
      ls_xml_table TYPE smum_xmltb,
      return       TYPE TABLE OF  bapiret2.
DATA gr_table TYPE REF TO cl_salv_table.
DATA functions TYPE REF TO cl_salv_functions_list.
DATA: l_text TYPE string,
      l_icon TYPE string.
DATA g_dsp TYPE REF TO cl_salv_display_settings.
DATA gr_columns  TYPE REF TO cl_salv_columns_table.
DATA column  TYPE REF TO cl_salv_column.
DATA lo_sorts TYPE REF TO cl_salv_sorts.
DATA: ls_color               TYPE lvc_s_scol.
DATA: lr_layout TYPE REF TO cl_salv_layout,
      ls_key    TYPE        salv_s_layout_key,
      l_repid   TYPE        sy-repid.
DATA: lr_columns TYPE REF TO cl_salv_columns.
DATA: lr_display TYPE REF TO cl_salv_display_settings.
DATA: gr_layout TYPE REF TO cl_salv_layout.
DATA: key TYPE salv_s_layout_key.
DATA: lo_header  TYPE REF TO cl_salv_form_layout_grid,
      lo_h_label TYPE REF TO cl_salv_form_label,
      lo_h_flow  TYPE REF TO cl_salv_form_layout_flow.
DATA lv_lines TYPE i.
DATA s_slddest TYPE sld_s_accessdata_display.

DATA: lv_start TYPE string VALUE 'START'.
DATA: lv_stop TYPE string VALUE 'STOP'.
DATA: lv_download TYPE string VALUE 'DOWNLOAD'.
DATA: lv_upload TYPE string VALUE 'UPLOAD AND ***UPDATE***'.

DEFINE titulo.
  &2 = &1->get_column( &3 ).
  &2->set_short_text( &4 ).
  &2->set_medium_text( &5 ).
  &2->set_long_text( &6 ).
  &2->set_output_length( &7 ).
END-OF-DEFINITION.

DEFINE set_color.
  ls_color-fname     = &1.
  ls_color-color-col = &2.
  ls_color-color-int = &3.
  ls_color-color-inv = &4.
  APPEND ls_color TO ls_w_zgraymarketinfo-color.
END-OF-DEFINITION.

CLASS lcl_datos DEFINITION.
  PUBLIC SECTION.
    METHODS:

      on_user_command FOR EVENT added_function OF cl_salv_events
        IMPORTING e_salv_function,

      double_click
                    FOR EVENT double_click OF cl_salv_events_table
        IMPORTING row.

ENDCLASS.

DATA lr_events TYPE REF TO cl_salv_events_table.
DATA  gr_events      TYPE REF TO lcl_datos.

CLASS lcl_datos IMPLEMENTATION.
  METHOD double_click.
    DATA lv_strig0 TYPE string.
    DATA lv_strig TYPE string.
    DATA lv_new_state TYPE string.
    DATA: ls_is_stable          TYPE lvc_s_stbl.
    DATA: gd_nom_archivo TYPE string,
          ld_filename    TYPE string,
          ld_path        TYPE string,
          ld_fullpath    TYPE string,
          ld_result      TYPE i.
    DATA: BEGIN OF gs_line_salida,
            line TYPE string,
          END OF gs_line_salida.
    DATA gt_line_salida  LIKE TABLE OF gs_line_salida.
    DATA ti_file    TYPE filetable.
    DATA wa_file    TYPE LINE OF filetable.
    CONSTANTS: lv_stop(7) VALUE 'STOP'.
    CONSTANTS: lv_start(7) VALUE 'START'.


    CHECK row IS NOT INITIAL.
    READ TABLE te_t_zgraymarketinfo INTO ls_w_zgraymarketinfo INDEX row.
    CASE ls_w_zgraymarketinfo-service.
      WHEN lv_start.
        lv_strig = ' ?'.
        lv_strig0 = '¿Alert!!!: Do you want to "' && lv_start &&  '" all channels'.
        lv_new_state = lv_start.
        PERFORM ask_change_mass USING lv_strig0 lv_strig lv_new_state row.
      WHEN lv_stop.
        lv_strig = ' ?'.
        lv_strig0 = '¿Alert!!!: Do you want to "' && lv_stop &&  '" all channels'.
        lv_new_state = lv_stop.
        PERFORM ask_change_mass USING lv_strig0 lv_strig lv_new_state row.
      WHEN lv_download.
        gd_nom_archivo = 'Backup_Tool_Channel_' && sy-datum && '-' && sy-uzeit && '.txt'.
* Display save dialog window
        CALL METHOD cl_gui_frontend_services=>file_save_dialog
          EXPORTING
            window_title      = 'Download File with all Channels'
            default_extension = 'txt'
            file_filter       = '(*.txt)'
            default_file_name = gd_nom_archivo
            initial_directory = 'c:\'
          CHANGING
            filename          = ld_filename
            path              = ld_path
            fullpath          = ld_fullpath
            user_action       = ld_result.

        gd_nom_archivo = ld_fullpath.

        CLEAR te_t_zgraymarketinfos[].
        LOOP AT te_t_zgraymarketinfo INTO ls_w_zgraymarketinfo.
          MOVE-CORRESPONDING ls_w_zgraymarketinfo TO ls_w_zgraymarketinfos.
          APPEND ls_w_zgraymarketinfos TO te_t_zgraymarketinfos.
        ENDLOOP.

        CALL METHOD cl_gui_frontend_services=>gui_download
          EXPORTING
            filename              = gd_nom_archivo
            write_field_separator = 'X'
          CHANGING
            data_tab              = te_t_zgraymarketinfos.

        MESSAGE i398(00) WITH 'Was saved the file:' ld_filename.

      WHEN lv_upload.
        CALL METHOD cl_gui_frontend_services=>file_open_dialog
          EXPORTING
            window_title     = 'Select File'
            default_filename = '*.txt'
            multiselection   = ''
          CHANGING
            file_table       = ti_file
            rc               = ld_result.

        READ TABLE ti_file INTO  wa_file INDEX 1.
        CHECK sy-subrc IS INITIAL.
        gd_nom_archivo = wa_file-filename.
        CLEAR te_t_zgraymarketinfos[].

        CALL METHOD cl_gui_frontend_services=>gui_upload
          EXPORTING
            filename                = gd_nom_archivo
            has_field_separator     = 'X'
          CHANGING
            data_tab                = te_t_zgraymarketinfos
          EXCEPTIONS
            file_open_error         = 1
            file_read_error         = 2
            no_batch                = 3
            gui_refuse_filetransfer = 4
            invalid_type            = 5
            no_authority            = 6
            unknown_error           = 7
            bad_data_format         = 8
            header_not_allowed      = 9
            separator_not_allowed   = 10
            header_too_long         = 11
            unknown_dp_error        = 12
            access_denied           = 13
            dp_out_of_memory        = 14
            disk_full               = 15
            dp_timeout              = 16
            OTHERS                  = 17.
        IF te_t_zgraymarketinfos[] IS INITIAL.
          MESSAGE i398(00) WITH 'Error or File Empty...'.
        ELSE.
          lv_strig = ''.
          lv_strig0 = '¿Alert!!!: Do you want to UPDATE all channels ?'.
          PERFORM ask_change_mass_update USING lv_strig0 lv_strig lv_new_state row.
        ENDIF.
      WHEN OTHERS.
        IF ls_w_zgraymarketinfo-activationstate EQ 'STARTED'.
          lv_strig = ls_w_zgraymarketinfo-channelname && ' ?'.
          lv_strig0 = '¿Do you want to "' && lv_stop &&  '" the channel:'.
          lv_new_state = lv_stop.
        ELSE.
          lv_strig = ls_w_zgraymarketinfo-channelname && ' ?'.
          lv_strig0 = '¿Do you want to "' && lv_start &&  '" the channel:'.
          lv_new_state = lv_start.
        ENDIF.

        PERFORM ask_change USING lv_strig0 lv_strig lv_new_state row.
    ENDCASE.

    ls_is_stable-row = 'X'.
    ls_is_stable-col = 'X'.

    CALL METHOD gr_table->refresh
      EXPORTING
        s_stable = ls_is_stable.

  ENDMETHOD.                    "on_double_click
  METHOD on_user_command.

  ENDMETHOD.
ENDCLASS.                    "lcl_event_handler IMPLEMENTATION

PARAMETERS: host TYPE string. "" DEFAULT 'SAPPOD'.
PARAMETERS: port TYPE string. "" DEFAULT '50000'.
PARAMETERS: user TYPE string DEFAULT sy-uname.
PARAMETERS: password TYPE string LOWER CASE OBLIGATORY.

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    IF screen-name = 'PASSWORD'.
      screen-invisible = '1'.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.
  IF host IS INITIAL.
    CALL FUNCTION 'SLDAPI_GET_PRIMARY_DEST'
      IMPORTING
        dest                 = s_slddest
      EXCEPTIONS
        no_primary_available = 1.
    host = s_slddest-host.
    port = s_slddest-port.
  ENDIF.

START-OF-SELECTION.


  v_url = 'http://' && host &&':' && port && '/AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=*&action=STATUS'.
  PERFORM call_service.
  PERFORM move_data.


END-OF-SELECTION.

  IF te_t_zgraymarketinfo[] IS NOT INITIAL.
    PERFORM call_alv.
  ELSE.
    MESSAGE i398(00) WITH 'No CC found...'.
  ENDIF.

FORM call_service.

  CLEAR client.
  CALL METHOD cl_http_client=>create
    EXPORTING
      host               = host
      service            = port
    IMPORTING
      client             = client
    EXCEPTIONS
      argument_not_found = 1
      plugin_not_active  = 2
      internal_error     = 3
      OTHERS             = 4.

*set header fields
  CALL METHOD client->request->set_header_field
    EXPORTING
      name  = '~request_method'
      value = 'POST'.

  CALL METHOD client->request->set_header_field
    EXPORTING
      name  = 'Content-Type'
      value = 'application/xml'.
  ""*; charset=utf-8′ .

*Set request protocol
  CALL METHOD client->request->set_header_field
    EXPORTING
      name  = '~server_protocol'
      value = 'HTTP/1.0'.

*Update url
  CALL METHOD client->request->set_header_field
    EXPORTING
      name  = '~request_uri'
      value = v_url.

*Disable logon popup
  client->propertytype_logon_popup = client->co_disabled.
  CALL METHOD client->authenticate
    EXPORTING
      username = user
      password = password.


  cl_http_utility=>set_request_uri( request = client->request  uri = response_text ).

*Send http request to server
  CALL METHOD client->send
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3
      OTHERS                     = 4.

  IF sy-subrc <> 0.
    CALL METHOD client->get_last_error
      IMPORTING
        code    = response_code
        message = response_text.

    MESSAGE i000(sr) WITH response_text.

    EXIT.
  ENDIF.

*Get http response from server
  CALL METHOD client->receive
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3
      OTHERS                     = 4.
  IF sy-subrc <> 0.

    CALL METHOD client->get_last_error
      IMPORTING
        code    = response_code
        message = response_text.

    status_code = client->response->get_header_field( '~status_code' ).
    status_reason = client->response->get_header_field( '~status_reason' ).
    CONCATENATE response_text '(' status_code status_reason ')'
    INTO status_reason SEPARATED BY space.

    MESSAGE i000(sr) WITH status_reason.

    EXIT.
  ENDIF.

  CLEAR: w_result.
  w_result = client->response->get_cdata( ).
  REFRESH result_tab.
  SPLIT w_result AT cl_abap_char_utilities=>newline INTO TABLE result_tab.

  CLEAR lv_file_string.
  CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    EXPORTING
      text   = w_result
    IMPORTING
      buffer = lv_file_string
    EXCEPTIONS
      failed = 1
      OTHERS = 2.

  CLEAR: xml_table[], te_return[].
  CALL FUNCTION 'SMUM_XML_PARSE'
    EXPORTING
      xml_input = lv_file_string
    TABLES
      xml_table = xml_table
      return    = te_return.

  IF te_return[] IS NOT INITIAL.
    READ TABLE te_return INTO ls_return WITH KEY type = 'E'.
    IF sy-subrc IS INITIAL.
      MESSAGE i398(00) WITH 'ERROR: with parameters or credentials...'.
      STOP.
    ENDIF.
  ENDIF.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form MOVE_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM move_data .

  LOOP AT xml_table INTO ls_xml_table.
    ASSIGN COMPONENT ls_xml_table-cname OF STRUCTURE ls_w_zgraymarketinfo TO FIELD-SYMBOL(<fs_val>).
    IF sy-subrc IS INITIAL AND <fs_val> IS ASSIGNED.
      <fs_val> = ls_xml_table-cvalue.
    ENDIF.
    IF ls_xml_table-cname EQ 'Control'.
      IF ls_w_zgraymarketinfo-activationstate EQ 'STARTED'.
        set_color 'ACTIVATIONSTATE'   5 0 0.
      ELSE.
        set_color 'ACTIVATIONSTATE'   6 0 0.
      ENDIF.
      IF ls_w_zgraymarketinfo-channelstate EQ 'OK'.
        set_color 'CHANNELSTATE'   5 0 0.
      ELSEIF ls_w_zgraymarketinfo-channelstate EQ 'ERROR'.
        set_color 'CHANNELSTATE'   6 0 0.
      ELSE.
        set_color 'CHANNELSTATE'   7 0 0.
      ENDIF.
      APPEND ls_w_zgraymarketinfo TO te_t_zgraymarketinfo2.
      CLEAR ls_w_zgraymarketinfo.
    ENDIF.
  ENDLOOP.

  PERFORM add_double_click_to.

  SORT te_t_zgraymarketinfo2 BY party service channelname.
  LOOP AT te_t_zgraymarketinfo2 INTO ls_w_zgraymarketinfo.
    APPEND ls_w_zgraymarketinfo TO te_t_zgraymarketinfo.
  ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CALL_ALV
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM call_alv .

  TRY.
      CALL METHOD cl_salv_table=>factory
        IMPORTING
          r_salv_table = gr_table
        CHANGING
          t_table      = te_t_zgraymarketinfo[].
    CATCH cx_salv_msg .
  ENDTRY.

  functions = gr_table->get_functions( ).
  functions->set_all( abap_true ).

  g_dsp = gr_table->get_display_settings( ).
  g_dsp->set_striped_pattern( abap_true ).

  gr_columns = gr_table->get_columns( ).
  gr_columns->set_color_column( 'COLOR' ).

  titulo gr_columns column 'PARTY'           'PARTY' 'PARTY' 'PARTY' 20.
  titulo gr_columns column 'SERVICE'         'SERVICE' 'SERVICE' 'SERVICE' 30.
  titulo gr_columns column 'CHANNELNAME'     'CHANNEL' 'CHANNEL' 'CHANNEL' 40.
  titulo gr_columns column 'ADAPTERTYPE'     'TYPE' 'TYPE' 'TYPE' 10.
  titulo gr_columns column 'ACTIVATIONSTATE' 'START/STOP' 'STARTED/STOPPED' 'STARTED/STOPPED' 20.
  titulo gr_columns column 'CHANNELSTATE'    'OK/ERR/INA' 'OK/ERROR/INACTIVE' 'OK/ERROR/INACTIVE' 20.

  key-report = sy-repid.
  gr_layout = gr_table->get_layout( ).
  gr_layout->set_key( key ).

  gr_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).


  CREATE OBJECT lo_header.
* Information in Bold
  lo_h_label = lo_header->create_label( row = 1 column = 1 ).
  lo_h_label->set_text('Comunication Channel Tool V 1.0').

* Information in tabular format
  lo_h_flow = lo_header->create_flow( row = 2 column = 1 ).
  lo_h_flow->create_text( text = 'CC Total:' ).
  lo_h_flow = lo_header->create_flow( row = 2 column = 2 ).

  lv_lines = lines( te_t_zgraymarketinfo ).
  lo_h_flow->create_text( text = lv_lines ).

  lo_h_flow = lo_header->create_flow( row = 3 column = 1 ).
  lo_h_flow->create_text( text = 'Date of List Generation' ).
  lo_h_flow = lo_header->create_flow( row = 3 column = 2 ).
  lo_h_flow->create_text( text = sy-datum ).

* Set the top of list using the header for Online
  gr_table->set_top_of_list( lo_header ).
* Set the top of list using the header for Print
  gr_table->set_top_of_list_print( lo_header ).


  lr_events = gr_table->get_event( ).
  CREATE OBJECT gr_events.
**  double click
  SET HANDLER gr_events->double_click FOR lr_events.

  gr_table->display( ).
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ASK_CHANGE
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM ask_change USING lv_strig lv_strig2 lv_new_state row.
  DATA lv_response.
  CLEAR lv_response.
  CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
    EXPORTING
      defaultoption = 'N'
      textline1     = lv_strig
      textline2     = lv_strig2
      titel         = 'Update Information?'
      start_column  = 35
      start_row     = 6
    IMPORTING
      answer        = lv_response.

  IF lv_response = 'J'. "Yes
    v_url = 'http://' && host &&':' && port && '/AdapterFramework/ChannelAdminServlet?party=' && ls_w_zgraymarketinfo-party
                      && '&service=' && ls_w_zgraymarketinfo-service && '&channel=' && ls_w_zgraymarketinfo-channelname && '&action=' && lv_new_state.
    PERFORM call_service.
    READ TABLE xml_table INTO ls_xml_table WITH KEY cname = 'ActivationState'.
    IF lv_new_state EQ 'STOP'.
      IF ls_xml_table-cvalue EQ 'STOPPED'.
        MESSAGE i398(00) WITH 'Channel:' ls_w_zgraymarketinfo-channelname ',was updated successful.'.
      ELSE.
        MESSAGE i398(00) WITH 'Channel:' ls_w_zgraymarketinfo-channelname ',was not updated.'.
      ENDIF.
    ELSE.
      IF ls_xml_table-cvalue EQ 'STARTED'.
        MESSAGE i398(00) WITH 'Channel:' ls_w_zgraymarketinfo-channelname ',was updated successful.'.
      ELSE.
        MESSAGE i398(00) WITH 'Channel:' ls_w_zgraymarketinfo-channelname ',was not updated.'.
      ENDIF.
    ENDIF.

    ls_w_zgraymarketinfo-activationstate = ls_xml_table-cvalue.
    DELETE ls_w_zgraymarketinfo-color WHERE fname EQ 'ACTIVATIONSTATE'.
    IF ls_w_zgraymarketinfo-activationstate EQ 'STARTED'.
      set_color 'ACTIVATIONSTATE'   5 0 0.
    ELSE.
      set_color 'ACTIVATIONSTATE'   6 0 0.
    ENDIF.
    MODIFY te_t_zgraymarketinfo FROM ls_w_zgraymarketinfo INDEX row.
  ENDIF.


ENDFORM.

*&---------------------------------------------------------------------*
*& Form ASK_CHANGE_MASS
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM ask_change_mass USING lv_strig lv_strig2 lv_new_state row.
  DATA lv_response.
  DATA lv_updated TYPE i.
  DATA lv_error TYPE i.
  CLEAR: lv_response, lv_updated, lv_error.
  CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
    EXPORTING
      defaultoption = 'N'
      textline1     = lv_strig
      textline2     = lv_strig2
      titel         = 'Update Information?'
      start_column  = 35
      start_row     = 6
    IMPORTING
      answer        = lv_response.

  IF lv_response = 'J'. "Yes
    LOOP AT te_t_zgraymarketinfo INTO ls_w_zgraymarketinfo WHERE party NE 'DOUBLE CLICK TO'.
      row = sy-tabix.
      v_url = 'http://' && host &&':' && port && '/AdapterFramework/ChannelAdminServlet?party=' && ls_w_zgraymarketinfo-party
                        && '&service=' && ls_w_zgraymarketinfo-service && '&channel=' && ls_w_zgraymarketinfo-channelname && '&action=' && lv_new_state.
      PERFORM call_service.
      READ TABLE xml_table INTO ls_xml_table WITH KEY cname = 'ActivationState'.
      IF lv_new_state EQ 'STOP'.
        IF ls_xml_table-cvalue EQ 'STOPPED'.
          ADD 1 TO lv_updated.
        ELSE.
          ADD 1 TO lv_error.
        ENDIF.
      ELSE.
        IF ls_xml_table-cvalue EQ 'STARTED'.
          ADD 1 TO lv_updated.
        ELSE.
          ADD 1 TO lv_error.
        ENDIF.
      ENDIF.

      ls_w_zgraymarketinfo-activationstate = ls_xml_table-cvalue.
      DELETE ls_w_zgraymarketinfo-color WHERE fname EQ 'ACTIVATIONSTATE'.
      IF ls_w_zgraymarketinfo-activationstate EQ 'STARTED'.
        set_color 'ACTIVATIONSTATE'   5 0 0.
      ELSE.
        set_color 'ACTIVATIONSTATE'   6 0 0.
      ENDIF.
      MODIFY te_t_zgraymarketinfo FROM ls_w_zgraymarketinfo INDEX row.
    ENDLOOP.
    MESSAGE i398(00) WITH lv_updated ': was updated successful AND '  lv_error ': finished with Error:'.
  ENDIF.


ENDFORM.

*&---------------------------------------------------------------------*
*& Form ASK_CHANGE_MASS_UPDATE
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM ask_change_mass_update USING lv_strig lv_strig2 lv_new_state row.
  DATA lv_response.
  DATA lv_updated TYPE i.
  DATA lv_error TYPE i.
  CLEAR lv_response.
  CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
    EXPORTING
      defaultoption = 'N'
      textline1     = lv_strig
      textline2     = lv_strig2
      titel         = 'Update Information?'
      start_column  = 35
      start_row     = 6
    IMPORTING
      answer        = lv_response.

  IF lv_response = 'J'. "Yes
    CLEAR: te_t_zgraymarketinfo[], lv_updated, lv_error.
    DELETE te_t_zgraymarketinfos  WHERE party EQ 'DOUBLE CLICK TO'.
    PERFORM add_double_click_to.
    LOOP AT te_t_zgraymarketinfos INTO ls_w_zgraymarketinfos.
      CLEAR ls_w_zgraymarketinfo.
      MOVE-CORRESPONDING ls_w_zgraymarketinfos TO ls_w_zgraymarketinfo.
      IF ls_w_zgraymarketinfo-activationstate EQ 'STARTED'.
        lv_new_state = lv_start.
      ELSE.
        lv_new_state = lv_stop.
      ENDIF.

      v_url = 'http://' && host &&':' && port && '/AdapterFramework/ChannelAdminServlet?party=' && ls_w_zgraymarketinfo-party
                        && '&service=' && ls_w_zgraymarketinfo-service && '&channel=' && ls_w_zgraymarketinfo-channelname && '&action=' && lv_new_state.
      PERFORM call_service.
      READ TABLE xml_table INTO ls_xml_table WITH KEY cname = 'ActivationState'.
      IF lv_new_state EQ 'STOP'.
        IF ls_xml_table-cvalue EQ 'STOPPED'.
          ADD 1 TO lv_updated.
        ELSE.
          ADD 1 TO lv_error.
        ENDIF.
      ELSE.
        IF ls_xml_table-cvalue EQ 'STARTED'.
          ADD 1 TO lv_updated.
        ELSE.
          ADD 1 TO lv_error.
        ENDIF.
      ENDIF.

      ls_w_zgraymarketinfo-activationstate = ls_xml_table-cvalue.
      DELETE ls_w_zgraymarketinfo-color WHERE fname EQ 'ACTIVATIONSTATE'.
      IF ls_w_zgraymarketinfo-activationstate EQ 'STARTED'.
        set_color 'ACTIVATIONSTATE'   5 0 0.
      ELSE.
        set_color 'ACTIVATIONSTATE'   6 0 0.
      ENDIF.

      APPEND ls_w_zgraymarketinfo TO te_t_zgraymarketinfo.
    ENDLOOP.
    MESSAGE i398(00) WITH lv_updated ': was updated successful AND '  lv_error ': finished with Error:'.
  ENDIF.


ENDFORM.
*&---------------------------------------------------------------------*
*& Form ADD_DOUBLE_CLICK_TO
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& -->  p1        text
*& <--  p2        text
*&---------------------------------------------------------------------*
FORM add_double_click_to .
  CLEAR ls_w_zgraymarketinfo.
  set_color 'PARTY'           5 0 0.
  set_color 'SERVICE'         5 0 0.
  set_color 'CHANNELNAME'     5 0 0.
  set_color 'ADAPTERTYPE'     5 0 0.
  set_color 'ACTIVATIONSTATE' 5 0 0.
  set_color 'CHANNELSTATE'    5 0 0.
  ls_w_zgraymarketinfo-party = 'DOUBLE CLICK TO'.
  ls_w_zgraymarketinfo-service = lv_start.
  ls_w_zgraymarketinfo-channelname = 'ALL CHANNEL'.
  APPEND ls_w_zgraymarketinfo TO te_t_zgraymarketinfo.

  CLEAR ls_w_zgraymarketinfo.
  set_color 'PARTY'           6 0 0.
  set_color 'SERVICE'         6 0 0.
  set_color 'CHANNELNAME'     6 0 0.
  set_color 'ADAPTERTYPE'     6 0 0.
  set_color 'ACTIVATIONSTATE' 6 0 0.
  set_color 'CHANNELSTATE'    6 0 0.
  ls_w_zgraymarketinfo-party = 'DOUBLE CLICK TO'.
  ls_w_zgraymarketinfo-service = lv_stop.
  ls_w_zgraymarketinfo-channelname = 'ALL CHANNEL'.
  APPEND ls_w_zgraymarketinfo TO te_t_zgraymarketinfo.

  CLEAR ls_w_zgraymarketinfo.
  set_color 'PARTY'           4 1 0.
  set_color 'SERVICE'         4 1 0.
  set_color 'CHANNELNAME'     4 1 0.
  set_color 'ADAPTERTYPE'     4 1 0.
  set_color 'ACTIVATIONSTATE' 4 1 0.
  set_color 'CHANNELSTATE'    4 1 0.
  ls_w_zgraymarketinfo-party = 'DOUBLE CLICK TO'.
  ls_w_zgraymarketinfo-service = lv_download.
  ls_w_zgraymarketinfo-channelname = 'ALL CHANNEL'.
  APPEND ls_w_zgraymarketinfo TO te_t_zgraymarketinfo.

  CLEAR ls_w_zgraymarketinfo.
  set_color 'PARTY'           3 1 0.
  set_color 'SERVICE'         3 1 0.
  set_color 'CHANNELNAME'     3 1 0.
  set_color 'ADAPTERTYPE'     3 1 0.
  set_color 'ACTIVATIONSTATE' 3 1 0.
  set_color 'CHANNELSTATE'    3 1 0.
  ls_w_zgraymarketinfo-party = 'DOUBLE CLICK TO'.
  ls_w_zgraymarketinfo-service = lv_upload.
  ls_w_zgraymarketinfo-channelname = 'ALL CHANNEL'.
  APPEND ls_w_zgraymarketinfo TO te_t_zgraymarketinfo.
ENDFORM.

3. You can now run the program.

The program take the name of SAP PO, port and the user from the configuration as you can see, just write you private password.

If all is OK you can see the list with the complete details of the communication channel.

You can see the C.C Total in SAP PO and their Status.

  1. If you do double click at one channel you will get a message from the system in order to reject or approver the change of status.
  2. If you do double click at the first green line you will get a message in order to reject or approver starting all the Communication Channels.
  3. If you do double click at the second red line you will get a message in order to reject or approver stopping all the Communication Channels.
  4. If you do double click at the their blue line you will download the current status of the all channel in order save it as backup and you can update this same status in the future.
  5. If you do double click at the yellow line you will upload and update the previous status downloaded.

Prerequisites

It is necessary the communication channel has the

control data in the communication channel monitor in External

Configuration and Monitoring Home / Monitoring / Communication Channel Monitor

Leave a Reply

Your email address will not be published.