2014 Jan 15 1:01 AM
Hi,
I am working on one requirement where my program has to generate Dynamic internal tables, So I am creating dynamic field catalog and passing it to the class
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = GT_DYN_FCAT1
IMPORTING
EP_TABLE = GT_DYN_TABLE1
EXCEPTIONS
GENERATE_SUBPOOL_DIR_FULL = 1
OTHERS = 2.
IF SY-SUBRC EQ 0.
ENDIF.
The above code is written in loop and the no. of loops will vary, it is working fine for around fifteen loops and after that it is not generating the Dynamic internal table and giving the SY-SUBRC = 1. It means the exception GENERATE_SUBPOOL_DIR_FULL. I came to know that during runtime max 36 dynamic subroutine pools will be generated after that it will not create Dynamic internal tables.
Please let me know if anybody faced same issue and any alternative to resolve this issue. my SAP version is 6.0.
Dileep.
2014 Jan 15 5:40 AM
Hello Dileep,
Regards,
Philip.
2014 Jan 15 5:29 AM
2014 Jan 15 5:40 AM
Hello Dileep,
Regards,
Philip.
2014 Jan 15 8:47 PM
2014 Jan 15 9:44 PM
Hi Dileep,
This is a limitation of GENERATE SUBROUTINE POOL: Check this documentation
GENERATE SUBROUTINE POOL
Syntax
GENERATE SUBROUTINE POOL itab NAME prog [error_handling].
Effect
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 internal mode. The eight-character name of the temporary subroutine pool is assigned to the variable prog.
A standard table without secondary table keys is allowed for itab. The line type for itab must be character type. A source code line in itab may contain a maximum of 255 characters. The data object prog must also be character type. In an internal mode, a maximum of 36 temporary subroutine pools may be created.
If the source text contained in itab has a syntax error, the subroutine pool is not generated and initialized using prog. Using the addition error_handling, syntax and generation errors can be analyzed. For the syntax check, the switch configuration of the Switch Framework is used in its state when the current transaction was called.
If an exception occurs when the subroutine pool is generated, the runtime error is handled itnernally so that no program termination occurs. Instead, sy-subrc is set to 8. However, there is still a database rollback and the corresponding short dump is stored as normal. The addition SHORTDUMP-ID can be used to determine the ID of the runtime error.
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. At the first call of a subroutine in the subroutine pool, this is loaded into internal mode, whereby the event LOAD-OF-PROGRAM is initialized.
System Fields
sy-subrc Meaning
0 Generation was successful.
4 Source code contains a syntax error.
8 A 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.
Notes
Since subroutines are now obsolete as a method of program modularization, a temporary subroutine pool created using GENERATE SUBROUTINE POOL should only contain a single initial subroutine that calls a method of a local class and does not contain any other functional coding.
If the creating program is a Unicode program, the corresponding syntax rules apply for the generated subroutine pool.
Using the switch configuration available at the time the transaction was called for the syntax check guarantees the assurance of the Switch Framework that the whole transaction is executed using the same switch configuration.
The source code in the internal table itab must contain a complete ABAP program, including the statement that introduces the program.
In a temporary subroutine pool, the same global declarations and editing rules are defined as in the static subroutine pool of the repository (see table of program types).
The addition REDUCED FUNCTIONALITY of the introductory program statement PROGRAM also works in temporary subroutine pools and is recommended to reduce their resource use.
Temporarily generated subroutine pools can be executed in the ABAP Debugger in single steps.
A temporary subroutine pool generated for an internal mode cannot be explicitly deleted. It remains available from its generation up to the point where the internal session is terminated.
GENERATE SUBROUTINE POOL should only be used in exceptional cases in application programs. ABAP offers many other methods for dynamic programming that generally render the creation of source code unnecessary (see the list under processing dynamic programs).
Your can check OSS Note 63227 too.
Now, i you prefer use create dynamic table, your can try with dynamic programming for generate a new program every time and pass that to method.
Or, maby you can try with RTTI, RTTS classes.
Regards,
2014 Jan 16 5:23 AM
Hii Dileep,
For your alternative dynamic table creation with your desire no. of records, try with this sample code,
here the the dynamic internal table is created based upon the input table name.
In this sample code, displaying the records of a database table entered with the no. of records want to display in ALV grid. You can enter any table name and based on that the records will be fetched and displayed in ALV grid.
check out this code according to your relevant and necessity.
REPORT zr_05test_table.
PARAMETERS: p_tname TYPE tabname OBLIGATORY, "database table name
p_nrows TYPE i. "No.of rows
DATA: v_count TYPE c LENGTH 20,
t_fcat TYPE slis_t_fieldcat_alv,
x_layout TYPE slis_layout_alv,
w_dref TYPE REF TO data.
FIELD-SYMBOLS <t_tab> TYPE STANDARD TABLE.
AT SELECTION-SCREEN.
IF NOT p_tname IS INITIAL.
SELECT SINGLE tabname
FROM dd02l
INTO v_count
WHERE tabname EQ p_tname
AND as4vers EQ ' '
AND as4local EQ 'A'
AND tabclass NE 'INTTAB'
AND tabclass NE 'APPEND'.
IF sy-subrc <> 0.
MESSAGE 'No table name exist with entered value' TYPE 'E'.
ENDIF.
ENDIF.
IF p_nrows IS INITIAL.
SET CURSOR FIELD 'p_nrows'.
MESSAGE 'Enter The No. of rows' TYPE 'E'.
ENDIF.
START-OF-SELECTION.
CREATE DATA w_dref TYPE STANDARD TABLE OF (p_tname).
ASSIGN w_dref->* TO <t_tab>.
IF <t_tab> IS INITIAL.
SELECT *
FROM (p_tname)
INTO TABLE <t_tab>
UP TO p_nrows ROWS.
IF sy-subrc EQ 0.
PERFORM catalog.
PERFORM display.
ENDIF.
ENDIF.
*&---------------------------------------------------------------------*
*& Form CATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM catalog .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' "To create fieldcatalog
EXPORTING
i_program_name = sy-repid
i_structure_name = p_tname "put your structure name here
CHANGING
ct_fieldcat = t_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM. " CATALOG
*&---------------------------------------------------------------------*
*& Form DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display .
x_layout-zebra = 'X'.
x_layout-colwidth_optimize = abap_true.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = x_layout
it_fieldcat = t_fcat
TABLES
t_outtab = <t_tab>
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM. " DISPLAY
Regards
Syed
2014 Jan 17 7:15 PM
Thanks for your info,
I used RTTS concept to resolve this issue and it works fine.
Dileep.