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

Subroutine in include

Former Member
0 Likes
1,657

Hello,

I am trying to include some subroutines I have written in an include program but they are not able to execute. For example, my include program contains:

FORM F1 USING STR1 STR2.

WRITE: / 'STR1 =', STR1, / 'STR2 = ', STR2.

ENDFORM.

Prog name: ZINCLUDE

Attributes: Include program

When I try to call this subroutine in another program (attributes: executable) using the following code it doesn't work:

REPORT ZTEST.

INCLUDE ZINCLUDE.

WRITE: / 'Calling sub..'.

PERFORM F1 IN PROGRAM ZINCLUDE USING 'abc' 'def'.

WRITE:/ 'Sub called.'.

This program activates and gets compiled successfully. However, when I run it produces no output, not even the local write statements. Please help.

Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,457

Hi khan,

REPORT ZTEST.

WRITE: / 'Calling sub..'.

PERFORM F1 USING 'abc' 'def'.

WRITE:/ 'Sub called.'.

INCLUDE ZINCLUDE.

and in ZINCLUDE include the following code hope this helps you

FORM F1 USING STR1 STR2.

WRITE: / 'STR1 =', STR1, / 'STR2 = ', STR2.

ENDFORM.

Regards,

Sravanthi.

6 REPLIES 6
Read only

Former Member
0 Likes
1,457

hi Khan,

Goto SE80 and activate the main program ZTEST .... Also make the below modification ....

REPORT ZTEST.

INCLUDE ZINCLUDE.

WRITE: / 'Calling sub..'.

PERFORM F1 USING 'abc' 'def'.

WRITE:/ 'Sub called.'.

Regards,

Santosh

Read only

Former Member
0 Likes
1,457

Hi Khan,

I think it should be a executable program.

Best reagrds,

raam

Read only

Former Member
0 Likes
1,457

Hi,

IT will Work Man.. I handled so many reports like this..

try once again.. it will work .. Make shure that the include program should be active stage ...

Check it once..

Raghunath.S

9986076729

Read only

Former Member
0 Likes
1,458

Hi khan,

REPORT ZTEST.

WRITE: / 'Calling sub..'.

PERFORM F1 USING 'abc' 'def'.

WRITE:/ 'Sub called.'.

INCLUDE ZINCLUDE.

and in ZINCLUDE include the following code hope this helps you

FORM F1 USING STR1 STR2.

WRITE: / 'STR1 =', STR1, / 'STR2 = ', STR2.

ENDFORM.

Regards,

Sravanthi.

Read only

former_member761936
Active Participant
0 Likes
1,457

Hi,

when you are including program.No need to write inprogram while calling subroutine and also we need to use start-of-selection .

REPORT ZTEST.

INCLUDE ZINCLUDE.

WRITE: / 'Calling sub..'.

PERFORM F1 IN PROGRAM ZINCLUDE USING 'abc' 'def'.

WRITE:/ 'Sub called.'.

Above code need to be write as

REPORT ZTEST.

INCLUDE ZINCLUDE.

START-OF-SELECTION.

WRITE: / 'Calling sub..'.

PERFORM F1 USING 'abc' 'def'.

WRITE:/ 'Sub called.'.

This will work.

Read only

Former Member
0 Likes
1,457

Hi Khan,

Actually I have worked with this scenario, where we write the FORM routines in the include program of type I.

I have taken your code and worked on that.

Report ZMK_TEST no standard page heading line-size 255.

If you use the first code which is your actual code the program goes to dump once you execute as the include you used is a program of type I and in the perform you are using the statement PERFORM F1 IN PROGRAM ZMK_INCLUDE USING 'abc' 'def'.

*INCLUDE Zmk_INCLUDE.
*WRITE 'Calling sub'.
*PERFORM F1 IN PROGRAM ZMK_INCLUDE USING 'abc' 'def'.
*WRITE:/ 'Sub called.'.

Use this code it will work correctly and the main modification is use of start-of-selection and the change in perform statement

INCLUDE Zmk_INCLUDE.
START-OF-SELECTION.
WRITE 'Calling sub'.
PERFORM F1 USING 'abc' 'def'.
WRITE:/ 'Sub called.'.

Reward points if helpful.

Thanks,

Khan.