
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 |