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

Duplicate dynamic table in - cl_alv_table_create=>create_dynamic_table

Former Member
0 Likes
1,131

Hi Gurus,

I have done the following code, but it is not treating <alv_table> and <alv_table_new> as different tables.

How can I create a duplicate table of <alv_table> in the below context ??

DATA : ldtab TYPE REF TO data,

ldtab_NEW TYPE REF TO data.

FIELD-SYMBOLS: <alv_table> TYPE table,

<alv_table_NEW> TYPE table.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = gt_fcat

IMPORTING

ep_table = ldtab.

IF sy-subrc = 0.

ldtab_new = ldtab.

ASSIGN ldtab->* TO <alv_table>.

ASSIGN ldtab_new->* TO <alv_table_new>.

ENDIF.

Regards,

Sandip.

Hi Gurus,

I have done the following code, but it is not treating <alv_table> and <alv_table_new> as different tables.

How can I create a duplicate table of <alv_table> in the below context ??

DATA : ldtab TYPE REF TO data,

ldtab_NEW TYPE REF TO data.

FIELD-SYMBOLS: <alv_table> TYPE table,

<alv_table_NEW> TYPE table.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = gt_fcat

IMPORTING

ep_table = ldtab.

IF sy-subrc = 0.

ldtab_new = ldtab.

ASSIGN ldtab->* TO <alv_table>.

ASSIGN ldtab_new->* TO <alv_table_new>.

ENDIF.

Regards,

Sandip.

5 REPLIES 5
Read only

former_member755502
Participant
0 Likes
1,032

hi,

Both field symbols i.e. <alv_table> and <alv_table_new> are pointing to same memory area because of the statements

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = gt_fcat

IMPORTING

ep_table = ldtab.

IF sy-subrc = 0.

ldtab_new = ldtab. <----


do not perform this step

ASSIGN ldtab->* TO <alv_table>.

ASSIGN ldtab_new->* TO <alv_table_new>.

endif.

instead write -

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = gt_fcat

IMPORTING

ep_table = ldtab.

IF sy-subrc = 0.

ASSIGN ldtab->* TO <alv_table>.

endif.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = gt_fcat

IMPORTING

ep_table = ldtab_new.

IF sy-subrc = 0.

ASSIGN ldtab_new->* TO <alv_table_new>.

endif.

try the above mentioned code.

I hope this will resolve your issue.

Regards,

Sambaran Ray

Read only

Clemenss
Active Contributor
0 Likes
1,032

Hi Sandip,

cl_alv_table_create=>create_dynamic_table is no good, use run time type services instead, search for CL_ABAP_TYPEDESCR.

Anyway,

ASSIGN ldtab->* TO <alv_table>.
CREATE DATA ldtab_new like  <alv_table>.
ASSIGN ldtab_new->* TO <alv_table_new>.

creates a second internal table like the first one - not pointing to the same memory area.

Regards,

Clemens

Read only

Former Member
0 Likes
1,032

You can refer to these two articles for two different ways of creating dynamic internal table-

http://www.divulgesap.com/blog.php?p=MTI4

http://www.divulgesap.com/blog.php?p=MjE=

Hope it helps.

Regards,

Lak

Read only

Former Member
0 Likes
1,032

Hi Sandip,

Have a look at this following Wiki . It clearly explains the way you can create Multiple dynamic Internal Tables.

http://wiki.sdn.sap.com/wiki/display/Snippets/CreateMultipleDynamic+Tables

Hope this will help.

Thanks,

Samantak.

Read only

Former Member
0 Likes
1,032

Hello Sandip,

SDN is full of material on how to create dynamic internal table but my only advice is to not to use static method from class cl_alv_table_create=>create_dynamic_table. Instead you can refer to ABAP RTTS (Run Time Type Services) for creating dynamic internal tables.

Thanks,

Augustin.