03-12-2010 4:06 PM
Hi all,
I want to hide some columns in ALV which are empty on display when calling
cl_gui_alv_grid->set_table_for_first_display
That is to say the internaltable will contain empty columns.
I know that using the "no_out" attribute of field catalog we can hide columns.
But the question is how to find these columns which are empty - should I have to loop through the itab to find it out OR
Can we set it in ALV LAYOUT or field catalog attributes so that it wont display empty columns.
any help is appreciated....
Thanks
P
Edited by: pazzuzu on Mar 12, 2010 5:14 PM
03-12-2010 4:20 PM
Im not sure about this,
you can try
like get all the fields of the internal table.
There are some classes available for this.
Then loop for each field name like for ex.
loop at it_fldname into wa.
read table it_data with key <wa-fieldnames> ne space transporting no fields. " i know not equal to is not possible here ( its just an idea).
if sy-subrc = 0.
column contains data
endif.
endloop.
03-12-2010 4:20 PM
Im not sure about this,
you can try
like get all the fields of the internal table.
There are some classes available for this.
Then loop for each field name like for ex.
loop at it_fldname into wa.
read table it_data with key <wa-fieldnames> ne space transporting no fields. " i know not equal to is not possible here ( its just an idea).
if sy-subrc = 0.
column contains data
endif.
endloop.
03-13-2010 9:47 AM
Thanks keshav...Any more ideas
so using ALV properties is it not possible to hide empty columns?
03-13-2010 7:33 PM
hi pazzuzu,
i think your question has the answer in it:
you have to first which columns are empty from your itab only and then accordingly dynamically compose your fieldcat using either the no-out property or not filling that field in the fieldcat itself.
thanks
Sachin Soni
03-13-2010 8:17 PM
03-13-2010 9:59 PM
03-15-2010 3:39 PM
how to find these columns which are empty
Please let me know how you got the solution ?
03-15-2010 4:08 PM
Hi,
If i understood your question correctly,
The you can try this
TYPE-POOLS:slis,abap.
TYPES:BEGIN OF ty,
f1 TYPE c,
f2 TYPE c,
f3 TYPE c,
f4 TYPE c,
END OF ty.
DATA:it TYPE TABLE OF ty,
wa TYPE ty,
wa_field TYPE slis_fieldcat_alv,
i_fieldcat TYPE TABLE OF slis_fieldcat_alv,
i_details TYPE abap_compdescr_tab,
wa_comp TYPE abap_compdescr,
ref_descr TYPE REF TO cl_abap_structdescr,
lv_field TYPE abap_compname.
FIELD-SYMBOLS:<fs>,
<fs1>.
ref_descr ?= cl_abap_typedescr=>describe_by_data( wa ).
i_details[] = ref_descr->components[].
wa-f1 = 'A'.
wa-f3 = 'C'.
APPEND wa TO it.
wa-f1 = 'X'.
wa-f3 = 'Y'.
APPEND wa TO it.
if it[] is not initial.
LOOP AT i_details INTO wa_comp.
ASSIGN wa_comp-name TO <fs>.
SORT it BY (<fs>) DESCENDING.
CONCATENATE 'WA' '-' <fs> INTO lv_field .
ASSIGN (lv_field) TO <fs1>.
READ TABLE it INTO wa INDEX 1 transporting (<fs>).
IF sy-subrc = 0 AND <fs1> IS NOT INITIAL.
wa_field-fieldname = wa_comp-name.
wa_field-seltext_m = wa_comp-name.
APPEND wa_field TO i_fieldcat.
ENDIF.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = i_fieldcat[]
TABLES
t_outtab = it[].
endif.
03-15-2010 6:43 PM
Hi keshav,
I didnt try it in code but that looks more or less like it...