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

Calling subroutine in another function group

Former Member
0 Likes
2,652

Hi all,

I want to include a call to subroutine TKKA1000_FUELLEN in function group kkag in my custom program. Can I do that? I come from a C/JAVA baclground in which I could INCLUDE the class or set of programs with a simple statement. can i do the smae here?

regards,

Mat

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,192

You can do that by using the IN PROGRAM extesion, but all of the variables used in the FORM must be declared in your program.

Perform TKKA1000_FUELLEN in program SAPLKKAG.

Make sure to include the TABLES and CHANGING parameters.

Regard,

Rich Heilman

3 REPLIES 3
Read only

Former Member
0 Likes
1,192

HI,

Check the below code....

<b>PERFORM form IN PROGRAM prog.</b>

Additions:

1. ... USING p1 p2 p3 ...

2. ... CHANGING p1 p2 p3 ...

3. ... TABLES itab1 itab2 ...

4. ... IF FOUND

In an ABAP Objects context, a more severe syntaxcheck is performed that in other ABAP areas. See Passsing SY-REPID not allowedand Receiving SY-SUBRC not allowed.

Effect

This variant is similar to variant 2 (externalperform). However, here you can specify the names of both thesubroutine and the program in which it occurs dynamically at runtime.If you do this, you should place the variables form and prog in parentheses. The names in form and prog must beentered in uppercase, otherwise a runtime error occurs. If you do notspecify any additions (such as USING) you do not need to specifythe program after IN PROGRAM. In this case, the system looks forthe subroutine in the current program.

Example

DATA: RNAME(30) VALUE 'WRITE_STATISTIC', "Form and program

"names must

PNAME(8) VALUE 'ZYX_STAT'. "be written in

"upper case

PERFORM (RNAME) IN PROGRAM ZYX_STAT.

PERFORM WRITE_STATISTIC IN PROGRAM (PNAME).

PERFORM (RNAME) IN PROGRAM (PNAME).

All three PERFORM statements have the same effect, that is,they call the subroutine 'WRITE_STATISTIC', which is defined inthe program 'ZYX_STAT'.

Notes

Dynamic PERFORM statements require more CPU time, since the system has to locate the subroutine each time.

Regards,

Vara

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,193

You can do that by using the IN PROGRAM extesion, but all of the variables used in the FORM must be declared in your program.

Perform TKKA1000_FUELLEN in program SAPLKKAG.

Make sure to include the TABLES and CHANGING parameters.

Regard,

Rich Heilman

Read only

0 Likes
1,192

Alternative to Rich's suggestion, you can also do the following

PERFORM TKKA1000_FUELL(saplkkag).

You have to include all the relevant parameters.

hith

Sunil Achyut