Creation of a dynamic internal table

by Diwakar

report  ZTest .
 
type-pools: slis.
 
field-symbols: <dyn_table> type standard table,
                          <dyn_wa>.
 
data: alv_fldcat type slis_t_fieldcat_alv,
          it_fldcat type lvc_t_fcat.
 
data: it001 type table of t001 with header line.
 
selection-screen begin of block b1 with frame title text-001.
select-options: s_bukrs for it001-bukrs.
selection-screen end of block b1.
 
start-of-selection.
 
  select * into table it001 from t001
                 where bukrs in s_bukrs.
 
  perform build_dyn_itab.
 
 ************************************************************************
*  Build_dyn_itab
************************************************************************
form build_dyn_itab.
 
  data: index(3) type c.
 
  data: new_table type ref to data,
        new_line  type ref to data,
        wa_it_fldcat type lvc_s_fcat.
 
  clear wa_it_fldcat.
  wa_it_fldcat-fieldname = 'PERIOD' .
  wa_it_fldcat-datatype = 'CHAR'.
  wa_it_fldcat-intlen = 6.
  append wa_it_fldcat to it_fldcat .
 
  loop at it001.
    clear wa_it_fldcat.
    wa_it_fldcat-fieldname = it001-bukrs .
    wa_it_fldcat-datatype = 'CHAR'.
    wa_it_fldcat-intlen = 4.
    append wa_it_fldcat to it_fldcat .
  endloop.
 
 * Create dynamic internal table and assign to FS
  call method cl_alv_table_create=>create_dynamic_table
               exporting
                  it_fieldcatalog = it_fldcat
               importing
                  ep_table        = new_table.
 
  assign new_table->* to <dyn_table>.
 
* Create dynamic work area and assign to FS
  create data new_line like line of <dyn_table>.
  assign new_line->* to <dyn_wa>.
 
endform.



 

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image