3 Ways of Retrieving Infotype Data with ABAP

Aditya Aufar
2 min readMar 8, 2022

--

Straight Out Selecting

There are many ways to retrieve Infotype data in SAP HCM from ABAP code. One of way the Infotype data can be retrieved is by using Query from the related Infotype table. This approach perhaps the most straightforward one. The syntax looks something like this:

In the example above, the current Infotype 1 Data with the subtype 001 of employee with Personnel Number 10 is retrieved.

Wrapped in Function Module

Another approach is probably one of the most popular way to retrieve Infotype data. It utilized the standard Function Module that provided by SAP called “HR_READ_INFOTYPE”. By following the same scenario as previous approach (same parameter), the Function Module can be called like this

By using this Function Module, at least we can utilize the EXCEPTIONS or error handling that are predefined from the Function Module. This approach might need a bit more codes to get the job done but considered relatively more efficient then the previous approach since this is the tool that provided by SAP.

Object Oriented with Classes

The third approach is using Object Oriented approach. This approach similar to the previous approach since it also utilized the standard codes from SAP in a form of Classes. The steps of using this approach are as follow:

  1. Create the instance of the infotype object reader.

2. Get the Infotype data by calling the method of the object reader instance that just been created above. Assign the parameters by following the same scenario as the previous approach with the Employee’s Personnel Number, Infotype, Subtype, Begin Date and End Date with the addition of some required parameters such as SRPS, OBJPS, etc.

3. Then to store the data into internal table, use the following Class.

This approach can results in even more codes but Object Oriented has its advantages over the procedural in some cases. That’s why it’s always important to acknowledge some alternatives for doing one task.

Encapsulate the Classes

I decided to create a custom ABAP Class to encapsulate all the Classes used in the previous approach to make it neater. By utilizing this global class instead, hopefully your code can look a lot more nicer and cleaner. You can see the repository here : https://github.com/aufaraditya/ABAP-INFTY-VALUE

Hopefully this post is useful in any way.

--

--