‎2010 Oct 07 5:04 PM
Hey everyone,
I need to realize a method which creates dynamically a fieldcatalog. The call of the method looks like this:
CALL METHOD me->describe_struct_for_fcat
EXPORTING
im_tab = it_data. "type: data
I have a vague idea how to do this:
1. get the type of the im_tab
2. Some kind of loop at the type of the im_tab where filling the row for the fcat and appending it to the fcat.
I would be pleased if you can post a code snippet or something, which I can copy.
Looking forward to your answers.
BR Fabian
‎2010 Oct 07 5:52 PM
As Keshav T suggested, use the SALV model to generate the ALV for your dynamic table. You can look the program SALV_DEMO_TABLE_SIMPLE.
Regards,
Naimesh Patel
‎2010 Oct 07 5:13 PM
Hi,
Check the code written in method factory of class CL_SALV_TABLE.
Or wait for our friend Marcin till he gives a clear & detailed explanation
‎2010 Oct 07 5:52 PM
As Keshav T suggested, use the SALV model to generate the ALV for your dynamic table. You can look the program SALV_DEMO_TABLE_SIMPLE.
Regards,
Naimesh Patel
‎2010 Oct 07 8:01 PM
try this, but note, you will have do figure out how to get the correct length and decimals for field types P or I
REPORT ZCA_BOB_CL_ABAP_STRUCTDESCR_X.
Data: r_descr type REF TO cl_abap_structdescr,
wa_comp TYPE abap_compdescr.
types: begin of wa_int_tab,
mandt type mandt,
matnr type matnr,
werks type WERKS_D,
lgort type LGORT_D,
min_qty type MINLF,
end of wa_int_tab.
data: it_int_tab TYPE STANDARD TABLE OF wa_int_tab.
data: wk_int_tab like LINE OF it_int_tab.
Data: wk_length(6) type n,
wk_decimals(6) type n.
START-OF-SELECTION.
r_descr ?= cl_abap_typedescr=>describe_by_data( wk_int_tab ).
Loop at r_descr->components into wa_comp.
If wa_comp-type_kind = 'C'
or wa_comp-type_kind = 'D'
or wa_comp-type_kind = 'N'.
Divide wa_comp-length by 2.
Else.
** go out to tables DD03L and DD04L to get LENG and DECIMALS
Endif.
write:/ wa_comp-name,
wa_comp-type_kind,
wa_comp-length,
wa_comp-decimals.
EndLoop.
‎2010 Oct 07 8:22 PM
Hi Bob,
thank you so much for your post! That is exactly what i was looking for!! Perfect!