Show TOC

 Implementing Mutually Dependent Fields

Use

Suppose your infotype features two fields – for example, a value field and a percentage field – that are mutually dependent, meaning that any change to the percentage field should result in a corresponding change in the value field, and vice versa. In the event that both fields are changed, one of the two fields – in this example, the value field – must predominate, such that the change in value will override the change in percentage, and a new percentage will be calculated in proportion to the changed value.

Procedure

The most expedient manner to implement mutual field dependency in your business logic is to instruct the system to erase the percentage field entry when a value is entered, and conversely, to erase the value field entry when a percentage is entered, thereby removing the dependency from the display. Aside from optional screen elements to suggest that the fields are mutually dependent, this approach abstains from explicit business logic on the user interface.

With this approach, the business logic will evaluate which of the fields is initial. If only one field is initial, then the business logic will derive its entry from the other field. If neither field is initial, or if both fields are initial, then the screen logic will employ the predominant field (in this example, the value) to calculate the entry for the other field (in this example, the percentage). Once the corresponding business logic is processed and the mutually dependent fields are again consistent, the system will update the display accordingly.

Note Note

The approach described above is equally valid for any number of mutually dependent fields.

End of the note.