Conditional mandatory field checks for tables

In Web UI it is possible to specify mandatory fields which should be checked by Web UI framework on every round trip. This is working for normal fields on details screen as well as for table fields. Developers don’t need to check these fields. They don’t need to create or delete corresponding error messages. Framework is doing it for free.

Please note that fields on detail screen can be configured as mandatory. However configuration is not working for tables. And: Configuration is not working for conditional mandatory fields at all. That is why we sometimes need following solution which is very powerful and easy to implement.

Actions you have to perform as developer:

  1. Redefine method DO_VALIDATE_INPUT of view controller.
  2. Perform some checks to find out whether fields are mandatory or not (in case they are not always mandatory).
  3. Build binding string and attribute path. For tables it is „//<contextnode>/Table[<index>].<fieldname>“. For structure fields it is „//<contextnode>/STRUCT.<fieldname>“ (standard fields from BOL/GenIL) or „//<contextnode>/EXT.<fieldname>“ (AET fields) or „//<contextnode>/<fieldname>“ (virtual fields).
  4. Register mandatory field by using method POST_MANDATORY_FIELD.

Important remark for tables: Sometimes it happens that mandatory checks are getting confused: Framework is not alerting empty fields or framework is alerting even if fields are not empty. Also custom sorting can be skipped or raising short dumps or just going wrong. In general (and especially in these cases) please ensure that you call method CLEAR_LAST_LINE in method ON_NEW_FOCUS before you perform sorting or mandatory checks.

Please note: SAP Solution Manager IT Service Management has an own solution to perform status dependent mandatory field checks. Maybe if we integrate this check here we would enable the framework to display mandatory fields with red color and star. I haven’t tried it yet. But I would expect this helpful behaviour…