SAP GENERATE SUBROUTINE POOL ABAP Statements
Warning: Undefined variable $saptab in /customers/b/9/9/trailsap.com/httpd.www/abap-statements/index.php on line 46Get Example source ABAP code based on a different SAP table
Standard SAP Help for GENERATE_REPORT
GENERATE SUBROUTINE POOL
• GENERATE SUBROUTINE POOL ABAP Statement
• NAME GENERATE SUBROUTINE POOL
ABAP Syntax
What does it do? This statement generates a temporary
For
INTHINT In fact, the length of 255 is checked only for strings.
INTHINT For whatsoever reasons, tables of text fields can have
INTHINT a length of 262243 characters. Of course, that should not be
INTHINT exploited.
If the source code in
If an exception is raised when the subroutine pool is generated, the runtime error is handled internally so that no programs are terminated. Instead,
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
If a runtime error occurs during the generation process (
ABAP_PGL
ABAP Code Snippet
Security Note
ABAP Code Snippet If used wrongly, dynamic programming techniques can present a serious security risk. Any dynamic content that is passed to a program from the outside must be checked thoroughly or escaped before being used in dynamic statements. This can be done using the system class
ABAP Code Snippet
ABAP Code Snippet See
Latest notes:Since subroutines are now obsolete as a method of program modularization, a temporary subroutine pool created using
If the program that creates the subroutine pool is a
Using the switch configuration from when the transaction was called for the syntax check ensures that the whole transaction is executed using the same switch configuration (guaranteed by Switch Framework).
The source code in the internal table
In a temporary subroutine pool, the same global declarations and editing rules are defined as in the static subroutine pool of the r epository (see
The addition
Temporarily generated subroutine pools can be executed in ABAP Debugger in single steps.
A temporary subroutine pool generated for an internal mode cannot be deleted explicitly. It remains available from its generation up to the point where the internal session is terminated.
Example ABAP Coding
Creates and generates (dynamically) a subroutine pool that implements the event block
tab = VALUE #(
( `PROGRAM subpool.` )
( `DATA spfli_tab TYPE TABLE OF spfli.` )
( `LOAD-OF-PROGRAM.` )
( ` SELECT *` <(> <)>
` FROM spfli` <(> <)>
` INTO TABLE spfli_tab.` )
( `FORM loop_at_tab.` )
( ` DATA spfli_wa TYPE spfli.` )
( ` LOOP AT spfli_tab INTO spfli_wa.` )
( ` PERFORM evaluate_wa USING spfli_wa.` )
( ` ENDLOOP.` )
( `ENDFORM.` )
( `FORM evaluate_wa USING l_wa TYPE spfli.` )
( ` cl_demo_output=>write_data( l_wa ).` )
( `ENDFORM.` ) ).
GENERATE SUBROUTINE POOL tab NAME DATA(prog)
MESSAGE DATA(mess)
SHORTDUMP-ID DATA(sid).
IF sy-subrc = 0.
PERFORM ('LOOP_AT_TAB') IN PROGRAM (prog) IF FOUND.
cl_demo_output=>display( ).
ELSEIF sy-subrc = 4.
MESSAGE mess TYPE 'I'.
ELSEIF sy-subrc = 8.
MESSAGE sid TYPE 'I'.
ENDIF.
Example ABAP Coding
Creates and generates (dynamically) a subroutine pool that implements a local class. The static method
DATA class TYPE string.
APPEND `program.` TO itab.
APPEND `class main definition.` TO itab.
APPEND ` public section.` TO itab.
APPEND ` class-methods meth.` TO itab.
APPEND `endclass.` TO itab.
APPEND `class main implementation.` TO itab.
APPEND ` method meth.` TO itab.
APPEND ` message 'Test' type 'I'.` TO itab.
APPEND ` endmethod.` TO itab.
APPEND `endclass.` TO itab.
GENERATE SUBROUTINE POOL itab NAME DATA(prog).
class = `PROGRAM=` <(> <)><(> <)> prog <(> <)><(> <)> `CLASS=MAIN`.
CALL METHOD (class)=>meth.
Example ABAP Coding
Creates and generates (dynamically) a subroutine pool that implements a local class. The class is instantiated using its
DATA class TYPE string.
DATA oref TYPE REF TO object.
APPEND `program.` TO itab.
APPEND `class main definition.` TO itab.
APPEND ` public section.` TO itab.
APPEND ` methods meth.` TO itab.
APPEND `endclass.` TO itab.
APPEND `class main implementation.` TO itab.
APPEND ` method meth.` TO itab.
APPEND ` message 'Test' type 'I'.` TO itab.
APPEND ` endmethod.` TO itab.
APPEND `endclass.` TO itab.
GENERATE SUBROUTINE POOL itab NAME DATA(prog).
class = `PROGRAM=` <(> <)><(> <)> prog <(> <)><(> <)> `CLASS=MAIN`.
CREATE OBJECT oref TYPE (class).
CALL METHOD oref->('METH').
Example ABAP Coding
See also
Runtime Exceptions
Catchable Exceptions
Reason for error:
No further temporary subroutine pools can be generated. Runtime error:
Reason for error:
The source code is in a table consisting of strings and the table contains rows with more than 255 characters. Runtime error:
Return to menu