cancel
Showing results for 
Search instead for 
Did you mean: 

ALV comp. - make field mandatory

former_member210563
Participant
0 Kudos

Hi,

I have WD where I use ALV for entering data. However, the first fiekd PERNR must be entered.

In WDDOINIT I have done the following:

This only produces a red star beside the field name. I can still leave the field blank. ??

Is WDDOINIT the right place to place the code ?

  loop at lt_columns into ls_columns.
    case ls_columns-id.

      when 'PERNR'.
        create object lo_pernr
          exporting
            value_fieldname = ls_columns-id.
        ls_columns-r_column->set_cell_editor( lo_pernr ).
        lo_pernr->set_state(  01 ).   and so on.....

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

making mandatory doesn't help in case of alv.

1. get all record of alv .

2. put loop  records if any record have pernr blank  raise error

3. if you want to highlight row in which error occur  first set node lead_selection_index equal to sy-index

get selected element

then use method REPORT_ATTRIBUTE_ERROR_MESSAGE  for raising error

Answers (3)

Answers (3)

Former Member
0 Kudos

Dear Peter,

Whenever we work on validation on normally write the code on WDDOBEFOREACTION method.

Now you have make the particular column as mandatory .

Generally we use standard class method

"cl_wd_dynamic_tool=>check_mandatory_attr_on_view " to validate the mandatory field .on WDDOBEFOREACTION  method. But this is use for current view only .

I assume u have used view container element for ALV . so this method  will not use .

Try with   "cl_wd_dynamic_tool=>CHECK_MANDATORY_ATTRIBUTES" on WDDOBEFOREACTION method .

thanks and regards,

Anup Banerjee

Former Member
0 Kudos

Hi Peter,

When you want to check this validation, that you have to decide first and place your code accordingly.

lo_pernr->set_state(  01 ).  is works for you.

Or you can highlight perticular column using  REPORT_ATTRIBUTE_ERROR_MESSAGE as suggested yadav.

Cheers,

Kris.

former_member217546
Participant
0 Kudos

Hi Peter,

Please throw an error message by checking the pernr value is initial or not.

Thanks,

Sudheer.