Вы находитесь на странице: 1из 16

ABAP Proxy Communication Scenario (Client Proxy)

By Neeraja Surapaneni, YASH PI Competency Core Team, 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 nonlanguage-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.
Also Read ABAP Proxy Communication (Server Proxy)
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).

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.

Click here to continue...

ABAP Proxy Communication Scenario (Client Proxy)


...Previous
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.

Save it.
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.

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.

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.

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.

Click here to continue...

ABAP Proxy Communication Scenario (Client Proxy)


...Previous
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
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,


BET01 LIKE PA0008-BET01,
ANZ01 LIKE PA0008-ANZ01,
LGA02 LIKE PA0008-LGA02,
BET02 LIKE PA0008-BET02,
ANZ02 LIKE PA0008-ANZ02,
LGA03 LIKE PA0008-LGA03,
BET03 LIKE PA0008-BET03,
ANZ03 LIKE PA0008-ANZ03,
END OF I_PA0008,
BEGIN OF I_PA0009 OCCURS 0,
PERNR LIKE PA0000-PERNR,
ZLSCH LIKE PA0009-ZLSCH,
BANKS LIKE PA0009-BANKS,
BANKL LIKE PA0009-BANKL,
BANKN LIKE PA0009-BANKN,
BKONT LIKE PA0009-BKONT,
END OF I_PA0009.
TRY.
CREATE OBJECT PRXY.
ENDTRY.
SELECT-OPTIONS:
S_PERNR FOR PA0001-PERNR.
START-OF-SELECTION.
SELECT PERNR
MASSN
FROM PA0000
INTO TABLE I_PA0000
WHERE PERNR IN S_PERNR
AND ENDDA GE SY-DATUM
AND BEGDA LE SY-DATUM
AND STAT2 EQ '3'.
SELECT PERNR
WERKS
PERSG
PERSK
BTRTL
ABKRS
KOSTL
ORGEH
PLANS
FROM PA0001
INTO TABLE I_PA0001
WHERE PERNR IN S_PERNR
AND ENDDA GE SY-DATUM
AND BEGDA LE SY-DATUM.
SELECT PERNR
NACHN
VORNA
GESCH
GBDAT
FROM PA0002
INTO TABLE I_PA0002
WHERE PERNR IN S_PERNR
AND ENDDA GE SY-DATUM
AND BEGDA LE SY-DATUM.
SELECT PERNR
SCHKZ
ARBST
FROM PA0007
INTO TABLE I_PA0007
WHERE PERNR IN S_PERNR
AND ENDDA GE SY-DATUM

"
"
"
"
"
"
"
"
"

Wage Type
Wage Type Amount for Payments
Number
Wage Type
Wage Type Amount for Payments
Number
Wage Type
Wage Type Amount for Payments
Number

"
"
"
"
"

Payment Method
Bank country key
Bank Keys
Bank account number
Bank Control Key

" Personnel number

"
"
"
"
"
"
"
"
"

Personnel number
Personnel Area
Employee Group
Employee Subgroup
Personnel Subarea
Payroll Area
Cost Center
Organizational Unit
Position

"
"
"
"
"

Personnel number
Last Name
First Name
Gender Key
Date of Birth

" Personnel number


" Work Schedule Rule
" Daily Working Hours

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
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.
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 />
<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>

Вам также может понравиться