02-29-2012 4:42 PM
Hi all,
hope there is hope:
I love to use the CL_SALV_TABLE classes. It is very convenient that I don't need a field catalog.
Now I define a type, i.e.
TYPES:
BEGIN OF ty_data,
...
matnr TYPE mara-matnr,
datefrom TYPE eedmsettlunit-datefrom,
timefrom TYPE eedmsettlunit-timefrom,
dateto TYPE eedmsettlunit-dateto,
timeto TYPE eedmsettlunit-timeto,
...
END OF ty_data,
ty_t_data TYPE TABLE OF ty_data,
When I (fill and) display a table defined like that using method DISPLAY of class CL_SALV_TABLE, I get a nice output. I have the small square indicating F4 help, but nothing happens if I press F4.
As soon as I define a dictionary structure with the same fields as in my TYPE, everything is fine, F4 works as expected.
Is this a SALV flaw or am I just missing something?
Thanks in advance for any qualified help - not for just the case I mentioned here but in general. I want the F4 work as it always works.
Best regards,
Clemens
02-29-2012 7:17 PM
Hi Clemens,
Did you tried the method SET_DDIC_REFERENCE of class CL_SALV_COLUMNS_TABLE ? I faced similar problem in one of my developments and I used below code.
data : lr_column TYPE REF TO cl_salv_column_table,
lr_columns TYPE REF TO cl_salv_columns_table.
lr_table TYPE REF TO cl_salv_table.
data : lv_ddic type salv_s_ddic_reference.
lr_columns = lr_table->get_columns( ).
lr_column ?= lr_columns->get_column( columnname = 'MATNR' ).
move 'MATNR' to lv_ddic-field.
move 'MARA' to lv_ddic-table.
lr_column->set_ddic_reference( lv_ddic ).
Hope this helps.
Regards, Vinod
02-29-2012 7:17 PM
Hi Clemens,
Did you tried the method SET_DDIC_REFERENCE of class CL_SALV_COLUMNS_TABLE ? I faced similar problem in one of my developments and I used below code.
data : lr_column TYPE REF TO cl_salv_column_table,
lr_columns TYPE REF TO cl_salv_columns_table.
lr_table TYPE REF TO cl_salv_table.
data : lv_ddic type salv_s_ddic_reference.
lr_columns = lr_table->get_columns( ).
lr_column ?= lr_columns->get_column( columnname = 'MATNR' ).
move 'MATNR' to lv_ddic-field.
move 'MARA' to lv_ddic-table.
lr_column->set_ddic_reference( lv_ddic ).
Hope this helps.
Regards, Vinod
03-02-2021 12:16 PM
Thanks! Your solution works fine using a field with domain fixed values, setting the same table and field name.
02-29-2012 8:03 PM
The problem lies in how the Field Catalog is being built based on the Type - Data Dictionary Type vs Local Type. The logic to populate the Columns object which would be used later on for the Field catalog, is within the method DESCRIBE_TABLE of class CL_SALV_DATA_DESCR.
This the snipped of the method READ_STRUCTDESCR which calls from the method DESCRIBE_TABLE. Separate logic for DDIC based Type ...
if r_structdescr->is_ddic_type( ) = ABAP_TRUE. "<<
t_dfies = r_structdescr->get_ddic_field_list( ).
transform( changing t_dfies = t_dfies ). " <<
else.
t_components = r_structdescr->get_components( ).
loop at t_components into s_component.
...
TRANSFORM method sets the REFTABLE and REFFIELD which would be used to drive the F4.
Regards,
Naimesh Patel
02-29-2012 11:14 PM
Thank you Vinod & Naimesh,
needs some more experimenting: I prefer the local typing of structures just for the flexibility - very quick and easy add, remove, reorder fields.
I assumed by defining a field with DDIC reference like
mydate TYPE sy-datum
the system knows that there is a DDIC reference - F1 help works.
And if I call my SALV factory dynamically, I have no real way to determine how to use SET_DDIC_REFERENCE. OK, I'll do explicitly whenever I really need.
I did not try yet: If it is possible to create a dynamic type reference that could not be distinguished from a DDIC based, that could solve it.
Regards,
Clemens
03-01-2012 8:55 AM
Hi Clemens,
Extracting the VALUE TABLE of structure column and assigning the value table in SET_DDIC_REFERENCE method may be one of the solution. Statement lr_column->get_ddic_domain( ) will return the domain attached with the column & cl_reca_ddic_doma=>get_complete( ) will return the value table associated with the domain.
data : lr_column TYPE REF TO cl_salv_column_table,
lr_columns TYPE REF TO cl_salv_columns_table.
lr_table TYPE REF TO cl_salv_table.
data : lt_col_list TYPE salv_t_column_ref,
ls_col_list TYPE salv_s_column_ref,
ls_header TYPE dd01v.
ls_ddic TYPE salv_s_ddic_reference.
data : lv_domain type domname.
lr_columns = lr_table->get_columns( ).
lt_col_list = lr_columns->get( ).
LOOP AT lt_col_list INTO ls_col_list.
TRY.
lr_column ?= lr_columns->get_column( columnname = ls_col_list-columnname ).
lv_domain = lr_column->get_ddic_domain( ).
CLEAR : ls_header, lv_domain.
cl_reca_ddic_doma=>get_complete(
EXPORTING
id_name = lv_domain
IMPORTING
es_header = ls_header
EXCEPTIONS
not_found = 1
OTHERS = 2 ).
IF sy-subrc EQ 0 AND ls_header-entitytab IS NOT INITIAL.
MOVE ls_header-entitytab TO lv_ddic-table.
MOVE lv_domain TO lv_ddic-field.
lr_column->set_ddic_reference( value = lv_ddic ).
ENDIF.
CATCH cx_salv_not_found .
ENDTRY.
ENDLOOP.
Regards, Vinod