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

Function Group - common subroutine to be used ...

Former Member
0 Likes
1,046

Hallo Experts,

If you can help please.

In my function group I have a subroutine that I need to always perform 1st. I've added the perform to the INCLUDE XXXXXTOP but then the program doesn't want to compile.

Where do I add this PERFORM statement ?

Thank you,

Maré

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
997

Hi,

TOP include is used only to define data. You put there definition of your form.

FORM form_name.

...

ENDFORM

By using PERFORM you just invoke it thereafter.

If you need this to be at the very beginning, call it in the beginning of the function module you use.

i.e.

FUNCTION your_function.

*DATA:....

PERFORM form_name

...

ENDFUNCTION*.

then in the program use:

CALL your function...

I hope that will help you.

Regards,

Marcin

6 REPLIES 6
Read only

MarcinPciak
Active Contributor
0 Likes
998

Hi,

TOP include is used only to define data. You put there definition of your form.

FORM form_name.

...

ENDFORM

By using PERFORM you just invoke it thereafter.

If you need this to be at the very beginning, call it in the beginning of the function module you use.

i.e.

FUNCTION your_function.

*DATA:....

PERFORM form_name

...

ENDFUNCTION*.

then in the program use:

CALL your function...

I hope that will help you.

Regards,

Marcin

Read only

0 Likes
997

Thanx for the replies.

My problem is that the subroutine will be used in more than one function module therefor I would like to do it only once at the start of the function group ... if possible ?

Read only

0 Likes
997

Hi,

If u define the subroutine in a diff. include then u call call it from all Fms with the following statement.

perform <Subroutine name> in program <Include name> if found.

Regards,

Joy.

Read only

0 Likes
997

Hi,

1) You should define the form in a separate Influde INCLUDE XXXXXF01 rather than in

INCLUDE XXXXXTOP.

2) Call the FORM with PERFORM from each function module that needs the output.

3) If it has to be called only once (because output does not differ) you may define static variables and give back the last results:

FORM get_t006 TABLES e_t006 STRUCTURE t006
                    USING VALUE(i_dimid) TYPE DIMID .

STATICS: lv_last_dimid type dimid.
STATICS: lt_last_result type standard table of t006.

IF i_dimid = lv_last_dimid.
     e_t006[] = lt_last_result[].
     RETURN.
ENDIF. 

..." select from t006/ ...

have fun,

hp

Edited by: Holger Pakirnus on Jul 1, 2008 6:51 PM

Edited by: Holger Pakirnus on Jul 1, 2008 6:54 PM

Read only

Former Member
0 Likes
997

Rather than storing the subroutine to top-include store it in a different include.

Note : This new include should be created in the function group.

Regards,

Joy.

Read only

Former Member
0 Likes
997

hi dont write the perform in the top it doesnt mean that it is available globally...but you can create the external subroutine and you can call them as well....

like in this..

http://help.sap.com/saphelp_erp2004/helpdata/en/9f/db999535c111d1829f0000e829fbfe/frameset.htm

or you can see some standard function modules ...for the coding