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 pool

Former Member
0 Likes
576

Hi,

How can i run the subroutine pool program. Is it necessary to create report for that? please help me.

2 REPLIES 2
Read only

Former Member
0 Likes
445

hi

hope it will help you.

Pls reward if help.

Subroutine Pools

Subroutine pools, as the name implies, were created to contain selections of subroutines that can be called externally from other programs. Before release 6.10, this was the only way subroutine pools could be used. But besides subroutines, subroutine pools can also contain local classes and interfaces. As of release 6.10, you can connect transaction codes to methods. Therefore, you can now also call subroutine pools via transaction codes. This is the closest to a Java program you can get in ABAP: a subroutine pool with a class containing a method – say – main connected to a transaction code.

Subroutine pools are created using the ABAP Editor and are introduced with the PROGRAM statement. They may not contain any screens of their own, and with the exception of the LOAD-OF-PROGRAM event block they may only use subroutines as processing blocks. Subroutine pools are loaded by externally calling their subroutines from within other ABAP programs.

DATA: CODE(72) OCCURS 10,

PROG(8), MSG(120), LIN(3), WRD(10), OFF(3).

APPEND 'PROGRAM SUBPOOL.'

TO CODE.

APPEND 'FORM DYN1.'

TO CODE.

APPEND

'WRITE / ''Hello, I am the temporary subroutine DYN1!''.'

TO CODE.

APPEND 'ENDFORM.'

TO CODE.

APPEND 'FORM DYN2.'

TO CODE.

APPEND

'WRIT / ''Hello, I am the temporary subroutine DYN2!''.'

TO CODE.

APPEND 'ENDFORM.'

TO CODE.

GENERATE SUBROUTINE POOL CODE NAME PROG

MESSAGE MSG

LINE LIN

WORD WRD

OFFSET OFF.

IF SY-SUBRC <> 0.

WRITE: / 'Error during generation in line', LIN,

/ MSG,

/ 'Word:', WRD, 'at offset', OFF.

ELSE.

WRITE: / 'The name of the subroutine pool is', PROG.

SKIP 2.

PERFORM DYN1 IN PROGRAM (PROG).

SKIP 2.

PERFORM DYN2 IN PROGRAM (PROG).

ENDIF.

In this program, a subroutine pool containing two subroutines is placed into table CODE. Note that the temporary program must contain a REPORT or PROGRAM statement. Statement GENERATE SUBROUTINE POOL generates the temporary program.

A generation error occurred since the WRITE statement has been misspelled in the second subroutine, DYN2. After that line has been revised:

APPEND

'WRITE / ''Hello, I am the temporary subroutine DYN2!''.'

TO CODE.

Generation was successful. The internal program name is displayed. Then, the subroutines of the subroutine pool are called. Note that you do not need to know the program name to call the subroutines.

Read only

Former Member
0 Likes
445

hi,

refer this link

/people/ravishankar.rajan/blog/2007/03/27/using-subroutine-pools-for-dynamic-programming