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 create a table

Former Member
0 Likes
639

hye all,

i have a field symbol which has the name of my data base table.<f_table>

1.Now i want an internal table which is again a field symbol with structure of the database table <f_table>.

2. I want to update the contents of data base table with the name <f_table>.

Please help me.

Thanks.

imran

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
622

Hi,

FIELD-SYMBOLS:

<gt_table> TYPE STANDARD TABLE.

gr_structdescr ?= cl_abap_structdescr=>describe_by_name( <f_table ).

gr_tabledescr ?= cl_abap_tabledescr=>create( gr_structdest ).

CREATE DATA gr_dref TYPE HANDLE gr_tabledescr.

ASSIGN gr_dref-> TO <gt_table>.*

Reply back..

With Rgds,

S.Barani

5 REPLIES 5
Read only

Former Member
0 Likes
622

How about this:


DATA:
  gr_structdescr  TYPE REF TO cl_abap_structdescr,
  gr_tabldesct    TYPE REF TO cl_abap_tabledescr,
  gr_dref         TYPE REF TO data.

FIELD-SYMBOLS:
  <gt_table>  TYPE STANDARD TABLE.

gr_structdescr ?= cl_abap_structdescr=>describe_by_name( <f_table ).
gr_tabledescr ?= cl_abap_tabledescr=>create( gr_structdest ).

CREATE DATA gr_dref TYPE HANDLE gr_tabledescr.
ASSIGN gr_dref->* TO <gt_table>.

* now field-symbol <GT_TABLE> points to an internal standard
* table with the same structure as the DDIC table specified in
* <F_TABLE>

Read only

Former Member
0 Likes
622

All the columns are not getting copied, into the output field symbol.

Any better solution to over come this.

Read only

0 Likes
622

Please quote the code that is executed to fill the internal table! I don´t think this issues reason is the dynamically creation of the internal table...

Read only

Former Member
0 Likes
623

Hi,

FIELD-SYMBOLS:

<gt_table> TYPE STANDARD TABLE.

gr_structdescr ?= cl_abap_structdescr=>describe_by_name( <f_table ).

gr_tabledescr ?= cl_abap_tabledescr=>create( gr_structdest ).

CREATE DATA gr_dref TYPE HANDLE gr_tabledescr.

ASSIGN gr_dref-> TO <gt_table>.*

Reply back..

With Rgds,

S.Barani

Read only

0 Likes
622

@S BHARANIDARAN:

ATTENTION:

the code quoted by you only creates and initializes the internal table, it does not fill the internal table!