Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Dynamically Structure

Former Member
0 Likes
543

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.

1 ACCEPTED SOLUTION
Read only

former_member210541
Active Participant
0 Likes
498

What would be the data type of the elements?

3 REPLIES 3
Read only

former_member210541
Active Participant
0 Likes
499

What would be the data type of the elements?

Read only

0 Likes
498

In this case i need char1.

Read only

0 Likes
498

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.