ā2012 Dec 04 6:25 AM
Hello,
I want to use the Extended Naming Convention for Programs check in SAP Code Inspector. After running a test program i get an errro which i can't solve. I hope somebody can help me with this issue.
The problem is, when i create a class which implements an Interface (also set an Alias for the method) and at the implementation of the Interface method i add the following code:
FIELD-SYMBOLS: <ls_test> type ty_data.
When i run the code inspector with the predefined variant: SAP_GUIDELINE_NAMING_SOURCE the following warning is shown:
Error(SYMBOL) pointing to the above mentiond field-symbol.
When i do the same on another class which doesn't implement an interface i don't get a warning.
I am on a NW 7.02 SP10 system.
I hope somebody can help me.
Kind regards,
Maarten.
ā2012 Dec 04 7:38 AM
Hi Maarten,
maybe you use the wrong naming-convention for global and local field-symbols.
This could explain why you got an error in an report, and don“t got an error in an interface/class.
Try to change the FIELD-SYMBOL name from <ls_test> to <gv_test>.
Best regards,
Damir
ā2012 Dec 04 7:38 AM
Hi Maarten,
maybe you use the wrong naming-convention for global and local field-symbols.
This could explain why you got an error in an report, and don“t got an error in an interface/class.
Try to change the FIELD-SYMBOL name from <ls_test> to <gv_test>.
Best regards,
Damir
ā2012 Dec 04 7:46 AM
Hello Damir,
Thanks for the reply. I did some more research and i think it's a bug in the code inspector check. As mentioned in the original post, i created a class which doesn't implement an interface and when i implement a method, and use the FIELD-SYMBOL statment i don't get an error.
What i did now, is that i removed the ALIASES statement. So the implementation of the interface method looks like lif_code_inspector~do_something. The result is that i don't have any warnings.
My conclusion is, it's a bug. Think a open an OSS Message.
Kind regards,
Maarten.
ā2012 Dec 04 7:52 AM
Hi Maarten,
yes maybe it is an bug in the code-inspector...
For a last try, you can play with the Visibility on the TAB 'Aliases'
Best regards,
Damir
ā2012 Dec 04 9:26 AM
Hello,
Think i did make a mistake. Hope somebody can clear it for me.
The classes i created are local classes. When i create a class as mentiond below
CLASS lcl_test DEFINITION FINAL
PUBLIC SECTION.
INTERFACES lif_if.
ALIASES get_something for lif_if~some_method.
ENDCLASS
.
what is the correct way to implement this interface method. Is this option 1 or 2. I ask this, because the syntax checker excepts both, but the code inspector gives warnings with option 2 in relation to my first post (defining local data elements within the method).
Option 1:
CLASS lcl_test IMPLEMENTATION.
METHOD lif~if.
writhe some code here.
ENDMETHOD.
Option 2:
CLASS lcl_test IMPLEMENTATION.
METHOD get_something. (name of the alias)
writhe some code here.
ENDMETHOD.
Thx in advance.
Maarten.
ā2012 Dec 04 9:45 AM
Hi Marteen,
i would always implement the interface method according to option 1 jus to avoid confusion for the reader which method is implemented.
Regards,
Dirk
ā2012 Dec 04 10:25 AM
Hi Maarten,
for me it both option are valid and also correct.
It matters what context is relevant for your solution.
Personally, I“ve used more Option 2, because it shortened the method name, so it is for me better readable and i can concentrate more on the relevant methodname.
Best regards,
Damir
ā2012 Dec 04 11:58 AM
All,
Thanks for al the answers.
I will use option 1. This works in the code inspector. I'm doubting if i should open an OSS message. In my opinion option 2 is also valid and should work.
Kind regards,
Maarten.