Mail Notification for PMS Status Change- Workflow
This document explain how to create workflow, event and business object required for custom mail notification for any event change/status change in performance management cycle.
1. Create Business Object:
T Code: SWO1
Create Custom business object with super type APPR_DOC BO.
Provide details for Object. You may use your naming convention as per format.
Delegate ZAPPR_DOC object to BO APPR_DOC. It will include all your custom events, methods in standard supertype APPR_DOC.
Provide Object type as standard BO APPR_DOC and in delegation type as ZAPPR_DOC.
Create custom event by placing cursor on events and click on Create icon.
Provide Event name as per your naming convention.
Implement custom events and Object Component.
Generate created BO ZAPPR_DOC.
Step 2: Create Task for fetching details for mail content and email id of receiver. Design single task for all workflows for PMS mail. Hence, get all the details required for mail in single task.
T Code: PFTC
Provide basic details as shown.
On 3rd tab container, create container elements where details to be stored in container.
While saving task, it will give error as we have defined method GetDetails from BO but there is not such method exist.
So in other session open, BO and create Method GetDetails.
Create Report. Do not create function module.
In Program, write logic to get details and set details in elements.
DATA : E_ID TYPE P0105–USRID_LONG,
M_ID TYPE P0105–USRID_LONG,
E_NACHN TYPE P0002–NACHN,
E_VORNA TYPE P0002–VORNA,
M_NACHN TYPE P0002–NACHN,
M_VORNA TYPE P0002–VORNA,
APPRAISAL_ID TYPE HAP_S_APPRAISAL_ID,
APPR_ID TYPE HAP_S_APPRAISAL_ID–APPRAISAL_ID,
LS_E0002 TYPE PA0002,
LS_M0002 TYPE PA0002.
DATA: LV_EPERNR TYPE PERNR–PERNR,
LV_MPERNR TYPE PERNR–PERNR.
DATA : LT_APPRAISEE TYPE HAP_T_HEADER_APPRAISEE,
LS_APPRAISEE TYPE HAP_S_HEADER_APPRAISEE,
LT_APPRAISER TYPE HAP_T_HEADER_APPRAISER,
LS_APPRAISER TYPE HAP_S_HEADER_APPRAISER.
SWC_GET_ELEMENT CONTAINER ‘Emp_ID’ E_ID.
SWC_GET_ELEMENT CONTAINER ‘Man_ID’ M_ID.
SWC_GET_ELEMENT CONTAINER ‘E_NACHN’ E_NACHN.
SWC_GET_ELEMENT CONTAINER ‘E_VORNA’ E_VORNA.
SWC_GET_ELEMENT CONTAINER ‘M_NACHN’ M_NACHN.
SWC_GET_ELEMENT CONTAINER ‘M_VORNA’ M_VORNA.
SWC_GET_ELEMENT CONTAINER ‘APPR_ID’ APPR_ID.
*APPRAISAL_ID-APPRAISAL_ID = ‘0A0C7CCDFD141EE5A98419E67ED2C123’.
APPRAISAL_ID–APPRAISAL_ID = APPR_ID.
CLEAR : LS_APPRAISEE, LS_APPRAISER.
REFRESH : LT_APPRAISEE, LT_APPRAISER.
CALL FUNCTION ‘HRHAP_DOCUMENT_GET_DETAIL’
* ADD_ON_APPLICATION =
* MODE = ‘ ‘
* UI_MODE = ‘ ‘
PLAN_VERSION = ’01’
S_APPRAISAL_ID = APPRAISAL_ID
* ADMINISTRATOR = ‘ ‘
* S_DISPLAY_UI =
* NO_ACTION_LOG = ‘ ‘
* IGNORE_COLUMN_NUMBER =
* S_DOC_PROCESSING =
* S_HEADER_TEXTS =
T_HEADER_APPRAISER = LT_APPRAISER
T_HEADER_APPRAISEE = LT_APPRAISEE
* T_HEADER_PART_APPRAISER =
* T_HEADER_OTHERS =
* S_HEADER_STATUS =
* S_HEADER_DATES =
* T_HEADER_ADD_DATA =
* S_HEADER_DISPLAY =
* T_BUTTONS =
* T_BODY_COLUMNS =
* T_BODY_ELEMENTS =
* T_BODY_ELEMENT_BUTTONS =
* T_BODY_ELEMENT_DESCR =
* T_BODY_CELLS =
* T_BODY_CELL_VAL_VALUES =
* T_BODY_CELL_VAL_RANGES =
* T_BODY_CELL_VAL_C_LIKE =
* T_BODY_CELL_VAL_DESCR =
* T_BODY_CELL_NOTES =
* T_STATUS_NOTES =
* T_STATUS_DESCRIPTION =
* S_RETURN =
CLEAR: LV_EPERNR, LV_MPERNR, E_NACHN, E_VORNA, M_NACHN, M_VORNA.
READ TABLE LT_APPRAISEE INTO LS_APPRAISEE INDEX 1.
IF SY–SUBRC = 0.
LV_EPERNR = LS_APPRAISEE–ID.
READ TABLE LT_APPRAISER INTO LS_APPRAISER INDEX 1.
IF SY–SUBRC = 0.
LV_MPERNR = LS_APPRAISER–ID.
SELECT SINGLE * FROM PA0002 INTO LS_E0002 WHERE
PERNR EQ LV_EPERNR.
E_NACHN = LS_E0002–NACHN.
E_VORNA = LS_E0002–VORNA.
SELECT SINGLE * FROM PA0002 INTO LS_M0002 WHERE
PERNR EQ LV_MPERNR.
M_NACHN = LS_M0002–NACHN.
M_VORNA = LS_M0002–VORNA.
SELECT SINGLE USRID_LONG FROM PA0105 INTO E_ID WHERE
PERNR EQ LV_EPERNR AND
SUBTY EQ ‘0010’.
SELECT SINGLE USRID_LONG FROM PA0105 INTO M_ID WHERE
PERNR EQ LV_MPERNR AND
SUBTY EQ ‘0010’.
SWC_SET_ELEMENT CONTAINER ‘Emp_ID’ E_ID.
SWC_SET_ELEMENT CONTAINER ‘Man_ID’ M_ID.
SWC_SET_ELEMENT CONTAINER ‘E_NACHN’ E_NACHN.
SWC_SET_ELEMENT CONTAINER ‘E_VORNA’ E_VORNA.
SWC_SET_ELEMENT CONTAINER ‘M_NACHN’ M_NACHN.
SWC_SET_ELEMENT CONTAINER ‘M_VORNA’ M_VORNA.
SWC_SET_ELEMENT CONTAINER ‘APPR_ID’ APPR_ID.
Step 3: Create Custom Workflow to get details and send mail on event trigger.
T Code: SWDD
Double click to insert activity step (Activity step is used to perform task and return values and container).
Provide task details and step Name.
Now, Create workflow container as like task container.
Click double click to create workflow container element.
Create all elements for which details is required in mail.
For our scenario, below are details required for all mail.
Now, important step. Binding of workflow container element to task elements. so that details fetched in task can be passed to workflow container correctly.
Do not generate automatically. Do it manually as shown below.
Bind all shown elements.
Now, include mail step to send mail.
Provide details for mail step. For this workflow, i need to notify manager as Employee has submitted goal setting. So E-Mail Address as Manager Mail id.
User variable details fetched from task in mail step with & prefix and suffix.
This is just done from workflow development. Now, to trigger workflow from event, need to configure start event.
Go to basic data as shown.
Go to Start Events. Provide Standard BO APPR_DOC. Do not give custom BO ZAPPR_DOC.
As we have delegated ZAPPR_DOC to APPR_DOC, custom events will also be available in standard BO APPR_DOC.
Activate it in A column (Green).
Do binding. Here binding will help to pass appraisal document details (APPR_DOC) attributes. And as in code, we have used Appraisal ID to get detail.
Hence, this binding is very important.
Do Binding as shown.
This is all done from technical side. I learnt and found very interesting.
Now from configuration side.
Step 4: Configure events and bind in status change button in status flow.
T Code: OOHAP_BASIC.
In last option, workflow events, Create new entries in workflow events which you have created in BO.
Now, assign it in category, template.
T Code: PHAP_CATALOG.
Select all the events created and make it applicable to category and template.
Configure event on respective action button in status flow to trigger event and workflow.
Hope this configuration stuff is easy hence not uploaded images.
Hope this will help.
Very fruitful document. keep sharing.
So you have already gone through this..eh.. yeah Useful document indeed.