Professional Documents
Culture Documents
Applies To:
SAP NW 04 XI 3.0 and SAP R/3 4.6C and above
Summary
In the SAP Exchange Infrastructure (XI), the HTTP adapter is native to the Integration Server (IS). A sender HTTP Adapter need not be configured in XI. HTTP messages can be sent to the native HTTP adapter of XI. There is a browser-based tool already available for this purpose. This article describes an ABAP-based tool for acting as the sender HTTP adapter. By: Bhanumurthy Thirumala Company: Intelligroup, Inc. Date: 07 February 2006
Table of Contents
Applies To:........................................................................................................................................1 Summary ..........................................................................................................................................1 Table of Contents .............................................................................................................................1 Introduction.......................................................................................................................................2 Description of the ABAP program for HTTP Client ..........................................................................2 Selection Screen of the program ..................................................................................................2 Explanation of the Selection Screen Fields ..................................................................................4 Runtime behavior..........................................................................................................................5 Program Constraints.....................................................................................................................6 Source Code of the ABAP program for HTTP Client .......................................................................7 Texts needed for the ABAP program for HTTP Client ...................................................................14 Selection Texts ...........................................................................................................................14 Text Elements .............................................................................................................................14 Browser-based HTTP Client...........................................................................................................15 Author Bio.......................................................................................................................................15 Disclaimer & Liability Notice ...........................................................................................................15
2006 SAP AG
Introduction
The HTTP adapter can be used for sending a payload to XI without SOAP envelope. It is native to the Integration Server (IS) in XI. Consequently, there is no need to configure a sender HTTP Adapter in XI. Browser-based tools are already available for sending HTTP messages to the native HTTP adapter of XI. However, an ABAP-based tool can have certain advantages over the browser-based tool, if the sending system is based on SAP. This article describes an ABAP-based tool for acting as the sender HTTP adapter. There may be valid business reasons for the SAP-based sending system to use a HTTP adapter, such as: o o o Ability to send messages to several SAP systems in the same format Minimum efforts in configuration and maintenance Automate the sending process
Some advantages of using an ABAP-based HTTP Client as compared to the browser-based tool: o o o o o o Save different variants of selection screen for different receivers Possibility to Schedule automated jobs to send messages from XML files Provision to integrate the application into the business events of the back-end ERP system In-line Text Editor that can be used for editing the Payload Helpful in testing any Receiver Adapter Can be enhanced to include logging the errors to a file and any custom validations on the Payload contents and communication data
2006 SAP AG
Variants can be created and used as needed for each receiver. For example:
2006 SAP AG
Explanation of the Selection Screen Fields Here is an explanation of the fields: Field Integration Server Host&Port Quality of Service Description The XI Integration Servers <Host>:<Port> Allowed values: o BE (Best Effort) o EO (Exactly Once) o EOIO (Exactly Once In Order) SAP Client of the XI system User to access the XI system client o Defaults to XIAPPLUER o If different, the user should have the same roles as XIAPPLUER Password for the user access to the XI system client Logon language for the user access to XI system client, Defaults to DE Sender Party, Optional
Client User
2006 SAP AG
If the option Insert Payload as Text is chosen, a Text editor appears as follows, where the payload can be entered, edited or pasted.
Runtime behavior When executed successfully, the results of the program run appear as in the following example. This example uses an Asynchronous call (QoS = EO). For Synchronous calls (QoS = BE), the results will be reported as in the internal table GT_RESPONSE_ENTITY_BODY.
2006 SAP AG
When executed with errors, the results of the program run appear as in the following example. This example uses an Asynchronous call (QoS = EO), with a wrong Sender Service, resulting in errors during Receiver Determination in XI.
Program Constraints o When uploading the payload from a file, the line width has a limit of 1024 characters. Any characters in a line after position 1024 will be truncated. The password is not encrypted on the selection screen, for easier administration. If needed, code can be modified to encrypt this.
2006 SAP AG
2006 SAP AG
case, " Sender Party case, " Sender Scheme case, " Sender Agency case obligatory, " Sender Service case obligatory, " Sender Interface Namespace type C lower case obligatory. " Sender Interface
C C C C C
selection-screen end of block SENDER_INFO. * Payload selection-screen begin of block PAYLOAD with frame title TEXT-S04. selection-screen begin of line. parameters: P_PAYFIL radiobutton group PAYL default 'X' user-command PAYL. selection-screen comment 3(20) TEXT-S05. selection-screen position 28. parameters: P_PAYTXT radiobutton group PAYL. selection-screen comment 31(25) TEXT-S06. selection-screen end of line. * Payload from File parameters: P_FILE type RLGRAP-FILENAME modif id FIL, " File P_LCL radiobutton group FILE default 'X' modif id " File P_APP radiobutton group FILE modif id FIL. " File selection-screen end of block PAYLOAD. selection-screen end of block HTTP_CLIENT. *---------------------------------------------------------------------* at selection-screen. *---------------------------------------------------------------------* G_UCOMM = SY-UCOMM. if G_UCOMM = 'PAYL'. if P_PAYTXT = 'X'. editor-call for GT_PAYLOAD title 'Payload Text'(001) backup into GT_PAYLOAD. clear: P_FILE. endif. endif. *---------------------------------------------------------------------* at selection-screen on value-request for P_FILE. *---------------------------------------------------------------------* perform FILENAME_HELP using P_FILE. *---------------------------------------------------------------------* at selection-screen output. *---------------------------------------------------------------------* if G_UCOMM = 'PAYL'.
2006 SAP AG
2006 SAP AG
* * * *
1 2 3 4 5 6 7.
if SY-SUBRC <> 0. message id SY-MSGID type SY-MSGTY number SY-MSGNO with SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. else. write:/ 'Response from HTTP Post:'(004) color 1. uline. skip 1. write:/ 'Status Code:'(005) color 1, 20 G_STATUS_CODE, / 'Status Text:'(006) color 1, 20 G_STATUS_TEXT. uline. if GT_RESPONSE_HEADERS is not initial. skip 1. write:/ 'Response Header:'(007) color 1. uline.
2006 SAP AG
call function 'GUI_UPLOAD' exporting FILENAME FILETYPE has_field_separator tables DATA_TAB exceptions FILE_OPEN_ERROR FILE_READ_ERROR NO_BATCH GUI_REFUSE_FILETRANSFER INVALID_TYPE NO_AUTHORITY UNKNOWN_ERROR BAD_DATA_FORMAT HEADER_NOT_ALLOWED SEPARATOR_NOT_ALLOWED HEADER_TOO_LONG UNKNOWN_DP_ERROR ACCESS_DENIED DP_OUT_OF_MEMORY DISK_FULL DP_TIMEOUT others
if SY-SUBRC <> 0. message I499(SY) with 'File upload failed'(009) L_FILENAME. stop. endif.
2006 SAP AG
* Read the file from Application server else. open dataset L_FILENAME for input in text mode encoding default. if SY-SUBRC = 0. do. read dataset L_FILENAME into LT_PAYLOAD. if SY-SUBRC = 0. append LT_PAYLOAD. clear LT_PAYLOAD. else. exit. endif. enddo. close dataset L_FILENAME. else. message I499(SY) with 'File upload failed'(009) L_FILENAME. stop. endif. endif. endform. "PAYLOAD_FROM_FILE
*&---------------------------------------------------------------------* *& Form FILENAME_HELP *&---------------------------------------------------------------------* * Search Help for File name *----------------------------------------------------------------------* form FILENAME_HELP using L_FILE type RLGRAP-FILENAME. data: L_FIELDNAME type DYNPREAD-FIELDNAME, L_APP type CHAR01, LS_FIELDLIST type DYNPREAD, LT_FIELDLIST type table of DYNPREAD. *Read the screen to get the Application Server indicator LS_FIELDLIST-FIELDNAME = 'P_APP'. append LS_FIELDLIST to LT_FIELDLIST. LS_FIELDLIST-FIELDNAME = 'P_FILE'. append LS_FIELDLIST to LT_FIELDLIST. call function 'DYNP_VALUES_READ' exporting DYNAME = SY-CPROG DYNUMB = SY-DYNNR tables DYNPFIELDS = LT_FIELDLIST exceptions INVALID_ABAPWORKAREA = 1 INVALID_DYNPROFIELD = 2 INVALID_DYNPRONAME = 3 INVALID_DYNPRONUMMER = 4 INVALID_REQUEST = 5 NO_FIELDDESCRIPTION = 6 INVALID_PARAMETER = 7
2006 SAP AG
if SY-SUBRC <> 0. message I499(SY) with 'Selection Screen could not be read'(010). elseif not LT_FIELDLIST[] is initial. read table LT_FIELDLIST into LS_FIELDLIST with key FIELDNAME = 'P_APP'. if SY-SUBRC = 0. move LS_FIELDLIST-FIELDVALUE to L_APP. endif. read table LT_FIELDLIST into LS_FIELDLIST with key FIELDNAME = 'P_FILE'. if SY-SUBRC = 0. move LS_FIELDLIST-FIELDVALUE to L_FILE. endif. endif. *File Name search if L_APP = 'X'. data: L_SERVER type MSXXLIST-NAME, L_PATH type DXFIELDS-LONGPATH. L_PATH = L_FILE. * Derive the associated Application Server name call function 'FIND_DB_APPLICATION_SERVER' importing SERVERNAME = L_SERVER exceptions NO_APPLICATION_SERVER = 1 others = 2. if SY-SUBRC <> 0. message I499(SY) with 'No application server name defined'(012). endif. call function 'F4_DXFILENAME_TOPRECURSION' exporting I_LOCATION_FLAG = 'X' I_SERVER = L_SERVER I_PATH = L_PATH FILEMASK = '*.*' FILEOPERATION = 'R' importing O_LOCATION_FLAG = O_SERVER = O_PATH = L_PATH ABEND_FLAG = exceptions RFC_ERROR = 1 ERROR_WITH_GUI = 2 others = 3 . if SY-SUBRC <> 0. message I499(SY) with 'File name search help failed.'(011).
* * *
2006 SAP AG
Text Elements
001 002 003 004 005 006 Payload Text Enter a File Name Payload is empty Response from HTTP Post: Status Code: Status Text:
2006 SAP AG
Author Bio
Bhanumurthy Thirumala is a SAP Technical Consultant with 7 years of SAP experience, currently working with Intelligroup as Principal Consultant. He is also a SAP certified XI consultant.
2006 SAP AG