Entering content frame

Procedure documentation Creating Function Modules for Maintaining Site Attributes Locate the document in its SAP Library structure

Use

When you create a new site in the maintenance interface of the site Administration Console you can assign attributes to your type by choosing Site Attributes. You can use table view SMW1SPRVDR to set which screen or which function modules are called to ensure that you can use the full functionality of attribute maintenance for sites. The corresponding function modules must, however, be created first.

Procedure

Choose Basic Tools ® ABAP Workbench ® Development ® Function Builder and create the function modules described below.

Because values maintained for the site attributes cannot be transferred to the administration console,  the global values must be saved globally so that they can be accessed by all the function modules called.

You have the following options for saving values globally:

·        Export to ABAP memory

·        Use a function group for all called modules and save the data in global variables.

Function group SMOE_SITE_ATTRIBUTE can be used as an example. It contains the function modules listed below.

If you are using subscription agents, the site attributes are transferred using additional parameters.

Function Module for Site Attribute Maintenance Screen

Function module for function SCREENFUNC (screen function in detail screen of table view SMW1SPRVDR). This function module is called by the administration console when you press the Site Attributes pushbutton. This module starts the screen to create the values for the site attribute (example: function module SMOE_SITE_ATT_SCREEN).

The structure of the function module is defined as follows:

Import Parameters:

Name

Type

Description

I_SITETYPID

SMW1STID

Key of the selected site type.

I_MODE

CHAR20

Mode of the Administration Console. Possible modes are:

ADD: a new site should be created

EDIT: an existing site is changed (only fields that can be changed should be able to be edited).

VIEW: The values of the attributes of an existing site should be displayed (fields cannot be edited).

I_SITE_ID

SMO_SITEID

Key of the selected site type. Keep in mind the following points concerning the modes (parameter I_MODE):

ADD           I_SITE_ID is set to initial

EDIT/VIEW I_SITE_ID corresponds to the key of the
                    site to be modified or displayed

IT_ATTRIBUTES

SMOEATTRIBSTR_TT
(optional)

Only when using subscription agents:
this parameter transfers the site attributes to be displayed from the repository of the subscription agent.

Export Parameters:

Name

Type

Description

O_SCREEN_
CHANGED

CHAR01

X    Values of the site attributes have changed

Empty   Attribute values have not changed

ET_ATTRIBUTES

SMOEATTRIBSTR_TT

Only when using subscription agents:
this parameter transfers the maintained site attributes to the repository of the subscription agent.

Function Module for Consistency Check

Function module for function CHECKFUNC that checks whether the values of the site attributes are correct. If this is not the case (O_RETURN-TYPE = E), the Administration Console will not save the values (example: function module SMOE_SITE_ATT_CHECK).

A check function must be specified, if attribute values are to be defined for the site. This function module is necessary as users could create new sites without choosing the button Site Attributes. In this case the screen consistency checks would not be run if the user saves the site. The check function is therefore called before the site is saved.

The structure of the function module is defined as follows:

Import Parameters:

Name

Type

Description

I_MODE

CHAR20

Mode of the Administration Console. Possible modes are:

ADD:  new site should be created

EDIT: existing site is changed

VIEW: attribute values of an existing site should be changed

I_SITE_ID

SMO_SITEID

Key of the selected site whose site attribute values are to be checked for consistency.

IT_ATTRIBUTES

SMOEATTRIBSTR_TT
(optional)

Only when using subscription agents:
this parameter transfers the site attributes to be checked from the repository of the subscription agent.

Export Parameters:

Name

Type

Description

O_RETURN

BAPIRET2

Contains return values of the check, such as error messages.

The administration console reacts only to errors with O_RETURN-TYPE = E. The displayed error text is read from the parameter O_RETURN-MESSAGE.

Function Module for Selecting Values

Function module for function READFUNC that is called to select the values of the site attributes (example: function module SMOE_SITE_ATT_READ).

The structure of the function module is defined as follows:

Import Parameters:

Name

Type

Description

I_SITETYPID

SMW1STID

Key of the selected site type.

I_SITE_ID

SMO_SITEID

Key of the site for which values are to be selected for the site attribute.

Export Parameters:

Name

Type

Description

BAPIRET2

Contains return values of the selection, such as error messages.

The administration console reacts only to errors with O_RETURN-TYPE = E. The displayed error text is read from the parameter O_RETURN-MESSAGE.

Function Module for Saving Values

Function module for function SAVEFUNC which is called when the site is saved. It saves the values of the site attributes. The function module must not execute a COMMIT/ROLLBACK WORK (example: function module SOME_SITE_ATT_SAVE).

The structure of the function module is defined as follows:

Import Parameters:

Name

Type

Description

I_SITETYPID

SMW1STID

Key of the selected site type.

I_MODE

CHAR20

Mode of the Administration Console. Possible modes are:

ADD:  new site should be created

EDIT: existing site is changed

DELETE: existing site should be deleted

I_SITE_ID

SMO_SITEID

Key of the site to be saved. Keep in mind the following points concerning the modes (parameter I_MODE):

ADD: When the site is saved, a new GUID is created for the site which is then passed to the function module SAVEFUNC. The GUID cannot be changed.

EDIT/DELETE: the GUID of the selected site is transferred.

Export Parameters:

Name

Type

Description

O_RETURN

BAPIRET2

Contains return values of the saving process, such as error messages.

The administration console reacts only to errors with O_RETURN-TYPE = E. The displayed error text is read from the parameter O_RETURN-MESSAGE.

The return value E causes the Administration Console to make a complete Rollback. For example, if a site is to be deleted that is not allowed to be deleted because of the values of the site attributes, this means that when O_RETURN-TYPE = E, the values of the site attributes as well as the site are kept. The error message O_RETURN-MESSAGE is returned.

Function Module for Saving Values when Using Subscription Agents

Function module for function GENSAVEFUNC (only when using subscription agents), which is called when the site is saved. It saves the values of the site attributes. The function module must not execute a COMMIT/ROLLBACK WORK (example: function module SOME_SITE_ATT_GEN_SAVE).

The structure of the function module is defined as follows:

Import Parameters:

Name

Type

Description

I_SITETYPID

SMW1STID

Key of the selected site type.

I_MODE

CHAR20

Mode of the Administration Console. Possible modes are:

ADD:  new site should be created

EDIT: existing site is changed

DELETE: existing site should be deleted

I_SITE_ID

SMO_SITEID

Key of the site to be saved. Keep in mind the following points concerning the modes (parameter I_MODE):

ADD: When the site is saved, a new GUID is created for the site which is then passed to the function module SAVEFUNC. The GUID cannot be changed.

EDIT/DELETE: the GUID of the selected site is transferred.

IT_ATTRIBUTES

SMOEATTRIBSTR_TT

Only when using subscription agents:
this parameter transfers the site attributes saved when a site is saved in the subscription agent.

Export Parameters:

Name

Type

Description

O_RETURN

BAPIRET2

Contains return values of the saving process, such as error messages.

The administration console reacts only to errors with O_RETURN-TYPE = E. The displayed error text is read from the parameter O_RETURN-MESSAGE.

The return value E causes the Administration Console to make a complete Rollback. For example, if a site is to be deleted that is not allowed to be deleted because of the values of the site attributes, this means that when O_RETURN-TYPE = E, the values of the site attributes as well as the site are kept. The error message O_RETURN-MESSAGE is returned.

Function Module for Locking Values

Function module for function LOCKFUNCthat is called to lock the values of the site attributes (example: function module SMOE_SITE_ATT_LOCK).

The structure of the function module is defined as follows:

Import Parameters:

Name

Type

Description

I_SITETYPID

SMW1STID

Key of the selected site type.

I_SITE_ID

SMO_SITEID

Key of the site that is locked by the Administration console.

I_LOCK

CHAR01

E    Values should be locked

D    Values should be unlocked

Export Parameters:

Name

Type

Description

O_RETURN

BAPIRET2

Contains return values of the locking process, such as error messages.

The administration console reacts only to errors with O_RETURN-TYPE = E. The displayed error text is read from the parameter O_RETURN-MESSAGE.

 

Function Module for Initializing the Values

Function module for function INITFUNC which is called to initialize the screen to maintain the values of the site attributes (example: function module SMOE_SITE_ATT_INIT).

This function module is not an import or export parameter.

 

 

Leaving content frame