‎2006 Jan 17 8:23 AM
Hello!
I have created a program that extensively uses dynamic internal tables. However, I faced an annoying limitation regarding internal tables. I made this little sample program to let you see what's going on:
REPORT ZTEST.
DATA: t_fcat TYPE lvc_t_fcat,
dt_outtab TYPE REF TO DATA.
FIELD-SYMBOLS: <tab> TYPE STANDARD TABLE.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING i_structure_name = 'CSKS'
CHANGING ct_fieldcat = t_fcat.
DO 100 TIMES.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING it_fieldcatalog = t_fcat
IMPORTING ep_table = dt_outtab
EXCEPTIONS generate_subpool_dir_full = 1
others = 2.
IF sy-subrc = 0.
WRITE / sy-index.
ELSE.
WRITE: / 'Error - sy-subrc = ', sy-subrc.
EXIT.
ENDIF.
ENDDO.
WRITE / 'End'.By using this program I found out that I can create no more than 36 internal tables for each program run. At the 37th one, the program raises an exception GENERATE_SUBPOOL_DIR_FULL.
Each method call creates a subroutine pool that stores a table, and obviously their number is limited somehow, in my case to 36.
At this point I must ask user to leave the program and start again, which is really not a feature of a professional application.
Now what I'd like to do first is to find a way to destroy a subroutine pool when an internal table is no longer needed (FREE-ing just table won't work - I tried). However, I don't know how.
Even if I succeeded, it would only mean extending the limits, while I'd like to have the solution with no limits.
Are there any experiences with this?
Thanks in advance!
Kind regards,
Igor
‎2006 Jan 17 8:49 AM
Hi
If you're using 4.7 you can create a dynamic internal table without to use the method create_dynamic_table.
Infatc here it allow the following statament:
CREATE DATA <REF> TYPE <TYPE TABLE> TABLE OF <TYPE LINE>
[WITH [UNIQUE|NON-UNIQUE] keydef] [INITIAL SIZE n].
For example:
DATA: my_table TYPE REF TO data.
DATA: table_name(30).
FIELD-SYMBOLS: <my_table> TYPE table.
table_name = 'CSKS'.
CREATE DATA my_table TYPE STANDARD TABLE OF (table_name).
You can also use LIKE if you want to create a table like a structure defined in program:
CREATE DATA <REF> LIKE <TYPE TABLE> TABLE OF <TYPE LINE>
but now it has to indicate explicitly the structure.
DATA: BEGIN OF itab,
field1,
field2,
END OF itab.
CREATE DATA my_table LIKE STANDARD TABLE OF itab.
But you can use this statament:
TYPES: BEGIN OF ty_itab,
field1,
field2,
END OF ty_itab.
table_name = 'TY_ITAB'.
CREATE DATA my_table TYPE STANDARD TABLE OF (table_name).
Max
‎2006 Jan 17 8:49 AM
Hi
If you're using 4.7 you can create a dynamic internal table without to use the method create_dynamic_table.
Infatc here it allow the following statament:
CREATE DATA <REF> TYPE <TYPE TABLE> TABLE OF <TYPE LINE>
[WITH [UNIQUE|NON-UNIQUE] keydef] [INITIAL SIZE n].
For example:
DATA: my_table TYPE REF TO data.
DATA: table_name(30).
FIELD-SYMBOLS: <my_table> TYPE table.
table_name = 'CSKS'.
CREATE DATA my_table TYPE STANDARD TABLE OF (table_name).
You can also use LIKE if you want to create a table like a structure defined in program:
CREATE DATA <REF> LIKE <TYPE TABLE> TABLE OF <TYPE LINE>
but now it has to indicate explicitly the structure.
DATA: BEGIN OF itab,
field1,
field2,
END OF itab.
CREATE DATA my_table LIKE STANDARD TABLE OF itab.
But you can use this statament:
TYPES: BEGIN OF ty_itab,
field1,
field2,
END OF ty_itab.
table_name = 'TY_ITAB'.
CREATE DATA my_table TYPE STANDARD TABLE OF (table_name).
Max
‎2006 Jan 17 8:57 AM
hi max,
i have a doubt,
with the method, create dynamic table , we can pass the fieldcat and get the internal table from the catalog.
but how can u create like that in ur example..
regards
hyma
‎2006 Jan 17 9:05 AM
Wow, that was quick, and it works too!
Thanks, Max, that's what I needed.
Hyma, you asked a legitimate question regarding fieldcatalog, and in this case the problem persists. However, I believe one can live without it.
‎2006 Jan 17 9:07 AM
Hi
You should use that method only if you have to define the structure of your table at runtime, so you use the catalog table to do that.
But if you know your structure, because it's just defined in dictionary or in the program, it's useless to use that method, because you can directly create your dynamic table.
But it can do this only from rel 4.7.
Max