2023 Dec 05 5:33 PM - edited 2024 Apr 21 12:21 PM
Hi there,
I would like to know if there is a possibility to determine all classes of a class pool using RTTI in ABAP.
It should be possible to determine all containing class in both directions:
Starting from global class -> local class(es) -> local test class(es).
Starting from local test class(es) -> local class(es) -> global class.
I would also prefer a solution without using the namens of the classes as identifying parameters, e.g. I could extract the name of the global class by using the field ABSOLUTE_NAME. That's not the solution I am looking for.
Nice would be something like this, starting from a local test class:
METHOD my_test.
DATA(class_descriptor) = CAST cl_abap_classdescr( cl_abap_classdescr=>describe_by_oref( me ) ).
DATA(global_class) = class_descriptor->global_class.
ENDMETHOD.
BR
2023 Dec 05 7:02 PM
Probably RTTS is not relevant for doing such a thing. RTTS is to help working with ABAP types, not to scan the internal parts of a type. Of course, you have other solutions which don't imply RTTS.
2023 Dec 06 6:55 AM
sandra.rossi
Of course, you have other solutions which don't imply RTTS.
For example?
2023 Dec 06 7:33 AM
You have limited the question to RTTS, it's why I didn't elaborate.
Quickly, by "of course", I meant all you could think of primarily like what is done by where-used list in ABAP editor, ABAP Unit framework, Code Inspector (used by ATC), etc., all implying reading and parsing ABAP source code. I'll elaborate later but I guess other people will reply to this second question.
2023 Dec 06 9:12 AM
Did you try to use a class such as CL_ABAP_COMPILER which allows some xref usage identificaion.
2023 Dec 06 4:24 PM
the question is, why do you need to find those classes by reflection? Or could the problem (that we do not know so far) be solved by a smart design of the related classes itself?
2023 Dec 08 5:35 PM
raymond.giuseppi
Did you try to use a class such as CL_ABAP_COMPILER which allows some xref usage identificaion.
Not yet. I did not know this SAP class before! Thanks for the hint.
holm.kettner
the question is, why do you need to find those classes by reflection?
I want to write smart and reusable unit tests for several enumeration classes. In general the unit tests should do checks on the containing attribute of the public class and other use cases. Therefore I need to know the name of the public class and also the ones of their local classes at run time.
BR