on 06-05-2014 9:02 AM
Hello all,
I have a WDA Dynamic Table and want to make some fields as mandatory fields.
can you please show me how to do this?
thank you very much
Hi,
Write the below code:
DATA: lr_table type ref to cl_wd_table,
lr_table_column type ref to cl_wd_table_column,
lr_input type ref to cl_wd_input_field.
lr_table ?= view->get_element( id = 'TABLE' ). " TABLE id ID of Table UI
* Get column
lr_table_column ?= lr_table->get_grouped_column( id = 'TABLE_COL' ). TABLE_COL is the ID of table Column
*Get Cell Editor
lr_input ?= lr_table_column->get_table_cell_editor( ).
*Set Required
lr_input->set_state( cl_wd_input_field=>e_state-required ).
hope this helps u,
Regards,
Kiran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can achieve your requirement as below
Sample:
data lo_input_field type ref to cl_wd_uie_input_field.
data lo_column type ref to cl_wd_table_column.
data lo_table type ref to cl_wd_table.
data lo_root type ref to cl_wd_ui_element_container.
" get the table reference from view root container lo_root
lo_root ?= view->get_root_element( ).
lo_table ?= lo_root->get_child( 'TABLE_NAME').
lo_column = lo_table->get_column('MATNR').
lo_input_field ?= lo_column->get_table_cell_editor( ).
if lo_input_field is bound.
lo_input_field->set_state( cl_wd_input_field=>e_state-required ).
endif.
Write the above code in wddomodifyview( ) method your view
Note: Here I have demonstrated about input field, but based on your cell editor type you collect the cell editor object reference
Hope this helps you.
Regards,
Rama
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So, if I underdtand right, you are workling with ALV tables?
The lo_column has type ref to CL_SALV_WD_COLUMN as this has the described method GET_CELL_EDITOR. (Different from the suggested GET_TABLE_CELL_EDITOR in classCL_WD_TABLE_COLUMN).
This was not clear by your initial post that suggested a standard table and no ALV
In that case, please try this:
DATA: lo_input_field TYPE REF TO CL_SALV_WD_UIE_INPUT_FIELD.
lo_column TYPE REF TO CL_SALV_WD_COLUMN
...
lo_input_field ?= lo_column->get_cell_editor( ).
lo_input_field->set_state( cl_wd_input_field=>e_state-required ).
Okay, then I've some questions:
1 -> are the fields in question editable?
2 -> are these fields input fields? All of them?
3 -> do you use the lo_input_field ?= lo_column->get_cell_editor( ). only for the specific columns? Or is there a loop at all table columns?
4 -> a code example would be helpful.
So:
1. Make sure, that you know the cell editor type of each required column.
2. Only get the cell editors from columns that are relevant.
3. Use the coding above only for cell editors that are input fields (and not e.e dropdown fields or checkbox)!
Edit:
You can check the type during runtime:
lo_column->type contains the cell editor type. In case of an input field, this should be 06.
So you may check like that:
if lo_column->type eq if_salv_wd_c_column_settings=>cell_editor_input_field.
lo_input_field ?= lo_column->get_cell_editor( ).
endif.
Hello Kai,
thanks for replay and the good explaing .
yes am Working with ALV
1 -> are the fields in question editable?
*** yes the are all editable
2 -> are these fields input fields? All of them?
** some are dropDown fields and some are Input Fields
and Also by Input Fields, i get only the Red Star Icon (*) but if i klick on save, everything will be saved even if the fields has this red satr icon ( *)
and it will not recognized as Mandatory Field
waht shall I do to make Drop Down also mandatory
Regards
Agadir
Okay, are they Dropdown by Key (or by Index)
In case of Dropdown by Keys replace the lo_input_field with
lo_ddk ( Type Ref To CL_SALV_WD_UIE_DROPDOWN_BY_KEY)
In case of Dropdown by Index replace with:
lo_ddi (Type Ref to CL_SALV_WD_UIE_DROPDOWN_BY_IDX )
Both have the SET_STATE method, so this can be used the same way.
Hi Agadir,
Well, you started asking for help on dynamic table but actually you are working on ALV.
The required fields check on ALV table will not work same like normal fields/ normal table.
You need to have your own logic for handling the MANDATORY check on alv table in WDDOBEFOREACTION( ).
- Once you are marked the cells as required ( *) , you need to get all the required attributes of alv table in method WDDOBOFOREACTION( )
Refer my blog to get the mandatory attribute list from a alv table
- Now, you have all the mandatory attributes in an internal table, use the method cl_wd_dynamic_tool=>check_mandatory_attributes to validate the mandatory fields on alv
Refer the below thread
Hope this helps you.
Regards,
Rama
hello Rama,
first of all, I need to explaine somethings:
I am enhancing the SAP Compo HRESS_C_CATS
the ALV Table is Dynamic and has NO Context ( there is NO Context Node) everything is Dynamic, and the Save Button is not in the same Layout.
and as i sayed, i want to make the Mandatory Fields in a RED coulor if they are emtpty .
I have tryed many ways... BUT 😞 it didnt work
Regrads Agadir
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.