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

Form in the Include Program

Former Member
0 Likes
2,938

Hi, everyone.

I have created an Include Program named Z_INCLUDE_TEST, it's code is:

DATA base TYPE i VALUE 100.

FORM add USING value(augend) TYPE i

value(addend) TYPE i

sum TYPE i.

sum = augend + addend + base.

ENDFORM. "ADD

And in other program, I want to call this form, my code is:

REPORT ztest_li.

INCLUDE Z_INCLUDE_TEST.

DATA: PRICE TYPE I VALUE 100,

TAX TYPE I VALUE 50,

SUM TYPE I.

PERFORM ADD USING PRICE TAX SUM.

WRITE / SUM.

But the compiler give me an error: Statement is not accessible. Can you explain this?

Thanks in advance!

Regards,

feng.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,914

Hi Feng,

I shall Explain that.

In ur program when execution starts, First Include Step is executed. Here the system checks for Start-Of-Selection in this include. But as this is an Include Program we shud explicitly state in our report program the 'Start-of-selection'.

U can try this also and this do not give error.

REPORT ZTest .

DATA: PRICE TYPE I VALUE 100,

TAX TYPE I VALUE 50,

SUM TYPE I.

PERFORM ADD USING PRICE TAX SUM.

WRITE / SUM.

INCLUDE Z_INCLUDE_TEST.

Now this doesnot give an error and executes fine because first the perform is identified by the system and this defaults to a report program's start-of-selection which further goes and process the Include and finds the form. Now as the report already gone thru the Start-of-selection so the staement can be accessed.

Awrd POints if useful

Bhupal

11 REPLIES 11
Read only

Former Member
0 Likes
1,914

Hi,

Modify your code as below.

REPORT ztest_li.

DATA: PRICE TYPE I VALUE 100,

TAX TYPE I VALUE 50,

SUM TYPE I.

start-of-selection.

INCLUDE Z_INCLUDE_TEST.

PERFORM ADD USING PRICE TAX SUM.

WRITE / SUM.

Regards

Sailaja.

Read only

0 Likes
1,914

Hi, Sailaja.

Thanks for your answer.I tried your method, but failed.

Regards,

feng.

Read only

Former Member
0 Likes
1,914

Hi,

Have you tried to acticvate both the programs together. And can you tell the detailed error as which statement is not accessible(by looking at error message you will get this)

Regards,

Atish

Read only

0 Likes
1,914

Thanks, Atish.

The error message is just that. Do you mean that my code is all right in syntax?

Regards,

feng.

Read only

Former Member
0 Likes
1,914

Hi,

Please try calling the perform in the following way:

First Program which contains the FORM:

REPORT ztest0001 .

&----


*& Form test

&----


  • text

----


FORM test.

WRITE 'hi'.

ENDFORM. "test

Second Program from which the PERFORM is done:

REPORT ztest0002 .

DATA: rname(30) VALUE 'test'.

PERFORM test IN PROGRAM ztest0001.

Please try in the similar way.

Regards,

Michael.

Read only

0 Likes
1,914

Thanks, Renjith Michael.

But I want to use INCLUDE.

Regards,

feng.

Read only

Former Member
0 Likes
1,914

Hello Feng,

Here is the your solution.

REPORT znaga_test .

INCLUDE z_include_test.

DATA: price TYPE i VALUE 100,

tax TYPE i VALUE 50,

sum TYPE i.

START-OF-SELECTION.

PERFORM add USING price tax sum.

WRITE / sum.

Thanks,

Nagaraju.

Read only

0 Likes
1,914

Thanks very much, Naga Raju.

Can you explain this? I'll give you full points.

Regards,

feng.

Read only

0 Likes
1,914

I think with out START-OF-SELECTION we cant use subroutines --form... Endform.

Thanks,

Nagaraju.

Read only

0 Likes
1,914

Thanks, Naga.

Can you tell me some links or some references?

Regards,

feng.

Read only

Former Member
0 Likes
1,915

Hi Feng,

I shall Explain that.

In ur program when execution starts, First Include Step is executed. Here the system checks for Start-Of-Selection in this include. But as this is an Include Program we shud explicitly state in our report program the 'Start-of-selection'.

U can try this also and this do not give error.

REPORT ZTest .

DATA: PRICE TYPE I VALUE 100,

TAX TYPE I VALUE 50,

SUM TYPE I.

PERFORM ADD USING PRICE TAX SUM.

WRITE / SUM.

INCLUDE Z_INCLUDE_TEST.

Now this doesnot give an error and executes fine because first the perform is identified by the system and this defaults to a report program's start-of-selection which further goes and process the Include and finds the form. Now as the report already gone thru the Start-of-selection so the staement can be accessed.

Awrd POints if useful

Bhupal