cancel
Showing results for 
Search instead for 
Did you mean: 

How to make Required Fields in WDA Dynamic Table

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member184578
Active Contributor
0 Kudos

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

ramakrishnappa
Active Contributor
0 Kudos

Hi,

You can achieve your requirement as below

  • Get the cell editor of your column into the respective object i.e. input fields, drop down, check box etc
  • set the field as mandatory by using method SET_STATE( )

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

Former Member
0 Kudos

Hello,

thanks for replay,

But the class  cl_wd_uie_input_field is unknown and cl_wd_ui_element_container ! are not defined in SAP ABAP ??

Regards

Agadir

ramakrishnappa
Active Contributor
0 Kudos

Oops, it should be cl_wd_input_field & cl_wd_uielement_container

Former Member
0 Kudos

  lo_input_field ?= lo_column->get_table_cell_editor( ).


get_table_cell_edito dosnt exist !!! thhere is an other methode get_cell_edito


and if i put   lo_input_field ?= lo_column->get_cell_editor( ).   everything dumpt !!!


Former Member
0 Kudos

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 ).

Former Member
0 Kudos

yes I've done everything as describe

if i put   lo_input_field ?= lo_column->get_cell_editor( ).


I got following error


  • The following error occurred in system XXX : Dynamic type conflict when assigning references
Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

ramakrishnappa
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hello Rama,

the methode WDDOBEFOREACTION does not give back the action name (save) alawys empty.

I want by save to make the mandatory Fields RED to let the user knows waht he musst do.

Regards

ramakrishnappa
Active Contributor
0 Kudos

Hi,

Is the SAVE button inside the ALV toolbar? if so, you need to use the method ON_FUNCTION to get the action name.

Hope this helps you.

Regards,

Rama

Former Member
0 Kudos

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