Synchronizing Fields with the Application

Use

Some applications hold identical copies of some address fields within their own database tables. There are many reasons for this. One example is the SAP Business Partner who keeps a copy of the name fields in the Business Partner tables, because a Business Partner must have a name, even if there is no address.

In such a scenario, it’s necessary to synchronize the application fields and the address fields during the dialog. To do this, the application must implement the methods GET_SYNCHRONIZED_FIELDS and SET_SYNCHRONIZED_FIELDS of class CL_BSP_MODEL_ACCESS_ADDRESS.

During the MODIFY method, the class CL_BSP_MODEL_ACCESS_ADDRESS follows this procedure:

·        It obtains the current value of the synchronized fields in the application fields with the method GET_SYNCHRONIZED_FIELDS.

·        It compares these values with the old and the new value in the corresponding address fields and determines the new value of the application fields.

·        It hands these new values to the application by calling the method SET_SYNCHRONIZED_FIELDS.

The new value of the field in the application table is determined in the following way:

·        If the value was not changed on the address controller, then any possible changes have been made in the application fields. Therefore, the value obtained from the application fields is applied to the address fields as well and returned to the application unchanged.

·        If the value obtained from the application is the same as the old value on the address controller, then the value has not been changed on the application fields. Therefore, the new value in the address controller is kept and handed to the application.

·        If the value obtained from the application is the same as the new value on the address controller, then any possible changes have been made simultaneously. In this case, no action is necessary and the value obtained from the application is returned unchanged.

·        If neither the value obtained from the application nor the old nor the new value in the address fields are the same, then the field has been changed both in the address controller and in the application fields, with different results. In this case, it is not possible to determine which was the last change, so the value in the address controller is kept and handed to the application.