Additional Blogs by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
leigh_mason
Employee
Employee

Abbreviations I’m going to use:

EP           Enterprise Portal

UWL      Universal Work List

P2P        Position To Position

ECC        Enterprise Core Components

CRM      Customer Relationship Managment

 

About this blog

This blog will provide an overview of how to achieve Position to Position based substitution.  We will not be including every single piece of code to achieve this; it will be up to you to build your own components based on your own requirements.

 

What is substitution

When an employee goes on leave they can substitute another employee(s) to take control of their workflow work items for the time they are away. 

 

Situation Example

Although substitution is available as User to User based via the UWL independent of what SAP System you have (ECC, CRM etc), we will be dealing with Position to Position based substitution in a HR environment.

To set the scene for this blog we will be using this situation:

“Manager has gone on leave and Employee A are substituting into the Manager’s position to action work items on behalf of the Manager”

We want to provide P2P based substitutions i.e. create the relationships A210/B210 between the Manager’s Position and Employee A’s Position objects in the HR System.

Employee A will then be able to logon to the EP and access the Manager’s work items via the UWL.

 

Further Reading

Chris Solomon has provided an excellent blog that should provide a sound functional overview of the concepts of Substitution

MSS: Delegation....the final frontier?

 

SAP Help Document (there are plenty more)

http://help.sap.com/erp2005_ehp_05/helpdata/EN/8d/25f558454311d189430000e829fbbd/frameset.htm

 

In the IMG of your HR System you can also access the following IMG documents:

SAP NetWeaver->Application Server->Business Management->SAP Business Workflow->Basic Settings

  • Maintain Task Classes
  • Substitute Profile

 

 

Levels of Substitution

You need to define what type of substitution you want to implement based on your own requirements.  More often than not, user to user based substitution will suffice however there are of course times when this is not sufficient, an example is Public Sector customers who have a complex organisational structure including relationships such as “Higher Duties” (A081) where you want to capture all holders of the position being substituted for by simply passing the Position HR Object around (e.g. putting SXXXXXXXX into a workflow task as an agent and have all holders access the work item).

Here is how we have defined the levels of substitution:

User to User

User ID is directly related to another SAP User ID via table HRUS_D2.   There are number of ways which I’ve seen this implemented, some via ABAP program, Web Dynpro and more commonly this functionality is provided via UWL i.e. when you click on “Manage Substitution Rules”

 

This is also common outside of HR systems as there is no concept of “Person” object.

Person to Position

Employee (Person Object type “P”) related to a Position via table HRVPADD2 and by maintaining the relationships in tableHRP1001.  To get this to work you can follow the approach adopted in this blog for P2P based substitution.

Position to Position (P2P)

Position (Object type “S”) related to another Position (Object type “S”) via table HRVPADD2 and by maintaining the relationships in tableHRP1001.

The aim of this blog is to show you that we can provide this type of substitution in the HR System.

 

P2P Supported in SAP Business Workplace (Transaction SBWP)

NB: P2P based substitution actually works if you are accessing work items in the backend system via transaction SBWP.

If this is sufficient for your requirements then you don’t have to proceed with the below example which includes an enhancement to SAP standard code.

 

P2P Not Supported in UWL

SAP does not support P2P based substitution as standard for UWL access to work items.  If you want proof of this please have a look at the following class->method:

CL_SWN_UWL_WORKLIST->GET_WORKLIST

Note the following lines of code:

*---- we only support personal substitution
  DELETE lt_swwwlhead WHERE otype <> 'US' AND otype <> space.

This is deleting any work item views that are not User based (object type “US”).  You may or may not have tried to put in P2P substitution relationships only to find that it doesn’t work in the UWL.  This is the culprit.

If we want P2P substitution to work, this is the place where we can make an Implicit Enhancement or Over-Write Exit on the method GET_WORKLIST.

  

Getting Started

I’ll run through how we achieved P2P based substitution at a customer site.  This is not meant to be the “only” solution to this problem, I hope SAP provides this type of Substitution as standard in the future as it is quite powerful.

This is what we did:

  • Created an ABAP Web Dynpro to allow the end user to create/change/delete  the substitution relationships (A210 / B210) and act as the entry point via the EP

 

  • Created some support functions / methods to update / change / create your Substitutions in table HRVPADD2

 

  • Create the Implicit Enhancement of class CL_SWN_UWL_WORKLIST method GET_WORKLIST to override the deletion of non-user based UWL views.

 

ABAP Web Dynpro

Our ABAP Web Dynpro which is executed in the EP looks like this:

 

This allows the Manager to create the Substitution relationships (A210 / B210) between their own Position and the Employee’s position.

The requirements for this Web Dynpro were only make this available to managers via MSS.  Of course you can build a similar application and provide it to whom ever you want.

Use your imagination here, there is obviously some Position search and selection routines etc to assist the user with selecting a substitute position.

 

 

Update Methods

We created a set of common methods to handle the creation, change, activation of substitution relationships.  There are a number of interesting Function Modules we used to do this.

Have a look at Function Group RHW1 and RHW2:

RHW1

RH_SUBSTITUTIONS_GET

 

RHW2

RH_SUBSTITUTION_ACTIVATE

RH_SUBSTITUTION_CUT

RH_SUBSTITUTION_DELETE

RH_SUBSTITUTION_MAINTAIN

RH_SUBSTITUTION_SELECT

RH_SUBSTITUTION_SELECT_OLD

 

These are really handy Function Modules and a number of these are sufficient to achieve what you want to do.  They will manipulate the data in table HRVPADD2.

Table HRVPADD2 is write protected so you cannot use direct inserts, modify, deletes in you customer namespace programs.

 

Relationship Overview

For P2P substitution to work, you need to create relationships between the two Position objects (Object type “S”).

To do this manually you can use transaction PO13.

Here are some screen shots of how the relationships look in our demo:

The Manager Position

  

 

Additional Data

You will notice a button on the top called “Additional data”.  This provides further data on the relationship.  For substitution these details are stored in the HRVPADD2 table.  Below is a screen shot of the Additional data screen:

 

 

The Employee Position

If you now look at the Employee’s position and the Substitution relationship you will notice the relationship will be A210.

 

Creating these relationships

We handle the creation of these relationships including the creation of the above  “Additional data” through program code.  Although you can create these relationships manually via transaction PO13, you can create them via your ABAP Web Dynpro / other code.

 

Substitute Profile

We won’t go into to much detail about Profiles, there are plenty of help documents about this.  For our requirements we only needed to use Substitution Profile “ALL”. 

In the “Further Reading” section of this blog we’ve listed some further links to help you understand these concepts more.

 

Substitution Active

In order for the substitution relationships to work, this MUST be “ticked”. 

We have used Function Module RH_SUBSTITUTION_MAINTAIN to manage this data as it provides with the ability to modify the “Substitution Profile”.

 

Implicit Enhancement

We also modified the method CL_SWN_UWL_WORKLIST->GET_WORKLIST with an implicit enhancement.  You can do this with an overwrite exit if you wish.

This method will compile a list of work items for the user and apply any substitution views, that is if you have applied User to User based substitution rules via the EP (shown above) by using the “Manage Substitution Rules” function, this method will read the HRUS_D2 table and identify if the substitution is active and incorporate the substituted users work items as well.

As stated in the code, SAP only support User based substitution so the method will delete any other substitution rules such as P2P based.

All we are looking to do here is copy the entire standard SAP method and remove the lines that delete any other UWL view, i.e. remove or comment out:

*---- we only support personal substitution
  DELETE lt_swwwlhead WHERE otype <> 'US' AND otype <> space.

 

Security Considerations

If you are going to create the A210 / B210 relationships in program code, you may (or may not) run into structural authorisation errors (we did).

Originally we were using a call to Function Module RH_RELATION_MAINTAIN which does not allow you to turn of authorisation checks. 

Security requirements are different from customer to customer.  In our case we wanted the Manager to allow a position for another Organisation Unit to be allowed to substitute which means we have to be able to get around structural authorisation checks. 
In hindsight RH_RELATION_MAINTAIN was an inappropriate Function Module to use instead we chose to use:

  • RH_INSERT_INFTY_1001_EXT
  • RH_CUT_INFTY_1001_EXT

This allowed us to switch of authorisation checks.

It’s also important to manage who is being substituted, be mindful of their roles and responsibilities (think PFCG roles).  In our case we have limited Managers as eligible substitutes therefore we assume some similarities with PFCG roles when a Manager substitutes for another Manager.

 

Evaluation Paths

We did not do anything special for evaluation paths i.e. we did not modify A210, B210 evaluation paths.

However, because you are using P2P based substitution, you may need to consider how additional holders of a position will be picked up as Agents of a work item.

In our example we were required to ensure that “Higher Duties” relationships were taken into consideration (this is the A081 relationship) as a “Holder” of a Position when we pass the Position object itself into workflow as an Agent.

 

Expiry Dates

You will notice that entries in table HRVPADD2 have a BEGDA, ENNDA (begin date and end date). 

When the clock ticks over the end date, the substitution relationship will be invalid.

In our example, Employee A will no longer see the Manager’s work items after the end date so there is nothing explicit we had to do for this to end apart from calling RH_CUT_INFTY_1001_EXT if the Manager deletes the substitution in the ABAP Web Dynpro.

 

Historical Records

We have seen some posts regarding tracking of previous substitution’s.  Because entries in table HRVPADD2 have a date range (i.e. BEGDA and ENDDA) it is possible to keep records that are “Inactive” and create further substitution rules between different date ranges.

I haven’t looked  but I can’t see whether there is any standard reporting around this, however this would be a fairly simple report to build if you wanted to.

Other useful bits of information

As per the User to User based substitution via the “Manage Substitution Rules” function in the UWL, once the P2P based substitution is active you will then have access to this nice little piece of functionality located just above the tab-panel of the UWL:

 

  

The user will be able to switch between “My Items”, ”All Items” or “Items on Behalf Of”.  This functionality is provided as standard with the UWL (fantastic!).

Note that your UWL iView in the EP will have some settings for Substitution.  Ask your Portal consultant / Administrator to assist you with getting these setup in accordance with your requirements. 

These settings affect the way the end user can create / maintain their user to user based Substitution rules (stored in table HRUS_D2).

 

NB: In the image above we have changed the name of the iView “Universal Worklist” to “Inbox”

 

Pit falls of this approach

 

  • CL_SWN_UWL_WORKLIST->GET_WORKLIST, by creating an implicit enhancement, this method is now subject to your normal change request approval process and will not be subject to changes made in subsequent support packs.   Will probably have to me managed via SPAU if your system is being upgraded / patched.

 

  • If you create the ABAP Web Dynpro, you will have another development to support (I want to use the term TCO here but I won’t.. oops I just did)

 

 

Summary

P2P based substitution is a very effective way of providing substitutions for work items in a SAP HR System especially if your workflow strategy is to use position objects as Agents of work items in Workflow.

At this point in time I don’t know if SAP will support P2P based substitution as standard, they have provided User to User based substitution as standard and this may suffice for the majority of customers.

In any case, if your requirements are to use P2P based substitution this blog should hopefully get you on your way to achieving it.  As stated at the start this is not the only solution to this problem, you may find a more elegant way to do this and would be happily open to suggestions.

5 Comments