2015 Sep 01 9:10 AM
HI ABAP'ERS,
I possible to create dynamically structure with random number, when in Selection-screen give size of this structure. For example in SS give 20 to program create a structure with 20 rows and 20 column in char type? I search but i don't see anythink good for me.
2015 Sep 01 9:24 AM
2015 Sep 01 9:24 AM
2015 Sep 01 9:43 AM
2015 Sep 01 10:03 AM
Write this code. Hope it helps
PARAMETERS : num TYPE i.
DATA : gt_dyn_table TYPE REF TO data,
gw_line TYPE REF TO data,
gw_line1 TYPE REF TO data.
FIELD-SYMBOLS: <gfs_dyn_table> TYPE ANY TABLE.
DATA : gw_dyn_fcat TYPE lvc_s_fcat,
gv_pos(4) TYPE n,
gt_dyn_fcat TYPE lvc_t_fcat.
DATA : str TYPE string.
DO num TIMES.
gv_pos = gv_pos + 1.
CLEAR str.
CONCATENATE 'FIELD' gv_pos INTO str .
gw_dyn_fcat-fieldname = str.
gw_dyn_fcat-outputlen = 1.
gw_dyn_fcat-col_pos = gv_pos.
APPEND gw_dyn_fcat TO gt_dyn_fcat.
CLEAR gw_dyn_fcat.
ENDDO.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_dyn_fcat
IMPORTING
ep_table = gt_dyn_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
IF sy-subrc EQ 0.
ASSIGN gt_dyn_table->* TO <gfs_dyn_table>.
ENDIF.