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 data reference to a table that is known at runtime

Fabian_Kegel
Product and Topic Expert
Product and Topic Expert
0 Likes
912

Hi,

I am trying to create a data reference to a table that is known only at runtime. In system 4.6C, I am not able to insert this coding

data: lr_data type ref to data.

CREATE DATA lr_data type table of (structure_name).

In hihger releases, I am able to do so.

Could you please tell me how to solve this problem in 4.6C?

Best regards,

Fabian

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
767

Hi

I'm working on 4.6C and that statament isn't supported here, but only from 4.7.

In 4.6C you can use the class CL_ALV_TABLE_CREATE

Max

5 REPLIES 5
Read only

Former Member
0 Likes
767

Hi Fabian

May be the data reference to a table is not possible in versions below 4.7E. So is why you are unable to do that.

Regards,

Santosh

Read only

andreas_mann3
Active Contributor
0 Likes
767

hi,

use fm ALV_TABLE_CREATE

and search hear in forum and weblogs for your problem

e.g.:

A.

Read only

Former Member
0 Likes
766

Hi fabian,

If i understood,

u want to create a dynamic internal table.

1.

For this purpose,

in my program,

there is an INDEPENDENT FORM

whose inputs are

TABLE NAME / STRUCTURE NAME

and from those, it consructs dynamic table.

2. Here is the program.

the dynamic table name will be

<DYNTABLE>.

3. U can use this program (FORM in this program)

to generate any kind of internal table

by specifying TABLE NAME .

4.

REPORT abc.

*----


COMPULSORY

FIELD-SYMBOLS: <dyntable> TYPE ANY TABLE.

FIELD-SYMBOLS: <dynline> TYPE ANY.

DATA: lt TYPE lvc_t_fcat.

DATA: ls TYPE lvc_s_fcat.

FIELD-SYMBOLS: <fld> TYPE ANY.

DATA : fldname(50) TYPE c.

*----


parameters : iname LIKE dd02l-tabname.

*----


START-OF-SELECTION.

*----


PERFORM

PERFORM mydyntable USING lt.

BREAK-POINT.

*----


  • INDEPENDENT FORM

*----


FORM mydyntable USING ptabname.

*----


Create Dyn Table From FC

FIELD-SYMBOLS: <fs_data> TYPE REF TO data.

FIELD-SYMBOLS: <fs_1>.

FIELD-SYMBOLS: <fs_2> TYPE ANY TABLE.

DATA: lt_data TYPE REF TO data.

data : lt TYPE lvc_t_fcat .

DATA : ddfields LIKE ddfield OCCURS 0 WITH HEADER LINE.

*----


CALL FUNCTION 'DD_NAMETAB_TO_DDFIELDS'

EXPORTING

tabname = iname

TABLES

ddfields = ddfields.

.

*----


CONSTRUCT FIELD LIST

LOOP AT ddfields.

ls-fieldname = ddfields-fieldname.

APPEND ls TO lt.

ENDLOOP.

ASSIGN lt_data TO <fs_data>.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = lt

IMPORTING

ep_table = <fs_data>

EXCEPTIONS

generate_subpool_dir_full = 1

OTHERS = 2.

IF sy-subrc <> 0.

ENDIF.

*----


Assign Dyn Table To Field Sumbol

ASSIGN <fs_data>->* TO <fs_1>.

ASSIGN <fs_1> TO <fs_2>.

ASSIGN <fs_1> TO <dyntable>.

ENDFORM. "MYDYNTABLE

regards,

amit m.

Read only

Former Member
0 Likes
768

Hi

I'm working on 4.6C and that statament isn't supported here, but only from 4.7.

In 4.6C you can use the class CL_ALV_TABLE_CREATE

Max

Read only

Former Member
0 Likes
766