02-03-2016 1:47 PM
In a class implementing an Interface.
eg
Class A.
Interfaces: If_cust_object.
METHOD If_cust_object~initial_sync.
place cursor on method Name
press where used list.
No results...
If you go inside the interface definition.
Interface If_cust_object.
methods Initial_sync.
place cursor on method Name
press where used list.
you get the list....
Stepped on that rake today. Got smacked in the face with a call point not fixed.
In other languages eg c# and in ECLIPSE ADT, the whereused list is shown in both cases.
Why not in ABAP ? Is that a Bug in whereused that the interface isnt checked properly?
Nice trap.
02-03-2016 8:07 PM
Just a quick side note: In your example, you're using objects from the SAP standard namespace, not customer / partner objects. There's a note around that basically states that the where-used-index is not guaranteed to be complete for SAP objects in a customer system, but that you can run SGEN followed by SAPRSEUB to build the index. Find and read the note first thought, and talk to your basis admins - the job might run for a few days and require considerable additional database space.
02-03-2016 2:29 PM
Hi Phil,
Open the Class/ Interface via transaction SE24.
Do not open the Method, Just place the cursor on any method and Do a where used.
You get the desired result.
Regards,
Shailesh
02-04-2016 8:22 AM
not sure you read my post properly. I state that already. And the behaviour is not good enough in my view
02-03-2016 8:00 PM
Phil,
I believe what you are describing is the expected behavior when working with well-designed ABAP OO code:
The reason I say this is the expected behavior for well-designed code is that there should be no direct references to method implementations outside of the implementing classes themselves or else one of the primary purposes of using an interface is violated. Here's an example of what I mean:
Say you have an interface for documents called IF_DOC:
* Basic interface for a document
INTERFACE if_doc.
METHODS:
get_output
RETURNING VALUE(r_result) TYPE nast.
ENDINTERFACE.
You then have two separate implementations to that document interface, one for sales orders and one for deliveries:
* Sales Order Class to implement the document interface
CLASS cl_sales_order DEFINITION.
INTERFACES if_doc.
ENDCLASS.
CLASS cl_sales_order IMPLEMENTATION.
METHOD if_doc~get_output.
* Some code here to get sales order outputs
ENDMETHOD.
ENDCLASS.
* Delivery Class to implement the document interface
CLASS cl_delivery DEFINITION.
INTERFACES if_doc.
ENDCLASS.
CLASS cl_delivery IMPLEMENTATION.
METHOD if_doc~get_output.
* Some code here to get delivery outputs
ENDMETHOD.
ENDCLASS.
At this point, if you carried out a where-used on the interface method, you should see two hits: one for the sales order implementation and one for the delivery implementation. The implementations have not actually been used yet though so you'd expect the list to return no results.
Finally, a third class is created to work with the document interface called CL_DOC_PROCESSOR:
* Additional class used to process documents
CLASS cl_doc_processor DEFINITION.
* Static method accepts a reference to doc interface
CLASS-METHODS:
issue_output
IMPORTING im_document TYPE REF TO if_doc.
ENDCLASS.
CLASS cl_doc_processor IMPLEMENTATION.
METHOD issue_output.
* Calling method only ever references interface, never concrete classes.
DATA(ls_output) = im_document->get_output( ).
print_output( ls_output ).
ENDMETHOD.
ENDCLASS.
At this point, carrying out a where-used on the interface method would now yield three hits: the two mentioned above and a third for the usage of the method in the document processor. Notice however that there are still no direct references to the implementations so carrying out a where-used on them would still yield no results. Also note: if results were returned for carrying out a where-used on those method implementations, they would be misleading as there is no guarantee that those implementations are actually being used.
One last example I'd like to add is a case in which you should get results for carrying out a where-used on a method implementation. Say that document processor class had another method called ISSUE_DELIVERY_OUTPUT:
METHOD issue_delivery_output.
DATA(lo_delivery) = NEW cl_delivery.
DATA(ls_output) = lo_delivery->if_doc~get_output( ).
print_output( ls_output ).
ENDMETHOD.
In this case, there is a direct reference to the implementing class so if you carried out a where-used against it you would find a match. Ideally these types of direct references to implementing classes should be avoided when using interfaces as the calling program should not need to worry about specific implementations.
Sorry for being a bit long winded, hopefully that's what you are looking for.
Thanks,
Brian
Message was edited by: Brian McDonnell
02-04-2016 8:25 AM
Having programmed for years in c# 5+ not just abap -oo- i disagree that a whereused list should only work in the interface.
And piece of code that called the method via the interface is a potential caller of the method. I except to see that in the where used list. Just like i do in c# visula studio and just like ABAP eclipse ADT.
02-04-2016 8:26 AM
02-03-2016 8:07 PM
Just a quick side note: In your example, you're using objects from the SAP standard namespace, not customer / partner objects. There's a note around that basically states that the where-used-index is not guaranteed to be complete for SAP objects in a customer system, but that you can run SGEN followed by SAPRSEUB to build the index. Find and read the note first thought, and talk to your basis admins - the job might run for a few days and require considerable additional database space.
02-04-2016 8:21 AM
Thats what it is. The namespace issue ! I forgot about that. AT least it works in Eclipse. Unfornately we have code with enhancements spots (dont ask...) and I cant edit that in eclipse.
So yes there is a where used weakness with namespace in ABAP.
02-04-2016 8:28 AM
02-04-2016 8:26 AM
Check this SAP Note, if you have the EU* jobs scheduled properly:
18023 - Jobs EU_INIT, EU_REORG, EU_PUT
They are responsible for the index tables needed for the where used list.
Peter
02-04-2016 8:31 AM
02-04-2016 9:39 AM
"The report SAPRSEUB has a very long runtime and can run up to 100 hours (5 days)."
Wow! It's really WTF