sap xi - abap proxy communication client proxy

17
ABAP Proxy Communication (Client Proxy) For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com SAP XI Scenario ABAP Proxy Communication (Client Proxy) Brought to you by

Upload: sapramya

Post on 12-Nov-2014

9.246 views

Category:

Documents


11 download

DESCRIPTION

SAP XI - ABAP Proxy Communication Client Proxy

TRANSCRIPT

Page 1: SAP XI - ABAP Proxy Communication Client Proxy

ABAP Proxy Communication (Client Proxy)

For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com

SAP XI Scenario

ABAP Proxy Communication (Client Proxy)

Brought to you by

Page 2: SAP XI - ABAP Proxy Communication Client Proxy

ABAP Proxy Communication (Client Proxy)

For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com

By Neeraja Surapaneni, YASH Technologies

This document is focused to give a better understanding on ABAP client proxies.

From WAS 6.20 onwards, proxy generation feature enables application systems to communicate with XI using proxies.

Proxy objects implement message interfaces from Integration Repository. Proxy generation converts non-language-specific interface descriptions in WSDL into executable interfaces in the application system. Proxies separate Business Application logic from the integration logic of the Exchange infrastructure.

There are 2 types of proxies available.

1. Java Proxies 2. ABAP Proxies.

1. Java Proxies: - Java proxies are used when JAVA applications needs to send or receive messages with other applications. JAVA proxies are generated from the WSDL description of the interface in the Integration Repository, and the result is a .jar file containing generated java classes corresponding to the integration objects.

2. ABAP Proxies: - ABAP proxies are used when ABAP applications needs to send or receive messages. ABAP proxies are generated on the Application server with transaction SPROXY, based on the WSDL representation of the message interface.

The type of the message interface determines what type of proxy is generated. The counterparts to outbound message interface in application systems are client proxies, these are called to send a message to inbound interface. And the counterparts of inbound message interface in application systems are server proxies.

Advantages of ABAP Proxies.

1. Proxy communication always by passes the Adapter Engine and will directly interact with the application system and Integration engine. So it will give us better performance.

2. Proxies communicate with the XI server by means of native SOAP calls over HTTP. 3. Easy to handle messages with ABAP programming. 4. Proxy is good for large volumes of data. we can catch and persist the errors ( both

system & application fault ) which was generated by Proxy setting

The rest of the document gives you pre-requisites and steps that are necessary for generating and executing ABAP client proxies.

Pre-requisites

1. The business systems should be based on SAP Web AS 6.20 and SAP Web AS 6.20 kernel patch level above 1253

2. You have installed the XI Add-On in each of these business systems as described in the Installation Guide SAP Exchange Infrastructure 3.0

3. The business systems and your central Integration Server are maintained in the System Landscape Directory (SLD).

Page 3: SAP XI - ABAP Proxy Communication Client Proxy

ABAP Proxy Communication (Client Proxy)

For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com

Steps required for developing ABAP Proxies

• Establish the connection between WAS and Integration Builder, this allows the application system to retrieve WSDL description of the interface as the basis of proxy generation.

• Create a source data type and a target data type. • Create Message types for the source and target data types. • Create Message Interfaces includes Inbound Message interface and Outbound Message

interface. • Create message mapping between the source and target message types. • Create Interface mapping. • Create ABAP proxies using the transaction SPROXY in the application system. • Create Collaboration agreements and Collaboration profiles in Integration directory. • Write a program in the application system for creating the client proxy request.

Scenario demonstrating ABAP Client Proxies. Take a business scenario where in business (Source System) sends an Employee details to their Payroll system for calculating the monthly salaries of their employees. But here the source business is running on SAP R/3 and corresponding Payroll system is not on SAP, hence the interpretation of data/communication is different. Because source system sends employee information through proxy communication and the target Payroll system is not aware of these proxy call, so in order to provide a communication between these two we need some interface mechanism which accepts proxy request and converts it into the format understandable by the target payroll system and vice versa.

Objects needed to be developed in IR

For this scenario we need to create the corresponding Data types, Message types and Message interfaces for source and target messages. Once the source Message interface is created we can generate the interface in source R/3 system using SPROXY transaction.

Page 4: SAP XI - ABAP Proxy Communication Client Proxy

ABAP Proxy Communication (Client Proxy)

For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com

Page 5: SAP XI - ABAP Proxy Communication Client Proxy

ABAP Proxy Communication (Client Proxy)

For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com

Page 6: SAP XI - ABAP Proxy Communication Client Proxy

ABAP Proxy Communication (Client Proxy)

For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com

In this demo scenario, there is slight variance in source and target messages. From the source we will get First name and last name where as target will accommodate only one full name and also source will send the annual salary whereas target will have the field Monthly salary. Hence required mapping should be done.

Page 7: SAP XI - ABAP Proxy Communication Client Proxy

ABAP Proxy Communication (Client Proxy)

For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com

Save it.

Page 8: SAP XI - ABAP Proxy Communication Client Proxy

ABAP Proxy Communication (Client Proxy)

For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com

Now activate all the objects that are developed in IR.

Before starting the configurations in the Integration directory, let us complete the creation of client proxies in source R/3 system.

Creating ABAP Proxies in Application system

Go to SPROXY transaction in R/3 system.

Here we can see all the Integration Repository objects. Select the outbound interface for which we want to create the proxy. Right click on the interface and select create option.

ABAP proxy will generate the following objects.

Page 9: SAP XI - ABAP Proxy Communication Client Proxy

ABAP Proxy Communication (Client Proxy)

For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com

We can observe the Structures resembling outbound data types, message types get created in the system. As the source structure can send multiple records of Employee, observe that a Table type of ZTDT_EMPDET_OB_EMPLOYEE_TAB getting created. This can be transferred to FTP.

Page 10: SAP XI - ABAP Proxy Communication Client Proxy

ABAP Proxy Communication (Client Proxy)

For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com

Activate the generated proxy.

For creating ABAP client proxy request we need to call the execute_asynchronous method of this class. This method will take the input as of type ZTMT_EMPDET_OB.

To fill the employee details we need to create the structure of type ZTDT_EMPDET_OB_EMPLOYEE and table of type

ZTDT_EMPDET_OB_EMPLOYEE_TAB.

After filling the internal table finally we need to move this to

ZTMT_EMPDET_OB- MT_EMPDET_OB-EMPLOYEE

Objects that need to be developed in ID

First we need to create communication channels for sender and receiver. Here it is not required to create sender communication channel as we are using proxies in the sender side for communication. We need to create Receiver communication channel to place the file with employee details in the FTP server.

Page 11: SAP XI - ABAP Proxy Communication Client Proxy

ABAP Proxy Communication (Client Proxy)

For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com

The next step in the Integration directory is we need to create Sender agreement, receiver agreement, interface determination and Receiver determination. But in our scenario it is not required to create sender agreement.

Page 12: SAP XI - ABAP Proxy Communication Client Proxy

ABAP Proxy Communication (Client Proxy)

For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com

Testing the Scenario.

In order to test the scenario we need to develop an ABAP Report to trigger a client proxy. The following report is executed in the SE38 Editor for triggering an ABAP Proxy. *&---------------------------------------------------------------------* *& Report Z_SEND_EMP_DETAILS *& *&---------------------------------------------------------------------* *& Published at SAPTechnical.com *& *&---------------------------------------------------------------------* REPORT Z_SEND_EMP_DETAILS. TABLES: PA0001. DATA: PRXY TYPE REF TO ZTCO_MI_EMPDET_OB, FS_EMPLOYEE TYPE ZTDT_EMPDET_OB_EMPLOYEE, T_EMPLOYEE TYPE ZTDT_EMPDET_OB_EMPLOYEE_TAB, FS_EMPLOYEE_MT TYPE ZTMT_EMPDET_OB. DATA: BEGIN OF I_PA0000 OCCURS 0, PERNR LIKE PA0000-PERNR, MASSN LIKE PA0000-MASSN, END OF I_PA0000, BEGIN OF I_PA0001 OCCURS 0, PERNR LIKE PA0000-PERNR, WERKS LIKE PA0001-WERKS, " Personnel Area PERSG LIKE PA0001-PERSG, " Employee Group PERSK LIKE PA0001-PERSK, " Employee Subgroup BTRTL LIKE PA0001-BTRTL, " Personnel Subarea

Page 13: SAP XI - ABAP Proxy Communication Client Proxy

ABAP Proxy Communication (Client Proxy)

For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com

ABKRS LIKE PA0001-ABKRS, " Payroll Area KOSTL LIKE PA0001-KOSTL, " Cost Center ORGEH LIKE PA0001-ORGEH, " Organizational Unit PLANS LIKE PA0001-PLANS, " Position END OF I_PA0001, BEGIN OF I_PA0002 OCCURS 0, PERNR LIKE PA0000-PERNR, NACHN LIKE PA0002-NACHN, " Last Name VORNA LIKE PA0002-VORNA, " First Name GESCH LIKE PA0002-GESCH, " Gender Key GBDAT LIKE PA0002-GBDAT, " Date of Birth END OF I_PA0002, BEGIN OF I_PA0007 OCCURS 0, PERNR LIKE PA0000-PERNR, SCHKZ LIKE PA0007-SCHKZ, " Work Schedule Rule ARBST LIKE PA0007-ARBST, " Daily Working Hours END OF I_PA0007, BEGIN OF I_PA0008 OCCURS 0, PERNR LIKE PA0000-PERNR, TRFAR LIKE PA0008-TRFAR, " Pay scale type TRFGB LIKE PA0008-TRFGB, " Pay Scale Area TRFGR LIKE PA0008-TRFGR, " Pay Scale Group TRFST LIKE PA0008-TRFST, " Pay Scale Level STVOR LIKE PA0008-STVOR, " Date of Next Increase WAERS LIKE PA0008-WAERS, " Currency Key ANSAL LIKE PA0008-ANSAL, " Annual salary LGA01 LIKE PA0008-LGA01, " Wage Type BET01 LIKE PA0008-BET01, " Wage Type Amount for Payments ANZ01 LIKE PA0008-ANZ01, " Number LGA02 LIKE PA0008-LGA02, " Wage Type BET02 LIKE PA0008-BET02, " Wage Type Amount for Payments ANZ02 LIKE PA0008-ANZ02, " Number LGA03 LIKE PA0008-LGA03, " Wage Type BET03 LIKE PA0008-BET03, " Wage Type Amount for Payments ANZ03 LIKE PA0008-ANZ03, " Number END OF I_PA0008, BEGIN OF I_PA0009 OCCURS 0, PERNR LIKE PA0000-PERNR, ZLSCH LIKE PA0009-ZLSCH, " Payment Method BANKS LIKE PA0009-BANKS, " Bank country key BANKL LIKE PA0009-BANKL, " Bank Keys BANKN LIKE PA0009-BANKN, " Bank account number BKONT LIKE PA0009-BKONT, " Bank Control Key END OF I_PA0009. TRY. CREATE OBJECT PRXY. ENDTRY. SELECT-OPTIONS: S_PERNR FOR PA0001-PERNR. START-OF-SELECTION. SELECT PERNR " Personnel number MASSN FROM PA0000 INTO TABLE I_PA0000 WHERE PERNR IN S_PERNR AND ENDDA GE SY-DATUM AND BEGDA LE SY-DATUM

Page 14: SAP XI - ABAP Proxy Communication Client Proxy

ABAP Proxy Communication (Client Proxy)

For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com

AND STAT2 EQ '3'. SELECT PERNR " Personnel number WERKS " Personnel Area PERSG " Employee Group PERSK " Employee Subgroup BTRTL " Personnel Subarea ABKRS " Payroll Area KOSTL " Cost Center ORGEH " Organizational Unit PLANS " Position FROM PA0001 INTO TABLE I_PA0001 WHERE PERNR IN S_PERNR AND ENDDA GE SY-DATUM AND BEGDA LE SY-DATUM. SELECT PERNR " Personnel number NACHN " Last Name VORNA " First Name GESCH " Gender Key GBDAT " Date of Birth FROM PA0002 INTO TABLE I_PA0002 WHERE PERNR IN S_PERNR AND ENDDA GE SY-DATUM AND BEGDA LE SY-DATUM. SELECT PERNR " Personnel number SCHKZ " Work Schedule Rule ARBST " Daily Working Hours FROM PA0007 INTO TABLE I_PA0007 WHERE PERNR IN S_PERNR AND ENDDA GE SY-DATUM AND BEGDA LE SY-DATUM. SELECT PERNR " Personnel number TRFAR " Pay scale type TRFGB " Pay Scale Area TRFGR " Pay Scale Group TRFST " Pay Scale Level STVOR " Date of Next Increase WAERS " Currency Key ANSAL " Annual salary LGA01 " Wage Type BET01 " Wage Type Amount for Payments ANZ01 " Number LGA02 " Wage Type BET02 " Wage Type Amount for Payments ANZ02 " Number LGA03 " Wage Type BET03 " Wage Type Amount for Payments ANZ03 " Number FROM PA0008 INTO TABLE I_PA0008 WHERE PERNR IN S_PERNR AND ENDDA GE SY-DATUM AND BEGDA LE SY-DATUM. SELECT PERNR " Personnel number ZLSCH " Payment Method

Page 15: SAP XI - ABAP Proxy Communication Client Proxy

ABAP Proxy Communication (Client Proxy)

For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com

BANKS " Bank country key BANKL " Bank Keys BANKN " Bank account number BKONT " Bank Control Key FROM PA0009 INTO TABLE I_PA0009 WHERE PERNR IN S_PERNR AND ENDDA GE SY-DATUM AND BEGDA LE SY-DATUM. SORT: I_PA0000 BY PERNR, I_PA0001 BY PERNR, I_PA0002 BY PERNR, I_PA0007 BY PERNR, I_PA0008 BY PERNR. REFRESH T_EMPLOYEE. LOOP AT I_PA0000. CLEAR FS_EMPLOYEE. FS_EMPLOYEE-PERSONNEL_NUMBER = I_PA0000-PERNR. FS_EMPLOYEE-ACTION_TYPE = I_PA0000-MASSN. READ TABLE I_PA0001 WITH KEY PERNR = I_PA0000-PERNR BINARY SEARCH. IF SY-SUBRC EQ 0. FS_EMPLOYEE-EMP_GROUP = I_PA0001-PERSG. FS_EMPLOYEE-EMP_SUBGROUP = I_PA0001-PERSK. FS_EMPLOYEE-PERSONNEL_SUBAREA = I_PA0001-BTRTL. FS_EMPLOYEE-PAYROLL_AREA = I_PA0001-ABKRS. FS_EMPLOYEE-COST_CENTER = I_PA0001-KOSTL. FS_EMPLOYEE-ORGANIZATIONAL_UNIT = I_PA0001-ORGEH. FS_EMPLOYEE-POSITION = I_PA0001-PLANS. ENDIF. READ TABLE I_PA0002 WITH KEY PERNR = I_PA0000-PERNR BINARY SEARCH. IF SY-SUBRC EQ 0. FS_EMPLOYEE-LASTNAME = I_PA0002-NACHN. FS_EMPLOYEE-FIRST_NAME = I_PA0002-VORNA. FS_EMPLOYEE-GENDER = I_PA0002-GESCH. FS_EMPLOYEE-DOB = I_PA0002-GBDAT. ENDIF. READ TABLE I_PA0007 WITH KEY PERNR = I_PA0000-PERNR BINARY SEARCH. IF SY-SUBRC EQ 0. FS_EMPLOYEE-WORK_SCHEDULE_RULE = I_PA0007-SCHKZ. FS_EMPLOYEE-DAILY_WORKING_HOURS = I_PA0007-ARBST. ENDIF. READ TABLE I_PA0008 WITH KEY PERNR = I_PA0000-PERNR BINARY SEARCH. IF SY-SUBRC EQ 0. FS_EMPLOYEE-PAY_SCALE_TYPE = I_PA0008-TRFAR. FS_EMPLOYEE-PAY_SCALE_AREA = I_PA0008-TRFGB. FS_EMPLOYEE-PAY_SCALE_GROUP = I_PA0008-TRFGR. FS_EMPLOYEE-PAY_SCALE_LEVEL = I_PA0008-TRFST. FS_EMPLOYEE-INCREASE_DATE = I_PA0008-STVOR. FS_EMPLOYEE-CURRENCY = I_PA0008-WAERS. FS_EMPLOYEE-ANNUAL_SALARY = I_PA0008-ANSAL. FS_EMPLOYEE-WAGE_TYPE1 = I_PA0008-LGA01. FS_EMPLOYEE-AMOUNT1 = I_PA0008-BET01. FS_EMPLOYEE-NUMBER1 = I_PA0008-ANZ01. FS_EMPLOYEE-WAGE_TYPE2 = I_PA0008-LGA02. FS_EMPLOYEE-AMOUNT2 = I_PA0008-BET02. FS_EMPLOYEE-NUMBER2 = I_PA0008-ANZ02. FS_EMPLOYEE-WAGE_TYPE3 = I_PA0008-LGA03.

Page 16: SAP XI - ABAP Proxy Communication Client Proxy

ABAP Proxy Communication (Client Proxy)

For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com

FS_EMPLOYEE-AMOUNT3 = I_PA0008-BET03. FS_EMPLOYEE-NUMBER3 = I_PA0008-ANZ03. ENDIF. READ TABLE I_PA0009 WITH KEY PERNR = I_PA0000-PERNR BINARY SEARCH. IF SY-SUBRC EQ 0. FS_EMPLOYEE-PAYMENT_METHOD = I_PA0009-ZLSCH. FS_EMPLOYEE-BANK_COUNTRY = I_PA0009-BANKS. FS_EMPLOYEE-BANK_KEYS = I_PA0009-BANKL. FS_EMPLOYEE-BANK_ACCOUNT_NUMBER = I_PA0009-BANKN. FS_EMPLOYEE-BANK_CONTROL_KEY = I_PA0009-BKONT. ENDIF. APPEND FS_EMPLOYEE TO T_EMPLOYEE. ENDLOOP. TRY. FS_EMPLOYEE_MT-MT_EMPDET_OB-EMPLOYEE = T_EMPLOYEE. CALL METHOD PRXY->EXECUTE_ASYNCHRONOUS EXPORTING OUTPUT = FS_EMPLOYEE_MT. COMMIT WORK . CATCH CX_AI_SYSTEM_FAULT . DATA FAULT TYPE REF TO CX_AI_SYSTEM_FAULT . CREATE OBJECT FAULT. WRITE :/ FAULT->ERRORTEXT. ENDTRY. When this report is executed, we can see the file in the FTP server with the employee details. <?xml version="1.0" encoding="UTF-8" ?> - <ns0:MT_Empdet_ib xmlns:ns0="http://yash-clientproxies"> - <Employee> <Personnel_number>00001002</Personnel_number> <Action_Type>52</Action_Type> <Emp_Group>1</Emp_Group> <Emp_Subgroup>DT</Emp_Subgroup> <Personnel_Subarea /> <Payroll_Area>D2</Payroll_Area> <Cost_Center>0000002100</Cost_Center> <Organizational_Unit>50000563</Organizational_Unit> <Position>50000083</Position> <Name>Ulrike Zaucker</Name> <Gender>2</Gender> <DOB>19600905</DOB> <Work_Schedule_Rule>FLEX</Work_Schedule_Rule> <Daily_Working_Hours>7.50</Daily_Working_Hours> <Pay_scale_type>40</Pay_scale_type> <Pay_Scale_Area>02</Pay_Scale_Area> <Pay_Scale_Group>AT</Pay_Scale_Group> <Pay_Scale_Level /> <Increase_date>00000000</Increase_date> <Currency>EUR</Currency> <Monthly_salary>0</Monthly_salary> <Wage_Type1>MA90</Wage_Type1> <Amount1>4601.63</Amount1> <Number1>0.00</Number1> <Wage_Type2 />

Page 17: SAP XI - ABAP Proxy Communication Client Proxy

ABAP Proxy Communication (Client Proxy)

For more tips, tutorials, Interview questions, certification questions, please visit SAPTechnical.com

<Amount2>0.00</Amount2> <Number2>0.00</Number2> <Wage_Type3 /> <Amount3>0.00</Amount3> <Number3>0.00</Number3> <Payment_Method>U</Payment_Method> <Bank_country>DE</Bank_country> <Bank_Keys>23984899</Bank_Keys> <Bank_account_number>253571587</Bank_account_number> <Bank_Control_Key /> </Employee> </ns0:MT_Empdet_ib>

Please visit SAPTechnical.com for more scenarios on XI:

• XSLT Mapping • IDOC-to-IDOC Scenario • File-to-File Scenario with SLD and Monitoring Status • Publishing Interface as Web Service (Web Service to RFC Scenario) • Monitoring of XML Message Queues in the R/3 system • ABAP Proxy communication Scenario (Server Proxy) • RFC-to-Web Service Scenario • IDoc-to-File Scenario • How-to-do Alert Configuration in XI • Time Bound File Processing - File to IDoc Scenario • Collect Multiple IDOCs to File using BPM • Useful information regarding SAP XI