‎2007 Dec 31 3:42 AM
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.
‎2007 Dec 31 9:58 AM
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
‎2007 Dec 31 3:47 AM
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.
‎2007 Dec 31 4:04 AM
Hi, Sailaja.
Thanks for your answer.I tried your method, but failed.
Regards,
feng.
‎2007 Dec 31 3:48 AM
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
‎2007 Dec 31 6:07 AM
Thanks, Atish.
The error message is just that. Do you mean that my code is all right in syntax?
Regards,
feng.
‎2007 Dec 31 6:20 AM
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.
‎2007 Dec 31 6:37 AM
Thanks, Renjith Michael.
But I want to use INCLUDE.
Regards,
feng.
‎2007 Dec 31 6:42 AM
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.
‎2007 Dec 31 6:48 AM
Thanks very much, Naga Raju.
Can you explain this? I'll give you full points.
Regards,
feng.
‎2007 Dec 31 9:23 AM
I think with out START-OF-SELECTION we cant use subroutines --form... Endform.
Thanks,
Nagaraju.
‎2007 Dec 31 9:30 AM
Thanks, Naga.
Can you tell me some links or some references?
Regards,
feng.
‎2007 Dec 31 9:58 AM
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