Application Development and Automation 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: 
Read only

Run Include dynamically

Former Member
0 Likes
1,151

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

1 ACCEPTED SOLUTION
Read only

matt
Active Contributor
850

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

4 REPLIES 4
Read only

Former Member
0 Likes
850

Hi,

if you do a submit to a program for every when?

Read only

matt
Active Contributor
851

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

Read only

gaurab_banerji
Active Participant
0 Likes
850

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

Read only

Former Member
0 Likes
850

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.