Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
sahai
Contributor

TYPES  : BEGIN OF ty_prn,   " This is a structure having three columns or pernr, suby and objps  pernr TYPE persno,  subty TYPE subty,  objps TYPE objps,

END OF ty_prn.

FIELD-SYMBOLS : <f1> TYPE any,

               <f2> type TABLE .

  data: dy_table type ref to data,

      dy_line  type ref to data,

      xfc type lvc_s_fcat,

      ifc type lvc_t_fcat.

data : idetails type abap_compdescr_tab,

       xdetails type abap_compdescr.

  data : ref_table_des type ref to cl_abap_structdescr.

DATA : prn TYPE STANDARD TABLE OF ty_prn, " table and workarea of this type        wa LIKE LINE OF prn.


data : str TYPE STring.CONCATENATE 'PA' infotype INTO str. " concatenating PA as database table in HR ABAP have naming convention PAnnnnref_table_des ?=  cl_abap_typedescr=>describe_by_name( str ). " getting the structure of the table name dynamically  idetails[] = ref_table_des->components[].                                  " reading the columns name dynamicaly


    loop at idetails into xdetails.                                                    " loop at the columns name and passing these in  a field catalogue    clear xfc.    xfc-fieldname = xdetails-name .    xfc-datatype = xdetails-type_kind.    xfc-inttype = xdetails-type_kind.    xfc-intlen = xdetails-length.    xfc-decimals = xdetails-decimals.    append xfc to ifc.  endloop.


  call method cl_alv_table_create=>create_dynamic_table              "                exporting                  it_fieldcatalog = ifc               importing                  ep_table        = dy_table.    assign dy_table->* to <f2>.    " now we can directly select from table into this <f2> as any normal internal table.

3 Comments