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

Question on Dynamic Internal Table creation

Former Member
0 Likes
674

Good day everyone.

I would like to ask if it is possible to just add several fields to an existing internal table to make it dynamic? if possible, does anyone have a sample program? thanks a lot!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
633

Hi christian,

1. I don't think we can do this.

(we can create dynamica internal tables,

right from scratch,

but we cannot add more fields

to an already existing dynamic internal table)

regards,

amit m.

5 REPLIES 5
Read only

Former Member
0 Likes
634

Hi christian,

1. I don't think we can do this.

(we can create dynamica internal tables,

right from scratch,

but we cannot add more fields

to an already existing dynamic internal table)

regards,

amit m.

Read only

0 Likes
633

Good day amit!

Ic, thanks for that info. I have another question, do you happen to know all the possible values i could use in declaring an intype for the structure of the dynamic internal table? Im having trouble looking for ways to declare a CURR (Currency) and CUKY field type for the dynamic internal table structure. Thanks!

Read only

0 Likes
633

Hi,

Instead of declaring as a specific data type probably in case of currency you can take help of a data element of the currency type.

DATA : W_CURR TYPE REF TO DATA

CREATE DATA W_CURR TYPE xxxx.

XXX POINTS TO A DATA ELEMENT OF THE curr DATA TYPE.

Regards,

Ravi

Read only

Former Member
0 Likes
633

Hi,

Yes, I agree with Amit Mittal,

You can create dynamic internal tables start,0

but you can't add more fields to an already existing internal table.

Regards,

Read only

Former Member
0 Likes
633

Hi Christian,

Refer the following code. It may help you.

Reward points if it helps.

REPORT ZDSAP .

DATA: d_ref TYPE REF TO data,

d_ref2 TYPE REF TO data ,

i_alv_cat TYPE TABLE OF lvc_s_fcat,

ls_alv_cat LIKE LINE OF i_alv_cat.

TYPES tabname LIKE dcobjdef-name .

parameter: p_tablen type tabname.

data: begin of itab occurs 0.

INCLUDE STRUCTURE dntab.

data: end of itab.

FIELD-SYMBOLS : <F_FS> TYPE table, 
<F_FS1> TYPE TABLE, 
<F_FS2> TYPE ANY, 
<F_FS3> TYPE TABLE. 

REFRESH itab. 
CALL FUNCTION 'NAMETAB_GET' 
EXPORTING 
langu = sy-langu 
tabname = p_tablen 
TABLES 
nametab = itab 

EXCEPTIONS 
no_texts_found = 1. 
LOOP AT itab . 
ls_alv_cat-fieldname = itab-fieldname. 
ls_alv_cat-ref_table = p_tablen. 
ls_alv_cat-ref_field = itab-fieldname. 
APPEND ls_alv_cat TO i_alv_cat. 
ENDLOOP. 
* internal table build 
CALL METHOD cl_alv_table_create=>create_dynamic_table 
EXPORTING it_fieldcatalog = i_alv_cat 
IMPORTING ep_table = d_ref . 
ASSIGN d_ref->* TO <F_FS>. 

SELECT * FROM (p_tablen) INTO CORRESPONDING FIELDS OF TABLE <F_FS>. 


LOOP AT <F_FS> ASSIGNING <F_FS2>. 
*your code goes here. 
ENDLOOP.