Skip to Content
0
Former Member
Sep 23, 2014 at 07:06 PM

How to set the structure of the ALV due to RTTS

302 Views

Hey experts I have the following code:

TABLES: zbr_t_kniznice.

DATA: it_component TYPE cl_abap_structdescr=>component_table .

DATA: st_component LIKE LINE OF it_component .

DATA : it_tabdescr TYPE abap_compdescr_tab,

wa_tabdescr TYPE abap_compdescr.

DATA:

it_fields TYPE TABLE OF dfies,

wa_fields TYPE dfies.

DATA: r_data_tab TYPE REF TO data,

r_data_str TYPE REF TO data,

wa_fieldcat TYPE lvc_s_fcat,

it_fieldcat TYPE lvc_t_fcat.

IF <table> IS NOT ASSIGNED.

st_component-name = 'KNIZNICA'.

st_component-type ?= cl_abap_elemdescr=>describe_by_data( zbr_t_kniznice-nazov ).

APPEND st_component TO it_component.

st_component-name = 'ID_KNIHY'.

st_component-type ?= cl_abap_elemdescr=>describe_by_data( zbr_t_knihy-id_knihy ).

APPEND st_component TO it_component.

st_component-name = 'ZANER'.

st_component-type ?= cl_abap_elemdescr=>describe_by_data( zbr_t_kategorie-nazov ).

APPEND st_component TO it_component.

st_component-name = 'VYDAVATELSTVO'.

st_component-type ?= cl_abap_elemdescr=>describe_by_data( zbr_t_vydavatels-obchodne_meno ).

APPEND st_component TO it_component.

st_component-name = 'JAZYK'.

st_component-type ?= cl_abap_elemdescr=>describe_by_data( zbr_t_kniznice-id_kniznice ).

APPEND st_component TO it_component.

CALL FUNCTION 'DDIF_FIELDINFO_GET'

EXPORTING

tabname = 'zbr_t_knihy'

TABLES

dfies_tab = it_fields

EXCEPTIONS

not_found = 1

internal_error = 2

OTHERS = 3.

LOOP AT it_fields INTO wa_fields.

CHECK wa_fields-fieldname(2) NE 'ID'.

CHECK wa_fields-fieldname NE 'MANDT'.

st_component-name = wa_fields-fieldname.

st_component-type ?= cl_abap_elemdescr=>describe_by_name( wa_fields-rollname ).

APPEND st_component TO it_component .

ENDLOOP.

TRY.

ob_abap_structdescr = cl_abap_structdescr=>create( it_component ).

CATCH cx_sy_struct_creation .

ENDTRY.

TRY.

ob_abap_tabledescr = cl_abap_tabledescr=>create( ob_abap_structdescr ).

CATCH cx_sy_table_creation .

ENDTRY.

CREATE DATA: r_data_tab TYPE HANDLE ob_abap_tabledescr ,

r_data_str TYPE HANDLE ob_abap_structdescr .

ASSIGN r_data_tab->* TO <table>.

ASSIGN r_data_str->* TO <wa_table>.

My outtab is <table>. I want to display it in ALV, but I don't know how to set the structure of the ALV in CALL METHOD r_grid2->set_table_for_first_display. Can you help me with it? Can I use the it_component for it? If yes how? Should I create an fieldcatalog? How can I get the requiered datas from it_component to my fieldcatalog? I would need the exact code, because I'm lost a lot. Thank you.

Regards,

Robert