

GENERATE SUBROUTINE POOL source_table NAME program_name MESSAGE syntax_check_message LINE line_no.

SELECT SINGLE tabname FROM dd02l INTO CORRESPONDING FIELDS OF dd02l WHERE tabname = tabname.

PARAMETERS : tabname LIKE dd02l-tabname DEFAULT 'ZEMP3'. DATA: gt_fcat TYPE lvc_t_fcat, gt_fcat_main TYPE slis_t_fieldcat_alv. DATA : source_table(72) OCCURS 0 WITH HEADER LINE, program_name LIKE sy-cprog, syntax_check_message(128), line_no TYPE i. *Using "REUSE_ALV_LIST_DISPLAY" function dynamically TYPE-POOLS: slis. REPORT zravie_gen_subroutine_pool3 MESSAGE-ID zrsp.

Now let's demonstrate in an example in which I am using subroutine pools for fetching data from a dynamic table: At the first call of a subroutine in the subroutine pool, this is loaded into internal mode, where the event LOAD-OF-PROGRAM is initialized. In the source code of the subroutine pool, subroutines can be called from all programs that are loaded in the same internal mode by specifying the program name prog using the statement PERFORM. Generation errors can occur, among other things, if the program contains errors in the declaration statements that are not recognized during the static syntax check. Syntax errors can either occur in the source code specified in itab or in the include programs included using the statement INCLUDE. Using the addition error_handling, syntax and generation errors can be analyzed. If the source text contained in itab has a syntax error, the subroutine pool is not generated and initialized using prog. In an internal mode, a maximum of 36 temporary subroutine pools may be created. The data object prog must also be character type (prior to Release 6.10 flat). A source code line in itab may contain a maximum of 255 characters. The line type for itab must be character type (prior to Release 6.10 flat). The name with a maximum of 30 digits for the temporary subroutine pool is assigned to the variable prog. The generated subroutine pool is stored internally in the current internal mode. The source code of the subroutine pool is taken from the internal table itab. This statement generates a temporary subroutine pool.
