Skip to Content
Author's profile photo Former Member

Start/Stop a communication channel from an ABAP program using the external control switch

This blog only provides instructions on how to start/stop a communication channel using an ABAP program. All other steps to have a fully functional communication channel are not provided in this blog, go to or do a search on SDN to get a guideline on that.


  1. There is a scheduled job running daily/weekly that creates an outbound file in SAP ECC
  2. There is a communication channel in SAP PI scheduled to pick up the file created and send it to an external system

By following the instructions below, the report can then be included as a step in a job scheduled in SAP ECC and therefore the communication channel scheduling in PI will not be required.

 External Control Off

In the communication channel monitoring, select the relevant commnunication channel and click on External Control Switch to allow the communication channel to be started/stopped externally. When it’s turned on, it should look as below.

External Control On

Goto SE38 to create a report and paste the code below.

report  YTEST_PRGM line-size 1023 message-id Z002.
data: V_URL type STRING,
      CLIENT type ref to IF_HTTP_CLIENT.

      NUMBER type I.

data: W_RESULT type STRING,
      RESULT_TAB type table of STRING,
      RESULT_WA like line of RESULT_TAB.

“Get comm channel status
V_URL = ‘/AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=Test_CommChannel_ExtCtrl&action=status’. 

“Start comm channel
“v_url = ‘/AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=Test_CommChannel_ExtCtrl&action=start’.  

“Stop comm channel
“v_url = ‘/AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=Test_CommChannel_ExtCtrl&action=stop’.  

    HOST               = HOST         “PI system name
    SERVICE            = SERVICE      “Port number
*      PROXY_HOST         =
*      PROXY_SERVICE      =
*      SCHEME             = SCHEMETYPE_HTTP
*      SSL_ID             =
*      SAP_USERNAME       =
*      SAP_CLIENT         =
    CLIENT             = CLIENT
    INTERNAL_ERROR     = 3
    others             = 4.

if SY-SUBRC <> 0.
  message E000 with SY-SUBRC.

*set header fields
    NAME  = ‘~request_method’
    VALUE = ‘POST’.

    NAME  = ‘Content-Type’
    VALUE = ‘application/xml’. “; charset=UTF-8′ .

*Set request protocol
    NAME  = ‘~server_protocol’
    VALUE = ‘HTTP/1.0’.

*Update url
    NAME  = ‘~request_uri’
    VALUE = V_URL.

*Disable logon popup
      USERNAME             = USERNAME        “Username
      PASSWORD             = PASSWORD        “Password

                                  URI = RESPONSE_TEXT ).
*Send http request to server
call method CLIENT->SEND
    HTTP_INVALID_STATE         = 2
    others                     = 4.
if SY-SUBRC <> 0.
  call method CLIENT->GET_LAST_ERROR
      message = RESPONSE_TEXT.

  message I000(SR) with RESPONSE_TEXT.

*Get http response from server
call method CLIENT->RECEIVE
    HTTP_INVALID_STATE         = 2
    others                     = 4.
if SY-SUBRC <> 0.
  call method CLIENT->GET_LAST_ERROR
      message = RESPONSE_TEXT.


  into STATUS_REASON separated by SPACE.
  message I000(SR) with STATUS_REASON.

*Get header_fields contents such status code, reason etc
“call method client->response->GET_HEADER_FIELDS
”   changing
”     FIELDS             =  Fields_Tab  .

clear: W_RESULT.

refresh RESULT_TAB.
loop at RESULT_TAB into RESULT_WA.
  write / RESULT_WA.

The following variables must be assigned with proper valueds:-

Host-PI system name

Service-PI system port number

Username-This must be a user in PI system with the following roles: xi_af_channel_admin_display and xi_af_channel_admin_modify

Password-PI user’s password

“Starting the communication channel
v_url = ‘/AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=Test_CommChannel_ExtCtrl&action=start’.


“Stopping communication channel
v_url = ‘/AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=Test_CommChannel_ExtCtrl&action=stop’. 


“Get communication channel status
v_url = ‘/AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=Test_CommChannel_ExtCtrl&action=status’. 

URL Parameters  


party– Identifies the party of the channel to be administered. You can use an asterisk (*) as a placeholder to administer several channels simultaneously

service– Identifies the communication component of the channel to be administered. You can use an asterisk (*) as a placeholder to administer several channels simultaneously

channel– Identifies the name of the channel to be administered. You can use an asterisk (*) as a placeholder to administer several channels simultaneously.                                                                                                                     

Action– You use the start and stop actions to start and stop the channels. You can use the status action to query the status of one or more channels.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Daniel Graversen
      Daniel Graversen
      it looks quite easy to start/stop the channels. I had never seen it before, but it is quite useful.

      Daniel Graversen

      Author's profile photo Former Member
      Former Member
      Hi Daniel,

      Yes indeed its quite easy, my customer uses it to monitor critical channels with Nagios (simple Http Request) and throws alerts (sms/mail) from it to a support team.

      Best wishes

      Author's profile photo Former Member
      Former Member
      The status info can be really useful when creating global monitoring dashboards for IT.

      Thanks a lot,

      David R.

      Author's profile photo Max Fedorovich Molochko
      Max Fedorovich Molochko
      Many thanks for this solution.
      Author's profile photo Former Member
      Former Member

      I know that the Channels can be controlled using http url..but never thought can be called using ABAP stack/reports..Helpful info.


      Author's profile photo Former Member
      Former Member


      Excellent work.


      Jannus Botha