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,            " 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
     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
         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>
 

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image