Menu

ABAP Workbench Tricks #4: Find Out Internal Names of SAP Class Objects

DevWorkbench    Friday August 8th, 2014   

How often have you looked at your screen and thought “darn, if only I knew which class method this error comes from”? The hidden internal naming of class objects like methods is sometimes a problem. Read in this post how you can find out the internal names of ABAP class methods.

The problem with ABAP class includes

The class builder is a beautiful thing. It hides all the messy code from developers that is necessary to define and implement a class in ABAP. All we coders get to see is a pretty, abstracted interface. We can graphically define most properties of class or interface methods and parameters and only very rarely need to look at the actual coding. All we need to do is write the source code that makes the class work within.

However, what if there’s a problem? If you’ve ever run the extended code check for a class method, you know there’s an issue. All you get displayed are the internal, auto-generated include names that your class method came from. You don’t really know what’s what, and that’s not very nice.

Extended Code Check Result

The extended code check result is useless without knowing the include names.

Also, sometimes there’s a valid reason for having to look at the actual, un-abstracted program code – for example when you want to implement a custom code inspector check. The class builder makes it hard (or rather, impossible) to do this, and its pretty graphical interface is laughing at us mockingly.

How to find out the internal name of class methods

But there must be something we can do! Well, of course there is. Funnily enough, the solution to this issue with classes is – a class. Specifically,  it’s the ABAP class CL_OO_INCLUDE_NAMING, which provides methods that allow you to find out the internal names of the class building blocks.

Of course, you could write a program to call the methods of this class, but it’s much easier to just open the class in the class builder (transaction SE24). Start the test environment by clicking the wrench icon or pressing F8. A popup will appear, asking you to enter a type or field length for a generically typed parameter. Enter the value “30” for the length.

Popup in ABAP Class Builder

Enter “30” here to proceed.

In the list of class methods that is displayed now, find the method GET_INSTANCE_BY_NAME and click the little Execute button next to it. Provide the class name you’re working with as a parameter, execute, and… wait, what?

Well, it’s not that easy. This method returns an object of type CL_OO_INCLUDE_NAMING – yes, that’s the same class we’re already in. To proceed, click the little grey circle (ball icon) next to the return value. You’re taken to the object details. This object has three interfaces as values. Click on the little detail button next to the interface IF_OO_CLASS_INCL_NAMING.

Interface IF_OO_CLASS_INCL_NAMING

Interface IF_OO_CLASS_INCL_NAMING

Still with me? From this interface, you can already see a bit of information, such as the internal name of the includes for different sections of the class. To see a list of names for all class methods, execute the object method GET_ALL_METHOD_INCLUDES. You are now – finally – presented with a list that contains a mapping of method names to their respective includes.

The other methods might be interesting as well. Using the method GET_INCLUDE_BY_SECTION, you can get the include names for the public, protected and private sections of the class. To do that, execute the method and use the following constants.

  • CPUB – Public section
  • CPRO – Protected section
  • CPRI – Private section

How to find the class method for an include in SAP

So, what if we want to do it the other way round – find out which method is in a specific class include? Luckily, that’s a much easier task. There are several possibilities to do that:

  • Open SE38 and enter the include name. The system will automatically open the class builder with the correct method.
  • In SE80, click the Other object (other object icon) icon. Change to the Function Group tab, and enter the include name in the appropriate field. Again, you will be taken to the class builder and the respective method will be opened.

That’s it for this topic! Hope it helps you to make your development better.