Thursday 10 September 2020

Easy way to create custom country-specific replication classes in the PTP framework

Introduction


When you try to replicate a person from EC to ECPY, then you may face a lot of difficulties like dealing with Pay Frequencies, storing information in a new subtype of an infotype, manipulating the employee data after the parsing of the XML.

SAP has provided country-specific standard replication classes & BADIs infotype wise, for that purpose. But, they are having less flexibility.

I have come across a similar situation like this, So, I am writing this blog post so that, it can help others to achieve their requirements through custom classes.

Solution


First of all, we should know how the PTP framework works. In the PTP framework, there are two tables namely ‘HRSFEC_CNTRY’, which is an SAP standard table. The table contains country-specific replication classes.

Please check the below screenshot for further reference.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

There is another table that SAP has kept for the customers ‘HRSFEC_CNTRY_CC’. The table generally remains blank but this can be used according to our needs.

SAP has created this table ‘HRSFEC_CNTRY_CC’  for the countries for whom there is no replication class created. People can enter the country ISO code, the Replication Type & the name of the custom class to perform replication.

There are two important classes namely: ‘

1. CL_HRSFEC_EE_MDR_BNDL_PROC
2. CL_HRSFEC_EE_MDR_MAIN.

Class ‘CL_HRSFEC_EE_MDR_BNDL_PROC’ handles the incoming API response and saves the data in the infotype framework.

The class ‘CL_HRSFEC_EE_MDR_BNDL_PROC’ is called first when we try to replicate an employee through the report ‘RP_HRSFEC_PTP_EE_REPLICATION’(It sends the outgoing API call to Employee Central).

This class identifies the country/molga of the employee & calls the relevant class from HRSFEC_CNTRY/HRSFEC_CNTRY_CC  table.

If no country-specific relevant class is found, the main class ’CL_HRSFEC_EE_MDR_MAIN’ is called for the replication.

If you notice properly, you will be able to see that  ’CL_HRSFEC_EE_MDR_MAIN’  is the superclass of all the country-specific classes.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

In the case of the country-specific classes, the name of the classes is suffixed by the country ISO code.

General format: CL_HRSFEC_EE_MDR_MAIN_XX, where the XX is the Country ISO code.

So, for AE, the name will be CL_HRSFEC_EE_MDR_MAIN_AE.

BADI like ‘HRSFEC_B_CE_PROCESS_EMPLOYEE‘ can also be used to incase of custom requirements. All you have to do is to use the enhancement spot ‘HRSFEC_CE_MASTER_DATA_REPL’.

Please check the below screenshot for further details.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

Now, if implementing these BADIs is not fulfilling your needs then, you can go with the option of overwriting the SAP standard class with the custom class.

To overwrite the standard class, you need to do the following steps.

1. Create a custom class using code SE24.

2. Make ’CL_HRSFEC_EE_MDR_MAIN’ as the superclass of the custom class. As a result of this, all the methods will be inherited in the custom class.

3. Now, go to the editable mode by Ctrl+F1.

4. Select the method in which you want to do the change & then click on redefine. As a result of this, you will be able to add codes to the method according to your needs & that will suppress the original code method of the superclass

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

5. Activate the class & the methods.

6. Go to SE16 & provide the table name: ‘HRSFEC_CNTRY_CC’.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

7. Click on Create entries & new entires & provide the name of the newly created custom class.

SAP ABAP Tutorial and Material, SAP ABAP Learning, SAP ABAP Certification, SAP ABAP Exam Prep

8. Save the change in a customizing TR.

That’s it. It’s done.

Every time you try to replicate the employee the country-specific standard class will be bypassed & the methods of the custom class will be called accordingly.

If you are providing a custom class name in the customer table: ‘HRSFEC_CNTRY_CC’  for a country & if an entry regarding the same country exists in the standard table of SAP: ‘HRSFEC_CNTRY’ with the same replication type, the class in the customer table gets the priority first.

No comments:

Post a Comment