Context Change Log (Recording User Entries)

Use

In many applications, it is important that user entries are actually marked as user entries. If, for example, many bound UI elements are displayed in a view, but only one single value is changed by a user entry, this can have an unnecessary negative effect on performance -when all the context contents are again processed by the business logic. It is more appropriate to mark the changes that the user has made within the view and to edit them separately. Changes that the user can make include changing the value of an attribute and converting the selection or the lead selection.

First of all, each context node provides the option of storing the relevant information for itself. However, to prevent you having to check all existing context nodes of a controller, Web Dynpro Framework provides a context change log function: Within a controller all information about changes made to context elements by the user are saved only in an internal table. The Web Dynpro runtime has access to this table and can adapt the flow of business logic to the table entries.

The function of the context change log is switched off in the controller default settings. You may activate it as required. You do this by using the IF_WD_CONTEXT interface of the respective controller.

IF_WD_CONTEXT Interface

The IF_WD_CONTEXT interface provides a reference to the controller context.

Use the following call to get a reference to IF_WD_CONTEXT:

          
MY_CONTEXT = WD_CONTEXT->GET_CONTEXT( )
            

The IF_WD_CONTEXT interface makes the following methods available for using the change log function:

Method

Description

ENABLE_CONTEXT_CHANGE_LOG( )

Activates recording of user entries for this controller.

DISABLE_CONTEXT_CHANGE_LOG( )

Deactivates the recording.

GET_CONTEXT_CHANGE_LOG( and_reset )

Provides the current content of the change log table and resets this automatically (the latter property is preset, it can however be deactivated again).

RESET_CONTEXT_CHANGE_LOG( )

Resets the change log table.

ADD_CONTEXT_ATTRIBUTE_CHANGE( )

You can use this method to program changes to a context attribute into the change log table. This is particularly important for programming value helps, since data selected from a value help is not automatically entered in the change log table.

Table of User-Defined Context Changes

The table in which the user-defined changes to context are listed is of the type WDR_CONTEXT_CHANGE_LIST. It contains nine columns which have the following meanings:

Column

Description

NODE_NAME

Name of the node containing the change

SEQUENCE

Sequence number of the entry

NODE

Reference to the node

NODE_PATH

Node path

CHANGE_KIND

Categorizes the type of change. Constants IF_WD_CONTEXT=>CHANGED_* are available as values.

ELEMENT_INDEX

Index of context element

ATTRIBUTE_NAME

Name of the attribute that was changed

OLD_VALUE

Reference to the previous value

NEW_VALUE

Reference to the new value

For the values in the columns OLD_VALUE and NEW_VALUE, a copy is first made of the old and the new attribute values. A reference to this copy is then stored in the table.

Example

You will find an example application DEMO_CONTEXT_CHANGES in your system in package SWDP_DEMO.

More Information

You can find more information about interface IF_WD_CONTEXT in the system in the relevant system documentation.