‎2010 Aug 29 7:31 PM
Hi All,
Can anyone tell me how to generate a reference to the structure dynamically without using statement
1) GENERATE SUB-ROUTINE POOL and
2) passing the referebce to field-symbol
My structure fields are present in an internal table(with some other fields as well)
Eg: Internal table contains Field1,field2......upto Field 10.
But i need the reference to the structure only for Field1,Field /5/6/7 only.
How to do this??
Thanks,
Madan
‎2010 Aug 29 7:53 PM
Can you elaborate your requirement ? You want to create the structure based on the fields of the previous internal table ?
‎2010 Aug 29 8:04 PM
Hi Mohan,
You can create it many ways.
1. If you have the structure name..
create data l_dref type standard table of (v_table).
assign l_dref->* to <i_master>. " Internal table
create data l_dwa like line of <i_master>.
assign l_dwa->* to <wa_master>. " Work area
2. If you don't have particular structure name. Fields properties are known
Populate fields catalog
data: l_wa_fcat type lvc_s_fcat.
l_wa_fcat-fieldname = p_field.
l_wa_fcat-datatype = 'CHAR'.
l_wa_fcat-inttype = 'C'.
l_wa_fcat-intlen = p_len.
append l_wa_fcat to i_fcat.
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = i_fcat
importing
ep_table = dy_table.
assign dy_table->* to <i_itab>. " Interanal table
create data dy_line like line of <i_itab>.
assign dy_line->* to <wa_itab>.
3. If any think you don't know unless run time (like length, type etc) Then use RTTS method
l_gs_comp-type ?= cl_abap_typedescr=>describe_by_data( v_mode ). " here v_mode is a variable and I want to add same field in the structure
l_gs_comp-name = l_field. " Structure Field name
append l_gs_comp to l_gt_components.
Create instances of dynamic structure and dynamic internal table
l_go_sdescr_new = cl_abap_structdescr=>create( l_gt_components ). " ref Stucture
l_go_tdescr = cl_abap_tabledescr=>create( l_go_sdescr_new ). " Ref Itab
Create data refence followed by table creation
create data l_gdo_handle type handle l_go_tdescr.
assign l_gdo_handle->* to <i_deep>. " Itab
create data dy_deep like line of <i_deep>.
assign dy_deep->* to <wa_deep>. " WA
Thanks
Subhankar