‎2008 Feb 07 1:57 PM
Is there any possibility to call INCLUDE in my ABAP program dynamically. I have many Includes which I call in Case-when-statement. I want to avoid this 20 whens.
Codes looks like this :
case obj.
when Z001.
Include z001.
When Z002
Include z002.
.
.
.
etc.
endcase.
I know it possibly for SUBMIT Report name and for CALL FM. So why not for includes?
Edited by: Saila on Feb 7, 2008 2:57 PM
‎2008 Feb 07 2:23 PM
No, it's not possible. You don't CALL includes. You just, er... include them. That is, they become part of the source code. Regardless of the value of obj all your includes are included. Includes should only be used to manage source code - to prevent the editor having to load too much at one time - NOT as a modularisation technique. There's an inherent danger in using them inside control structures, and this should be avoided. You should rather use classes/function modules/forms/submit (in order of decreasing preference.
matt
‎2008 Feb 07 1:59 PM
‎2008 Feb 07 2:23 PM
No, it's not possible. You don't CALL includes. You just, er... include them. That is, they become part of the source code. Regardless of the value of obj all your includes are included. Includes should only be used to manage source code - to prevent the editor having to load too much at one time - NOT as a modularisation technique. There's an inherent danger in using them inside control structures, and this should be avoided. You should rather use classes/function modules/forms/submit (in order of decreasing preference.
matt
‎2011 Jun 16 9:46 AM
try using macro.
define myinclude
case &1.
when 1.
include z001.
when 2.
include z002.
when others.
endcase.
myinclude 2.
let me know if it works......
‎2011 Jun 16 9:57 AM
Includes are just part of you program for improving your codes readability.You dont call them, you just include them.
I dont understand, what issue you are facing if you have all these includes.If you have to put some condition, then put them on the performs , which these include would contain.And execute those conditionally.