Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to suppress 'Include name does not begin with the prefix of the current class pool'?

WRoeckelein
Active Participant
0 Kudos

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

11 REPLIES 11

pokrakam
Active Contributor

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.

pokrakam
Active Contributor

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?

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

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.

pokrakam
Active Contributor
0 Kudos

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.

matt
Active Contributor

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...

horst_keller
Product and Topic Expert
Product and Topic Expert

"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 ...

mmcisme1
Active Contributor
0 Kudos

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

0 Kudos

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

mmcisme1
Active Contributor
0 Kudos

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.

kiran_k8
Active Contributor
0 Kudos

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.

WRoeckelein
Active Participant
0 Kudos

I am using an existing include from a SAP AddOn, where all constants used in the API of the AddOn are defined.