‎2006 Jun 09 2:54 PM
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
‎2006 Jun 09 3:01 PM
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
‎2006 Jun 09 2:58 PM
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
‎2006 Jun 09 2:59 PM
‎2006 Jun 09 3:00 PM
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.
‎2006 Jun 09 3:01 PM
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
‎2006 Jun 09 3:03 PM
Hi Fabian,
Please go through these links...
http://help.sap.com/saphelp_nw04/helpdata/en/79/c55497b3dc11d5993800508b6b8b11/content.htm
Regards,
SP.