Extended Approval Notification with SAP Fiori Component
I would like to share my experience with SAP FIORI Approval application through this blog. This blog will walk you through required steps to enable SAP FIORI Approval component to send external email notification with FIORI application URL as part of email. This will allow user to review work item and make a decision (i.e. Approve or Reject).
Here is the main steps to implement Extended Notification for SAP Fiori Approve Purchase Order App or any other Approval apps.
1) Implement OSS Note in 2056158, if it is required in your system.
2) Assign Purchase Order Task to UI5_BSP – Visualization Type using SAP Transaction SWFVISU.
3) Change the workflow Business Scenario setting and Assign Custom handler class using T-code SWNCONFIG.
4) Testing the SAP Fiori App.
1) Implement OSS Note 2056158 manual correction in your system.
- Go to SE11
- Enhance the fixed value Domain SWFVVTYP using transaction SE11.
- Add the value UI5_BSP (UI5 based on BSP) and activate the domain.
2) Create an entry for Purchase Order Task and Visualization Type as UI5_BSP – using SAP Transaction SWFVISU.
3) Change the workflow Business Scenario settings and Assign Custom handler class using T-code SWNCONFIG.
- Now change the Subscription Basic data.
- Recipient Address: “*”
- Recipient Type : Cus Receiver Determination Through Handler
- Handler : CL_SWN_SUBSCRIPTION as shown below screen shot.
2. Subscription Settings
- Show Action Execute As: LINK1
3. Change Filter Settings: ALL_DELTA
- DELTA: “X”
- TASK : TS20000166
4. Create an entry for General Settings:
- Settings: UI5_BSP
- Description :
- Value :
- UI5_BSP Approve Purchase Order URL:
http:// <Server Name>/sap/bc/ui5_ui5/ui2/ushell/shells/abap/FioriLaunchpad.html?sap-client=800&sap-language=EN#PurchaseOrder-approve&/HeaderDetails/WorkflowTaskCollection(SAP__Origin=’LOCAL’,WorkitemID=’{$zitem.externalObjectId}‘)
5. Create custom handler class and assign the Workflow scenario.
- Scenario: WORKFLOW
- Visualization Type : UI5_BSP
- Category: STANDARD
- Message Template: WORKFLOW1
- Notification Handler : ZCL_SWN_NOTIF_WORKFLOW
- Handler for User : CL_SWN_USER_STD
6. Creating Custom Notification Handler class
7. Redefine super class method “ADD_LINK_ACTION_EXECUTE” and following code.
METHOD add_link_action_execute.
CALL METHOD super->add_link_action_execute
CHANGING
c_links = c_links
* EXCEPTIONS
* no_subscription = 1
* others = 2
.
IF sy–subrc <> 0.
* Implement suitable error handling here
ENDIF.
*- add link invoking the workitem execution
*- according to subscription and general settings
DATA li_subs TYPE REF TO if_swn_subscription.
DATA l_execute_as TYPE swn_showactionas.
DATA lt_links TYPE swntlinks.
DATA wa_link TYPE swnslink.
DATA l_param TYPE string.
DATA l_user TYPE syuname.
DATA l_langu TYPE sylangu.
DATA l_logon_id TYPE string.
DATA: lt_text TYPE textpool_table.
DATA l_dummy TYPE c.
DATA lt_visu_tasks TYPE swntvt.
DATA l_done TYPE flag.
FIELD-SYMBOLS: <text> LIKE LINE OF lt_text.
FIELD-SYMBOLS:
<visu> TYPE swfvt.
**********************************************************
DATA: l_url TYPE string,
l_param_id TYPE swn_setting.
entered( ‘add_link_action_execute’ ).
*- note 1230808: retrieve texts in the communication language of user
lt_text = get_text_elements( ).
l_langu = m_user_ref->get_language( ).
li_subs = get_subscription_ref( ).
*- get subscription params
CALL METHOD li_subs->get_value_raw
EXPORTING
i_id = ‘SHOW_ACTION_EXECUTE_AS’ “#EC NOTEXT
RECEIVING
r_value = l_execute_as
EXCEPTIONS
OTHERS = 1.
IF l_execute_as IS INITIAL.
*- note 1057871: workitem execution should not be
*- provided within notification
EXIT.
ENDIF.
*- check if a special visualization type is requested
lt_visu_tasks = get_visu_tasks( ).
READ TABLE lt_visu_tasks WITH KEY task = app_type
ASSIGNING <visu>.
IF sy–subrc = 0.
IF <visu>–vtyp EQ ‘UI5_BSP’.
l_param_id = <visu>–vtyp.
wa_link–category = swn1_ref_type_tech.
wa_link–id = swn1_ref_id_execute.
READ TABLE lt_text ASSIGNING <text> WITH KEY id = ‘I’ key = ‘002’.
IF sy–subrc IS INITIAL.
wa_link–caption = <text>–entry.
ELSE.
wa_link–caption = ‘Workitem ausführen’(002).
ENDIF.
SELECT SINGLE value FROM swn_settings INTO l_url
WHERE parameter_id = l_param_id.
IF l_url IS NOT INITIAL.
REPLACE ‘{$zitem.externalObjectId}’ IN l_url
WITH app_key IGNORING CASE.
IF sy–subrc <> 0.
MESSAGE e155(swn) WITH wa_link–caption INTO wa_link–caption.
CLEAR wa_link–url.
ENDIF.
wa_link–url = l_url.
CLEAR : c_links[].
APPEND wa_link TO c_links.
l_done = ‘X’.
ENDIF.
ENDIF.
ENDIF.
leaving( ‘add_link_action_execute’ ).
ENDMETHOD.
4) Testing the SAP Fiori App.
1) Create purchase order using ME21 or Me21n transaction as shown below screen shot.
2) Run standard program SWN_SELSEN as background job to send external email notification.
3) Check your email inbox.
4) Launch the SAP fiori approval work item by clicking email notification hyper link, then system
should launch the sap fiori app as shown below screen.
Hi, we're having problems implementing this solution.
1. when I redefine super class method "ADD_LINK_ACTION_EXECUTE" I was getting an error re: private object GET_TEXT_ELEMENTS. I changed this and added an endless loop so I could debug.
2. When I create a new purchase order, it creates an entry in Inbox->Workflow but when I run SWN_SELSEN all values are 00000000000. The code for the redefined class does not appear to be called.
Any ideas ?
Hi Shaunna,
which class did you redefine?
I have used this class CL_SWN_NOTIF_WORKFLOW as a super class and it is private method in supper class. So I just created the GET_TEXT_ELEMENTS new method and copied the code from supper class.
Please follow the same thing and let me know if you have any issues.
Thanks & regards,
Raghava Vakada
Hi Raghava
using SE24 I had created a new class called ZCL_SWN_NOTIF_WORKFLOW as per the instructions.In the properties tab, the superclass is CL_SWN_NOTIF_WORKFLOW.
I have copied in the GET_TEXT_ELEMENTS as a new method (Level = Instance, Visibility = Private) and have copied the Private Section from the superclass too as this was causing an error.
What is the error..
You have to create two more private attributes also(M_TEXT_ELEMENTS_READ,M_TEXT_ELEMENTS) then you can activate the wrapper class..let me know if you are running any other issues..
Hi Raghava,
I'm new to SAP Fiori so could you please suggest me whether the above configuration to be done in SAP Frontend server(Gateway) or SAP Backend Server(SAP Business Suite/ECC/CRM/SRM).
Kindly suggest me to solve this issue.
Regards,
Ramana.
Hi Raghava,
these two private attributes are already there. The Z class compiles without error. My problem is that when I run step 4.Testing the Fiori App, nothing happens.
I have created the purchase order using ME21n and I have run standard program SWN_SELSEN as background job to send external email notification. But the results are 0000000000, it appears that nothing is getting picked up. Also no email arrives and I cannot see one in transaction SCOT.
I have put breakpoints in the Z Class code to see if there is a problem with the Z Class code but it is not stopping. This implies that the code is not getting executed.
Can you check all the steps above to ensure that no configuration steps are missing ?
thanks
Shaunna
Hi Shaunna,
while executing this SWN_SELSEN program, make sure you should select the check box "No Time check During Send". So that you can see emails in Transaction SOST immediately..
Thanks
Raghava
Hi Raghava
when we create a new purchase order, we can see it in the inbox. When I run SWN_SELSEN I tick the checkbox "No Time check During Send". When this program runs it shows a small report.. all values are 00000000 so it appears that the PO is NOT getting picked up. I have also checked transaction SOST and there are no emails there either.
regards
Shaunna
Hi Raghava,
Thanks for posting this.
Just to confirm, all these settings are to be done in the backend or the gateway?
I have gone through the steps and had done the config in the backend.
I have tried adding the FIORI URL for the general settings set up for UI5_BSP and for some reason it did not accept my URL.
What could be the reason, you think?
Thanks.
Hi Furaidah,
Yes..all these setting needs to be done back-end system.
It might be length issue. It will accept only 255 characters. All entries will be created in table SWN_SETTINGS and also check the data type.
For your testing, copy existing "WD_HOST" to UI5_BSP and enter your url.
This will work for you and let me know.
Thanks & regards,
Raghava Vakada
Thanks Raghava,
Unfortunately our backend is at 703 and we are in the process of the upgrade to 740, but takes sometime.
Trying to apply note 2056158 requires other notes to be applied first and we do not want to take the risk.
We are thinking of 'selectively' choosing the 'corrections' that will work for us. Is there any other option, we can explore?
Otherwise, we will need to wait for the upgrade
Thanks for your help.
Hi Raghava,
We applied note 2056158 manually, only maintaining the UI5_BSP visualizaton type.
And then we wrote the codes, as suggested by you.
And it all turned up fine !. đ Thanks again for providing us the step by step instructions.
If you have anything that we should be aware of, please share with us. We are still new with this FIORI stuff đ
Hi Furaidah,
we have having problems. We have implemented the steps as defined by Raghava above but when we get to the last step 'Testing the SAP Fiori App' and create the PO using ME23N and then run SWN_SELSEN nothing is getting picked up. Any ideas ? Did you have to make any additional changes to the steps above ? Did you have to add any extra configuration ?
thanks in advance Shaunna
Hi Shaunna,
Have you checked if your workflow has worked at all?
Try SWI6 , enter object and PO and see if there's any workflow being triggered.
Also, go to the approver's inbox (SBWP) to see if there's any work item to be released.
Once you have done that, check table SWN_NOTIF if there's any pending. IF there is, check your delivery schedule in SWNConfig.
Try these steps first and see how it goes.
Hi yusof
We are facing the same problem nothing gets picked up when we run SWN_SELSEN
I checked  the approverâs inbox we have the workflow there but when I check the table SWN_NOTIF I don't find any pending notification.
Is there extra configurations that needs to be done ?
Thank you
Hi,
If you just redefine method ADD_LINK_ACTION_EXECUTE it won't be called because method ADD_LINKS_ACTION will call the same method but in the superclass.
In my opinion it would be a better option to copy class CL_SWN_NOTIF_WORKFLOW to customer namespace.
Regards
Hi Salema,
Add_links_action call the method add_link_action_execute at line number at bottom of the method. you can debug the code while running the program swn_notif.
Please check the receiver personal number communication info type 0105 subtype 0010/0001 recipient address and recipient type in transaction PA30.
It will resolve many issues.
Regards,
Raghava
Hi,
That's exactly my point.
The calling stack for class CL_SWN_NOTIF_WORKFLOW is the following:
IF_SWN_NOTIF~GET_LINKS (entry point from BSP swn_message1)
ADD_LINKS_ACTION
ADD_LINK_ACTION_EXECUTE
You need to redefine at least all these 3 methods, otherwise the ADD_LINK_ACTION_EXECUTE is called in superclass, not in the Z class.
Regards,
Rui
Hi Rui,
I don't know why you need to redefine all 3 methods.
as per above my blog scenario, I don't need to redefine all other methods
just redefine method ADD_LINK_ACTION_EXECUTE and add your custom logic .
Thanks,
Raghava Vakada
Hi Raghava,
your solution is very interesting but I have not the full picture.
My question is: which user will be used to execute the work item?
I would be interested in using this solution from a mobile client (IOS or Android smartphone). The user will receive the mail notification with the link to work item execution in his mail client; clicking on the link he should automatically logon to Fiori. How can it work? There should be some single sign on mechanism with the on the smartphone?
Am I missing something?
Thanks and regards,
Bruno
Hello Bruno,
Depends on workflow configuration. if a user received the workitem and he has approval authorizations. then he can execute the workitem..
No..It will ask you first login details and then launch the approval workitem if login credentials are correct..
Thanks & regards,
Raghava vakada
Hi Raghava,
We have followed the steps mentioned above. We don't have the Approve Purchase Orders app, but we are trying to link the My Inbox app. Here, however, we are unable to find the Approve/ Reject buttons against the PO. We are using the standard PO approval workflow and I see that the decision keys are defined for the same in SPRO.
Kindly let us know what is going wrong.
Thanks,
SD
Hi Raghava,
I used the above solution also I changed the handler at category level .
Everything seems good but for substitute users the email body appears to be blank.
Regards,
Gaurang
Hello Raghava,
I am new to FIORI App. Actually we have implemented the PO Reject/Released workflow to Fiori. when user Release the PO through the FIORI APP then the notification is not reaching to buyer. Could you please help me on this.
Thanks and Regards,
Muralikrishna Peravali
Hello,
I am cĂșrrenclty facing issues with extended notifications that only for non dialog users the extended notification works not for the personal user. Could you pleae let me know if this is a standard functionality ?
Thanks and Regards,
Vijaya Chintarlapalli