Requirement:
In complex requirement where ECC system was creating multiple file and the requirement is like PI should start picking those file only once all the files are placed.

Initial Approach:

Initially we thought of going with Trigger file mechanism where we define an additional file in File List parameter, with same name as the source file name(only file extention needs to be different.)

Limitaion.

It works with a single file and with static file name.

On further digging we realised that we can levarage the External Control Option provided by SAP in such situation for starting/stopping channel.

Approach:

Step 1: We need to set “External Control On”

Image1.PNG

After Switching On the External Control for the Communication Channel we can Control this Communication Channel Externally.

Step 2: After this we have to write an executable report in ECC system that can start and stop the communication channel.

*&———————————————————————*
*& Report  Z_COMM_CHANNEL_START_STOP
*&
*&———————————————————————*

REPORT  Z_COMM_CHANNEL_START_STOP.
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.

“Set this v_url parameter as per your requirement(wether you want to start the channel or stop or just want the status)
“Get comm channel status
*V_URL = ‘/AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=Test_CommChannel_ExtCtrl&action=status’.

“Start comm channel
v_url
= http://host:port/AdapterFramework/ChannelAdminServlet?party=*&service=*&channel=CC_File_Merch_Recv&action=start.

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

call method CL_HTTP_CLIENT=>CREATE
 
exporting
    HOST              
= ‘host’         “PI system name
    SERVICE           
= ‘port’         “PI Port number
*      PROXY_HOST         =
*      PROXY_SERVICE      =
*      SCHEME             = SCHEMETYPE_HTTP
*      SSL_ID             =
*      SAP_USERNAME       =
*      SAP_CLIENT         =
 
importing
   
CLIENT             = CLIENT
 
exceptions
    ARGUMENT_NOT_FOUND
= 1
    PLUGIN_NOT_ACTIVE 
= 2
    INTERNAL_ERROR    
= 3
   
others             = 4.

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

*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            
= ”        “PI System Username
      PASSWORD            
= ”  .     “PI System 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 SYSUBRC <> 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 SYSUBRC <> 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.

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

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

*&———————————————————————*

Step 3: This reports needs to be called at the end of the report from where multiple files has been created.

Through this approach we can easily control SAP PI channel and start/stop as per the requirement from ECC end.

Regards,

Pradeep

To report this post you need to login first.

4 Comments

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

Leave a Reply