Start of Content Area

Background documentation Work Protect Mode  Locate the document in its SAP Library structure

The work protect mode provides the infrastructure for handling unsaved data in SAP NetWeaver Portal. An application is called “dirty” if the entered data has not yet been saved. Normally data is lost when the user navigates to another application without having first saved the data. To prevent this from happening, the client framework of the portal monitors the current status of all the applications in the portal.

Example 

Example of dialog box showing the work protect mode:

This graphic is explained in the accompanying text

The application must define a special status (dirty flag), which tells the portal when there is unsaved data. You can set and cancel this status (TRUE, FALSE) using method SET_APPLICATION_DIRTY_FLAG in interface IF_WD_PORTAL_INTEGRATION. If the dirty flag is set to TRUE, each navigation step is automatically executed in a new window. The unsaved data is retained in the original window. This means the user can switch to the original application and save the data afterwards.

The following source text shows how to set the dirty status:

  data lr_componentcontroller type ref to ig_componentcontroller .

data L_API_COMPONENTCONTROLLER type ref to IF_WD_COMPONENT.

data L_PORTAL_MANAGER type ref to IF_WD_PORTAL_INTEGRATION.

 L_COMPONENTCONTROLLER =   WD_THIS->GET_COMPONENTCONTROLLER_CTR( ).

 L_API_COMPONENTCONTROLLER = L_COMPONENTCONTROLLER->WD_GET_API( ).

 L_PORTAL_MANAGER = L_API_COMPONENTCONTROLLER->GET_PORTAL_MANAGER( ).

 

call method L_PORTAL_MANAGER->SET_APPLICATION_DIRTY_FLAG

  exporting

    DIRTY_FLAG = TRUE | FALSE

    .

You insert the source code into a controller method of a Web Dynpro component.

Web Dynpro supports the work protect mode in three different ways (method SET_WORK_PROTECT_MODE in interface IF_WD_PORTAL_INTEGRATION):

      NONE

This value means that the work protect mode is not used by the Web Dynpro application. If you navigate to another application in the portal, unsaved data is lost, even if you set the dirty flag.

      APPLICATION_ONLY

This value means that the Web Dynpro application itself decides if there is still unsaved data – that is, whether the application is dirty. This is why the “dirty” status is only monitored by the server. With this value you cannot ensure that data that has not yet been transferred to the server will not be lost.

      BOTH

This value means the client also checks the “dirty” status. This ensures that no user input that has not yet been transferred to the server will be lost. This is done by setting the dirty status of the application in SAP Enterprise Portal as soon as the user has entered data.

The modes described above can be changed as often as required during runtime of a Web Dynpro application. For example, you can change the mode when a user navigates from one view to another. For one view, it may make sense to save data that is entered in an input field. In this case you define the value BOTH or APPLICATION_ONLY. For another view this protection mode may not be necessary. In this case you define the value NONE.

The source text below shows how the work protect mode can be set:

  data lr_componentcontroller type ref to ig_componentcontroller .

data L_API_COMPONENTCONTROLLER type ref to IF_WD_COMPONENT.

data L_PORTAL_MANAGER type ref to IF_WD_PORTAL_INTEGRATION.

 L_COMPONENTCONTROLLER =   WD_THIS->GET_COMPONENTCONTROLLER_CTR( ).

 L_API_COMPONENTCONTROLLER = L_COMPONENTCONTROLLER->WD_GET_API( ).

 L_PORTAL_MANAGER = L_API_COMPONENTCONTROLLER->GET_PORTAL_MANAGER( ).

 

call method L_PORTAL_MANAGER->SET_WORK_PROTECT_MODE

  exporting

    MODE   = NONE | APPLICATION_ONLY | BOTH

    .

Note

Note the following in connection with the CLOSE_WINDOW functionality:

CLOSE_WINDOW overrules the work protect mode in the portal, that is, there is no work protect popup for CLOSE_WINDOW (You have unsaved data or a similar message).

Example

You can find an example in the system in the Web Dynpro application WDR_TEST_PORTAL_WORKPROTECT.

 

 

End of Content Area