cancel
Showing results for 
Search instead for 
Did you mean: 

Program to execute BLT in xMII from SAP R/3

vivekkrishnan
Active Participant
0 Kudos

Hi all,

This an extension of [Calling Services and Queries in SAP xMII 11.5 from ABAP|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9f101377-0c01-0010-269f-c3ee905d583b] by Bimal Mehta.

I have made the code ready to use since it takes lot of time to have the declaration and checking and all.

Can anyone tell me how to post this as a Blog or in the Wiki ?



REPORT  ZCALL_XMII_TRANS                              .

parameters: p_trans(50) type c ,			" xMII Transaction
            p_rfcdes    type rfcdest DEFAULT 'SAP_XMII'," RFC Destination Created
            p_user(10)  type c ,			" xMII User Name
            p_pass(10)  type c .			" xMII Password

* Data Declaration for RFC Connection

data : i_rfc_destination type rfcdest.
data : client type ref to IF_HTTP_CLIENT .

* Data Declaration for Path, UserName, Password

data : path type string.

data:  if_query_field type TIHTTPNVP with header line,
       it_query_field type TIHTTPNVP .
data:  i_user_name(5),
* Transaction to be called in SAP xMII
       i_transaction type string,
* Password of xMII
       i_user_password type string,
       if_str  type string,
       if_query type string.

* This method checks for Existing RFC Connection of Name
* i_rfc_destination and passes the parameters to CLIENT

* Assign Parameters to Variables

i_transaction     = p_trans.
i_rfc_destination = p_rfcdes.
i_user_name       = p_user.
i_user_password   = p_pass.

CALL METHOD
  CL_HTTP_CLIENT=>CREATE_BY_DESTINATION
  EXPORTING
    DESTINATION              = i_rfc_destination
  IMPORTING
    CLIENT                   = client
  EXCEPTIONS
    ARGUMENT_NOT_FOUND       = 1
    DESTINATION_NOT_FOUND    = 2
    DESTINATION_NO_AUTHORITY = 3
    PLUGIN_NOT_ACTIVE        = 4
    INTERNAL_ERROR           = 5
    others                   = 6.
IF SY-SUBRC <> 0.

  write: / 'Destination Not Found'.

ENDIF.

* set request method

CALL METHOD client->request->set_header_field
  EXPORTING
    name  = '~request_method'
    value = 'GET'.

*build request path to XAcute Transaction

path = '/Runner'.

clear if_query_field.
if_query_field-name = 'OutputParameter'.
if_query_field-value = '*'.
append if_query_field to it_query_field.

clear if_query_field.
if_query_field-name = 'Transaction'.
* This is the Business Logic Transaction to be called in xMII
if_query_field-value = i_transaction.
append if_query_field to it_query_field.

if not i_user_name is initial.
  if_query_field-name = 'XacuteLoginName'.
* User name for the xMII
  if_query_field-value = i_user_name.                 " User Name
  append if_query_field to it_query_field.

  if_query_field-name = 'XacuteLoginPassword'.
  perform get_password
  using i_user_password
  changing if_str.
  if_query_field-value = if_str.
  append if_query_field to it_query_field.

endif.

* build query string
if_query = cl_http_utility=>fields_to_string( fields = it_query_field
                                              encode = 0 ).

* build path

*/Runner?OutputParameter=*&Transaction=<Transaction Name>
* &XacuteLoginName=<uname>&XacuteLoginPassword=<password>


concatenate path '?' if_query into path.
condense path.

* Sets Header Field for the method with the Path
    CALL METHOD client->request->set_header_field
      EXPORTING
        name  = '~request_uri'
        value = path.

* send request
    call method client->send
      EXCEPTIONS
        http_communication_failure = 1
        others                     = 4.
    if sy-subrc <> 0.
      call method client->close( ).
      WRITE / 'HTTP_COMMUNICATION_FAILURE'.
    endif.

* get response
    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->close( ).
      WRITE  / 'HTTP_COMMUNICATION_FAILURE'.
    endif.

    call method client->close( ).
    if sy-subrc <> 0.
      write 'NO_XML_DOCUMENT'.
    else.
      write:  / 'Execution Completed'.
    endif.

*&---------------------------------------------------------------------*
*& Form get_password
*&---------------------------------------------------------------------*
* get password string from base64 encoded value
*----------------------------------------------------------------------*
* -->i_password_encoded: encoded password
* <--e_password: decoded password
*----------------------------------------------------------------------*
FORM get_password USING i_password
CHANGING e_password.
  data: i_pwd type string,
  e_pwd type string.
  i_pwd = i_password.
  e_pwd = cl_http_utility=>decode_base64( encoded = i_pwd ).
  e_password = e_pwd.
ENDFORM. " get_password

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos
vivekkrishnan
Active Participant
0 Kudos

Thanks udayan ...