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

Create a dynamic Table from another table

former_member215107
Active Participant
0 Likes
923

Dear All,

I have a table TOTO of 1 column and n lines.

From TOTO, i want to create a table TITI with following requirement:

Number Columns = n lines

How can i proceed ?

Rodolphe.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
894

Hi Rodolphe,

Create the Dynamic Internal table using the Following method.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

i_style_table = gc_yes

it_fieldcatalog = it_fieldcatalog

IMPORTING

ep_table = lr_table

e_style_fname = mv_style_fname."name for style table

Regards,

Deepak.

6 REPLIES 6
Read only

Former Member
0 Likes
893

This message was moderated.

Read only

Former Member
0 Likes
893

This message was moderated.

Read only

0 Likes
893

They are not getting deleted automatically!

They are being deleted by the moderators because you are violating the rules of this forum. This is the right time for you to read the rules to avoid getting your id deleted.

pk

Read only

Former Member
0 Likes
895

Hi Rodolphe,

Create the Dynamic Internal table using the Following method.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

i_style_table = gc_yes

it_fieldcatalog = it_fieldcatalog

IMPORTING

ep_table = lr_table

e_style_fname = mv_style_fname."name for style table

Regards,

Deepak.

Read only

former_member215107
Active Participant
0 Likes
893

Yes UmaDave ... strange...

Thanks

Read only

Former Member
0 Likes
893

Hi Rodolphe,

using cl_alv_table_create=>create_dynamic_table may raise exception generate_subpool_dir_full after 36 times (memory issue)

try the following code:

TYPES: BEGIN OF ty_toto,
        col TYPE i,
       END OF ty_toto.

DATA it_toto     TYPE TABLE OF ty_toto.
DATA wa_toto     TYPE          ty_toto.
DATA v_lines     TYPE          i.

DATA dref        TYPE REF TO   data.
DATA struct_type TYPE REF TO   cl_abap_structdescr.
DATA comp_tab    TYPE          cl_abap_structdescr=>component_table.
DATA comp        LIKE LINE OF  comp_tab.

DATA v_col_name  TYPE string.

FIELD-SYMBOLS: <titi> TYPE ANY.

* Create table content
DO 10 TIMES.
  wa_toto-col = sy-index.
  APPEND wa_toto TO it_toto.
ENDDO.

DESCRIBE TABLE it_toto LINES v_lines.

* Define structure
DO v_lines TIMES.
  v_col_name = sy-index.
  CONCATENATE 'COL_LINE_' v_col_name INTO v_col_name.
  CONDENSE v_col_name NO-GAPS.
  comp-name = v_col_name.
  comp-type = cl_abap_elemdescr=>get_i( ).
  APPEND comp TO comp_tab.
ENDDO.

* Create Table
struct_type = cl_abap_structdescr=>create( comp_tab ).
CREATE DATA dref TYPE HANDLE struct_type.

* Assign table
ASSIGN dref->* TO <titi>.

regards

rea