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

Include program

Former Member
0 Likes
1,062

Hi all,

I am tyring to develop an report.In this I want the definition of the subroutine in an include. This the code I have written :

<b>Main program :</b>

*********************************************************

REPORT zotcrgt003 .

INCLUDE z_i_otcrgt003. " include for data Declarations.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001 .

PARAMETERS : p_zbukr TYPE regup-zbukr ,

p_zlsch TYPE regup-zlsch ,

zw_laufd LIKE f110v-laufd ,

zw_laufi LIKE f110v-laufi .

SELECT-OPTIONS : s_kunnr FOR regup-kunnr.

SELECTION-SCREEN END OF BLOCK b1 .

PERFORM language_translation.

INCLUDE z_i_otcrgt0031. " include in whihc i Defined the above form

break-point.

*********************************************************

<b>Include program :</b>

*********************************************************

form language_translation.

SELECT SINGLE * FROM ZTFIN WHERE

fname = 'Z_F140_ACC_ST_01'

AND spras = 'E'.

SELECT SINGLE * FROM ztfin INTO t_ztfin WHERE

fname = 'Z_F140_ACC_ST_01'

AND spras = 'I'.

endform. " language_translation

*********************************************************

This is working fine, but when I keep the include statements together like this :

INCLUDE z_i_otcrgt003.

INCLUDE z_i_otcrgt0031.

I am getting an error saying statement is not accessible.

Can anyone explain me what is it so ?

Regards,

Varun.

Message was edited by: varun sonu

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
997

INCLUDE statement is location specific which means that the statements in the INCLUDE will be expanded in the compiled code at the same location where you put this statement. So in your example what it is doing is soon after the data declarations, it is having FORM ... ENDFORM statements and then your START-OF-SELECTION, SELECTION-SCREEN etc.

That is why you are getting this error. Routines should be at the end of the program, which means your INCLUDE should also be at the end.

8 REPLIES 8
Read only

Former Member
0 Likes
997

Hi

Which statament? And where do you put the INCLUDE stataments in your code (when you insert them close)?.

Max

Read only

Former Member
0 Likes
998

INCLUDE statement is location specific which means that the statements in the INCLUDE will be expanded in the compiled code at the same location where you put this statement. So in your example what it is doing is soon after the data declarations, it is having FORM ... ENDFORM statements and then your START-OF-SELECTION, SELECTION-SCREEN etc.

That is why you are getting this error. Routines should be at the end of the program, which means your INCLUDE should also be at the end.

Read only

0 Likes
997

Hi Srinivas,

So every time all the includes must be specified at the end of the program ? Is it what you atre saying ?

Regards,

Varun.

Read only

0 Likes
997

i've always thought it was bad coding to run routines in INCLUDES just by putting an include statement in your code.

it makes it difficult for anyone else to come in and see what's going on.

why don't you put your include statements at the top of your main program and just call those subroutines where and when you need them using PERFORM statements?

it's much easier and you wouldn't be running into the problem as you are now.

Read only

0 Likes
997

Hi Varun

It depends on how you've arranged your program and what the includes contain.

The includes with declaration data should be place at the beginning of the program, the includes with routine at the end.

Max

Read only

0 Likes
997

Not all the includes, I am specifically talking about includes that have <u>only</u> FORMs. The thumb rule is that an include is appropriate in a place where, instead of the include statement, you put the code of the include. As an example, if my include has 3 lines of code, and I put my include statement at say line 3 of the main program, then it is equivalent to writing those 3 lines of include at that location. If those 3 lines are valid at that location of the main program, then the include statement is valid at that location, if not, then you cannot put the include statement there.

Read only

0 Likes
997

Hi ,

As robert mentioned when I mention both the includes like this :

INCLUDE z_i_otcrgt003.

INCLUDE z_i_otcrgt0031.

it is giving me an error. I have defined it soon after the report statement.

Regards,

varun.

Read only

0 Likes
997

Hi

I think the problem isn't the INCLUDE statament, but the PERFORM statament.

You can write this code:

REPORT ZCCCC.

INCLUDE ZCCCC0.

INCLUDE ZCCCC1.

START-OF-SELECTION.

PERFORM WRITE_NUMBER.

The form WRITE_NUMBER is defined in ZCCCC1.

But you can't write this code:

INCLUDE ZCCCC0.

INCLUDE ZCCCC1.

PERFORM WRITE_NUMBER.

START-OF-SELECTION.

Max