Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- report rtti.
- tables bkpf.
- select-options so_bukrs for bkpf-bukrs.
- select-options so_belnr for bkpf-belnr.
- select-options so_gjahr for bkpf-gjahr.
- class rtti definition create private final.
- public section.
- types tt_fieldname type standard table of fieldname with non-unique default key.
- class-methods get_fieldname
- importing ia_any type any
- returning value(rt) type tt_fieldname.
- private section.
- endclass.
- class rtti implementation.
- method get_fieldname.
- data lo_typedescr type ref to cl_abap_typedescr.
- data lo_tabledescr type ref to cl_abap_tabledescr.
- data lo_structdescr type ref to cl_abap_structdescr.
- data lv_fieldname like line of rt.
- data lt_dfies type ddfields.
- data ls_dfies type dfies.
- lo_typedescr = cl_abap_typedescr=>describe_by_data( ia_any ).
- case lo_typedescr->kind.
- when cl_abap_typedescr=>kind_struct.
- lo_structdescr ?= lo_typedescr.
- when cl_abap_typedescr=>kind_table.
- lo_tabledescr ?= lo_typedescr.
- lo_structdescr ?= lo_tabledescr->get_table_line_type( ).
- when others. assert 1 = 2.
- endcase.
- lt_dfies = cl_salv_data_descr=>read_structdescr( lo_structdescr ).
- loop at lt_dfies into ls_dfies.
- lv_fieldname = ls_dfies-fieldname.
- append lv_fieldname to rt.
- endloop.
- endmethod.
- endclass.
- class lcl_app definition create private final.
- public section.
- class-methods new returning value(ro_instance) type ref to lcl_app.
- methods run.
- private section.
- endclass.
- start-of-selection.
- lcl_app=>new( )->run( ).
- class lcl_app implementation.
- method new.
- create object ro_instance.
- endmethod.
- method run.
- types: begin of ts_example,
- bukrs type bkpf-bukrs,
- belnr type bkpf-belnr,
- gjahr type bkpf-gjahr,
- end of ts_example.
- data lt_fieldname type rtti=>tt_fieldname.
- data lt_example type table of ts_example.
- data lo_grid type ref to cl_salv_table.
- lt_fieldname = rtti=>get_fieldname( lt_example ).
- select (lt_fieldname)
- from bkpf into table lt_example
- where bukrs in so_bukrs
- and belnr in so_belnr
- and gjahr in so_gjahr.
- call method cl_salv_table=>factory
- importing
- r_salv_table = lo_grid
- changing
- t_table = lt_example.
- lo_grid->display( ).
- endmethod.
- endclass.
Add Comment
Please, Sign In to add comment