2017 Oct 13 9:02 AM
Hi,
from Code Inspector I received the hint to not use the same include in multiple methods, so I have moved the include now to "Class-Relevant Local Definitions".
While this works, I get now a warning 'Include name "..." does not begin with the prefix (...) of the current class pool'. (class is in our namespace prefix, include is prefix of a sap product which is a prerequisite of the class).
Can I suppress this warning somehow?
This is on NetWeaver 7.40.
Thanks,
Wolfgang
2017 Oct 13 9:29 AM
Includes are an obsolete construct. If you want to do things properly, use a local class. If the code is to be shared across multiple classes then create a global class. This is a much more flexible approach and allows for better encapsulation than you can achieve with includes.
2017 Oct 13 9:43 AM
Ah... I missed the bit that the include is from SAP, so my answer above is only partly relevant.
Things to try might be encapsulating the include functionality in a local class, but I suspect that may not work. Is the stuff in the include not something you could copy or call directly?
2017 Oct 14 2:31 PM
Hmm, includes are not obsolete but of course a supported technology for source code modularization. What we don't want is reuse of includes in several programs. And in given include setups as function groups and class pools we want you to use the predefined names.
2017 Oct 14 3:05 PM
Thanks, you are right, I didn't word that very well. "Use of includes for code re-use is an obsolete construct" would have been more accurate.
Many many moons ago we used includes as a reusable code repository, which is considered bad practice since the advent of ABAP Objects (or even before that). This is exactly what the OP was doing - although the reason makes sense given he wants to reuse a SAP-delivered piece of functionality.
2018 Feb 07 1:20 PM
Terminology quibble. I would say that includes are for program source code organisation. I don't think they contribute to modularisation per se - for that we have methods (or Function Modules, if you must). You don't modularise a program by adding includes...
2018 Feb 07 1:36 PM
"Terminology quibble".
'xactly.
When we say "source code modularization" we mean "source code organization" rather than "modularization of functionality"
I set myself a marker to remove "source code modularization" from the documentation ...
2017 Oct 14 1:31 PM
Why are you using the include? Can you move it into a class/method construct? Is there a reason why it works better in the include? Your actual question suppress the message. Add the following to the end of your include CCDEF. See if that helps with the message. Another possibility is to create a type-pool and add your include there.
Best of luck!
Michelle
2018 Feb 07 11:18 AM
Hi Mike and Michele,
thanks for your hints.
I am using an existing include of a SAP AddOn which defines the constants used in the APIs of the AddOn (there I can't edit the include itself). Of cource I could define my own global class, but this defeats the purpose to use the constant definitions of the AddOn and not duplicate them on our side...
Using the include in the "Class-Relevant Local Definitions" gave more trouble including syntax errors, so I am now back to using the include in the methods...
Regards,
Wolfgang
2018 Feb 07 1:30 PM
So you are using the include because you are using the same definitions. Are you using them all? If the include changes - will your code still work?
I guess my definitions tend to be within the modules but I don't use includes. I don't use them, because I don't use all the fields over again.
I would guess you would probably get the warning, but if it works for you then I wouldn't worry about it.
2018 Feb 07 2:04 PM
Wolfgang,
https://answers.sap.com/questions/363618/goodbad-programming-from-oops-perspective.html
Hope the above discussion also will provide you more info.
K.Kiran.
2018 Feb 13 2:46 PM
I am using an existing include from a SAP AddOn, where all constants used in the API of the AddOn are defined.