Get Example source ABAP code based on a different SAP table
ID GENERATE • GENERATE SUBROUTINE POOL ABAP Statement • NAME GENERATE SUBROUTINE POOL
GENERATE SUBROUTINE POOL> Short Reference >
ABAP_SYNTAX GENERATE SUBROUTINE POOL itab NAME prog $[ error_handling>$].>
What does it do? This statement generates a temporary subroutine pool>. The source code of the subroutine pool is taken from the internal table itab>. The generated subroutine pool is stored internally in the current ABAP_ISESS >. The eight-character name of the temporary subroutine pool is assigned to the variable prog>. The following can be specified for prog>:
An existing character-like variable
An inline declaration DATA(var)>> or FINAL(var)>>, where a variable of type PROGNAME>> is declared. For itab>, only a standard table without secondary table keys> is allowed. The line type of itab> must be character-like. A line of source code in itab> can have no more than 255 characters. For line types with a fixed length, trailing blanks are ignored. In an ABAP_ISESS , a maximum of 36 temporary subroutine pools can be created. BEGIN_SECTION SAP_INTERNAL_HINT In fact, the length of 255 is checked only for strings. For whatsoever reasons, tables of text fields can have a length of 262243 characters. Of course, that should not be exploited. END_SECTION SAP_INTERNAL_HINT If the source code in itab> has a syntax error, the subroutine pool is not generated and prog> is initialized. The addition error_handling>> can be used to analyze syntax errors and generation errors. For the syntax check, the switch configuration of Switch Framework> is used as it was when the current transaction was called. If an exception is raised when the subroutine pool is generated, the runtime error is handled internally so that no programs are terminated and sy-subrc> is set to the value 8 instead. However, there is still a database rollback> and the corresponding short dump> is saved as regular. The addition SHORTDUMP-ID>> can be used to determine the ID of the runtime error. Subroutines defined in the source code of the subroutine pool can be called from all programs that are loaded in the same ABAP_ISESS by specifying the program name prog> using the statement PERFORM>>. When a subroutine is called for the first time in the subroutine pool, this is loaded into the ABAP_ISESS , and the event LOAD-OF-PROGRAM>> is raised. System Fields> sy-subrc>>Meaning> 0Generation was successful. 4The source code contains a syntax error. 8A generation error occurred. The resulting runtime error was handled internally. If a runtime error occurs during the generation process (sy-subrc > has the value 8), a database rollback is executed as usual.