Skip to Content

ALV comp. - make field mandatory

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 24, 2013 at 03:25 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 24, 2013 at 03:23 PM

    Hi Peter,

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

    Thanks,

    Sudheer.

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 25, 2013 at 05:14 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 25, 2013 at 06:52 AM

    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

    Add comment
    10|10000 characters needed characters exceeded