Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
leigh_mason
Employee
Employee

System Details

NetWeaver Gateway

Component

Ver

SP

Description

SAP_BASIS

731

6

SAP Basis Component

SAP_ABA

731

6

Cross-Application Component

GW_CORE

200

6

SAP GW CORE 200

IW_BEP

200

6

Backend Event Provider

UISAPUI5

100

4

SAP UI5

IW_FND

250

6

SAP IW FND 250

SAP Notes of Interest

  • 1805831 - Workflow Support Decision options Nature (Positive/Negative)
  • 1884623 - SP04: Fixes and performance improvements for Fiori Home

Thanks

Thanks to masayuki.sekihara for all his support in providing guidance for our Fiori implementation.  He provided the sample BADI implementation for us as well as answering numerous emails and phone calls.

Useful Links

Assumptions

  • Included some sanity checking with RFC setup etc, this isn’t supposed to be an exhaustive setup guide.  I've assumed you've followed the installation and configuration guide

  • I haven’t gone into a great deal of detail in some cases, I’m assuming you know how to do things such as creating a BADI implementation.

  • You've installed the correct add-ons on both Gateway and target system such as SRM or ECC.

Introduction

A recent twitter conversation between John Moy and Jocelyn Dart prompted me to do a quick blog about the Fiori Generic Approval application. 

The Generic Approval application in Fiori was delivered to provide an Approve / Reject functionality for any SAP workflow with a decision task.  I had a chat to Masa about this and he indicated that the application was also for non-SAP workflow as well ( that would be an interesting blog ).

The application name is ui5_ca_all_apv and you will be able to find the application in the BSP repository via SE80.  If you can’t find the app, then it may not be installed.  Check with whoever did the add-on installations in this case.

We had recently implemented this at a customer and probably went through the same learning curve as everyone else, I hope you find my experiences useful in your implementations.

Apart from the installation of add-ons and making sense of all the SAP Notes ( hardest part ) the Generic Approval ( in our case Leave Request ) was relatively easy to get up and running.

I can hear what you’re all saying, “why not use the standard leave app…” yes, but when you’re working with ITS based leave services, the standard Fiori Leave application doesn’t work hence we used the Generic Approval application instead.

What I wanted to cover:

  • IMG config Gateway + ECC
  • Fiori Catalog and Tile creation
  • PFCG Role Assignment
  • BADI Implementation ( container operation for pushing the workflow along )
  • Adding “approval notes” or “rejection notes”
  • Final Result

What I am not going to cover:

  • Installation - including the SAP Note list for SP6 for Gateway
  • Workflow Build – Assume you have a workflow decision task and workflow scenario ready to rock

Remember, our scenario here is a generic Leave Request approval.  You can apply the same concepts here to other general approval tasks.

OData, RFC Setup and Other Sanity Checks

At some stage, there were a stack of issues for me ( including security stuff ) where I had to go back and verify the configuration of RFC’s and the IMG activities.

This section is just for a sanity check and a place to start looking of things go wrong if your Fiori application starts throwing errors ( such as no RFC destination, OData service errors ).

We also used the Gateway services test harness which shows us the return codes and response for OData services.  When they are returning 200 OK codes you're in good shape, there are some other good tools in there as well to help you work out what's going wrong from the OData side.

Security Issues

Run traces in ST01 when getting authorisation errors, 9 times out of 10 for us, it was a missing authorisation object like S_SERVICE or S_RFCACL.

Follow the installation guide that describes using role templates and copy them.

The other thing to watch out for here is authorisations on the target system.  Ensure your users have the correct authorisations ( e.g. for HR, consider structural auths ).

RFC Entries

  • Check your RFC’s via SM59
  • Ensure that the settings as explained in the installation guide or Masa’s documents are followed.  Take note of the Trust settings

Manage SAP System Aliases

Manage SAP System Aliases SAP NetWeaver->Gateway->OData Channel->Connection Settings->SAP NetWeaver Gateway to SAP System->Manage SAP System Aliases


Check entries here:

  • Check you have two entries, both will point to the same RFC destination.  The alias ending with "PGW" is used for software version /IWPGW/BWF for business workflow, this is the task provider for ECC in our case.
  • Your naming conventions maybe different but ensure the System ID and Client number are populated ( had to blank them out for this blog )

Assign SAP System Aliases to OData Service

SAP NetWeaver->Gateway->OData Channel Development with IW_BEP->Registration->Assign SAP System Aliases to OData Service

Check the entries here:

  • Entry for ZLEAVEAPPROVAL_0001, SAP System Alias will point to the "DEFAULT" software version.
  • Entry for TASKPROCESSING, SAP System Alias will point to the “/IWPGW/BWF" software version.

Activate and Maintain Services

Transaction /IWFND/MAINT_SERVICE SAP NetWeaver->Gateway->OData Channel Development with IW_BEP->Registration->Activate and Maintain Services

Check your entries here:

  • Check ZTASKPROCESSING is pointing to the "/IWPGF/BWF" software version.  The system alias ( in the bottom right corner of the picture ) ends with "_PGW'. 
  • You can also test the service here, which will give you better details and logs if the service fails when called, you’ll have access to the response from the target system too.

Check entries here:

  • For the ZLEAVEAPPROVAL app, make sure the SAP System Alias is pointing to the "DEFAULT" software version, NOT the "/IWPGW/BWF" software version ( see the System Aliases at the bottom right of the picture ).

Testing Services

When you test the services, you should be getting 200OK codes to show you the test was successful. If this is not happening ( could be many reasons ) you can now see the Error Log and the Response which will help you track down SAP Notes, Knowledge Articles on SCN or Service Market Place.

SICF Activation

As always, there is always someone who doesn’t activate their services via SICF.  Make sure the correct SICF entries are activated for the functionality you require.

Gateway Configuration – SPRO

SAP NetWeaver->Gateway Service Enablement->Content->Task Gateway Service->Scenario Definition

You have created a Scenario Definition

  • Notice the Technical Service name is pointing to the IWPGW/TASKPROCESSING

Set your consumer types

  • Make sure your consumer types DESKTOP / MOBILE / TABLET are set.

Assign Task Definition

  • Here check that your SAP System Alias is pointing to the alias with software version "/IWPGW/BWF".
  • Ensure your “TSxxxxxxx” number is correct  This will be the approval task ID in your ECC system.

ECC Configuration – SPRO

There are a couple of things to check here.

SAP NetWeaver->Gateway Service Enablement->Content->Workflow Settings

Check Entries here:

  • Ensure your Workflow ID is correct
  • Ensure the Step ID of the approval task in the worklow is correct ( validate this in SWDD )
  • You have 2 entries for Decision, Approve / Reject ( remember the keys, it’s important when implementing the BADI ).
  • Ensure you’ve selected the POSTIVE, or NEGATIVE from the drop down list
  • NB: Ensure you’ve installed the correct SAP Notes that provide the extensions necessary to perform this configuration.

Tile Configuration – Fiori Admin Page

Here is where we configure the Fiori Tile from the Admin page.  In our implementation we used the catalog ID of SAP_HCM003_HCM_LVRQ_APR only because it already had the appropriate authorisations attached the standard SAP role.  But you can create your own.  Just wanted to explain this because the screen shots may be confusing.

Launch the Admin tool:

http://<host>:<port>/sap/bc/ui5_ui5/ui2/launchpage/admin/admin.html?sap-client=XXX&sap-language=EN

Here is the Catalog page

  • You can create your own Catalog here for the generic application
  • We decided to add another one into HCM003_HCM_LVRQ_APR to take advantage of the SAP Standard Security Role. 

  • When you create a new Tile, create via App Launcher (dynamic)

  • Enter Title, Icon, Service URL and Target URL

Service URL

  • URL for OData service to retrieve data, ensure your SCENARIO ID is included here, the apostrophes are important

/sap/opu/OData/iwpgw/taskprocessing;mo/ScenarioCollection/?$filter=key eq 'Z_APPROVE_LEAVE'

Target URL

  • URL for navigation, you don’t need the apostrophes here.

/sap/bc/ui5_ui5/sap/ui5_ca_all_apv/index.html?backToHome=true&scenarioId=Z_APPROVE_LEAVE

You should have a new Catalog with Tile:

Tile Display via PFCG Role

When you want the tile to display for the Generic Approval application, you can follow the installation guide (7.3 Configure Launch Settings for Custom Workflows).

The screenshot below shows where the settings are made in transaction PFCG.  Note the Type / Object / Text.

  • In object, ensure the PAGEID= <Your Catalog Name>

Launch Page

You should be able to test the launch of the application now.  You should see your Generic Approval application displayed as a Tile.

  • http://<host>:<port>/sap/bc/ui5_ui5/ui2/launchpage/home.html


You can open the application, but it won’t approve/reject yet as you need to implement the BADI in order to process your workflow task.  If you have approval tasks assigned and the app / OData services are working, you should see the work item count.

BADI Implementation

In order to approve/reject your approval task, you need a plug in point to process the decision keys you’ve configured earlier.

You can use BADI definition:

/IWWRK/BADI_WF_BEFORE_UPD_IB

  • Create your own enhancement implementation and also an implementation class
  • Ensure you enter values for Filter Values STEP_ID and WORKFLOW_ID.  This will ensure the BADI is only executed for your defined workflows and steps.

Sample Code

In the method “/iwwrk/if_wf_wi_before_upd_ib~before_update” you implement code for handling the workflow decision triggered for the Generic Approval application.

Here is some sample code from masayuki.sekihara.  I've added in a couple more things like adding attachments.

 DATA ls_object          TYPE swr_obj_2.
  DATA lv_objtype         TYPE swr_struct-object_typ.
  DATA lv_objkey          TYPE swr_struct-object_key.
  DATA lv_subrc           TYPE sy-subrc.
  DATA lt_container       TYPE TABLE OF swr_cont.
  DATA ls_container_line  TYPE swr_cont.
  DATA formnumber         TYPE swxformabs-formnumber.
  DATA ls_formabs         TYPE swxformabs.
  DATA lt_header          TYPE TABLE OF solisti1.
  DATA lv_return          TYPE swotreturn.
  DATA lt_attachments     TYPE TABLE OF swrsobjid.
  DATA ls_attachment      LIKE LINE OF lt_attachments.
  DATA lt_messages        TYPE TABLE OF swr_messag.
  DATA ls_comments_line   LIKE LINE OF it_wf_container_tab.
  DATA ls_attachment_hdr  TYPE swr_att_header.
  DATA lv_notes           TYPE string.
**********************************************************************
* ATTACH NOTES AS SOFM DOCUMENT
**********************************************************************
  READ TABLE it_wf_container_tab INTO ls_comments_line WITH KEY element = 'ACTION_COMMENTS'.
  IF sy-subrc = 0.
    MOVE ls_comments_line-value TO lv_notes.
ls_attachment_hdr-file_extension = '.htm'.
ls_attachment_hdr-file_type      = 'T'.
    ls_attachment_hdr-language       = 'EN'.
ls_attachment_hdr-file_name      = 'Approver Comments'.
    CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'
      EXPORTING
workitem_id    = is_wi_details-wi_id
att_header     = ls_attachment_hdr
        att_txt        = lv_notes
        document_owner = sy-uname
        language       = sy-langu
        do_commit      = 'X'
      IMPORTING
return_code    = lv_subrc
      TABLES
message_lines  = lt_messages.
  ENDIF.
  "Read the workflow's container data
  CALL FUNCTION 'SAP_WAPI_READ_CONTAINER'
    EXPORTING
      workitem_id      = is_wi_details-wi_id
    IMPORTING
      return_code      = lv_subrc
    TABLES
      simple_container = lt_container.
  " Check which decision was selected and set the data
  " values appropriately
  CASE iv_decision_key.
    WHEN 0001. "Approved
ls_container_line-value = 'A'.
ls_formabs-procstate = 'A'.
    WHEN 0002. "Rejected
ls_container_line-value = 'R'.
      ls_formabs-procstate = 'R'.
  ENDCASE.
  "ACTUALSTATE is what the workflow keys off to determine
  "which path to follow - Approve or Reject path
ls_container_line-element = 'ACTUALSTATE'.
*  "Modify the workflow's container data - we are updating the row that
*  "holds ACTUALSTATE which will be in the second row of the table
  MODIFY lt_container  FROM ls_container_line TRANSPORTING value WHERE element = 'ACTUALSTATE'.
ls_container_line-element = 'USAPPROVER'.
  CONCATENATE 'US' sy-uname INTO ls_container_line-value.
  MODIFY lt_container  FROM ls_container_line TRANSPORTING value WHERE element = 'USAPPROVER'.
**********************************************************************
* WRITE CONTAINER AND COMMIT CHANGES
**********************************************************************
  "Write the updated container back to the workflow engine
  CALL FUNCTION 'SAP_WAPI_WRITE_CONTAINER'
    EXPORTING
      workitem_id      = is_wi_details-wi_id
      do_commit        = 'X'
    IMPORTING
      return_code      = lv_subrc
    TABLES
      simple_container = lt_container.
  IF sy-subrc NE 0.
    "Handle error
  ENDIF.
  "Complete the task
  CALL FUNCTION 'SAP_WAPI_WORKITEM_COMPLETE'
    EXPORTING
      workitem_id = is_wi_details-wi_id.
  "This task requires a confirm to be fully completed
  "and start the next step in the workflow
  CALL FUNCTION 'SAP_WAPI_WORKITEM_CONFIRM'
    EXPORTING
      workitem_id = is_wi_details-wi_id.

Adding Rejection / Approval Comments

When you approve / reject the workflow item, Fiori pops up a screen to allow the user to enter comments.

I couldn’t work out where this was possible to capture for the generic scenario so we used the function 'SAP_WAPI_ATTACHMENT_ADD'.  You can extract the comments from the passed in container with element 'ACTION_COMMENTS'.


The one thing I noticed here, the attachments are created successfully.  What you should see in the Fiori application on the approval page is a purple Icon:

Sometimes the notes are created and the purple Icon displays.  Other times the notes are created and the “paperclip” is show ( a link to a .html document ).

I’m still baffled by this and need to look into it further.  If anyone has the answer, please post it in response to this blog.

Results

You should now be able to approve/reject a workflow task.  When you open your Tile, you’ll see the items waiting to be approved on the left, and some basic details and information on the right.

You’ll see there are few screen elements here worthy of explanation:

  • Title “Process leave request for …” is from the title of the work item task
  • Description, as the name suggest, is the description you have defined in the workflow task
  • SAP WORKFLOW user.  This is the technical name of the workflow batch user.  This appears here when the item is first generated and pulled into the Fiori application.  I’m still working on figuring out how / why this happens.  After you approve / reject the item, the correct name appears instead.

Final Thoughts

I hope this blog helps you during the implementation of the Generic Approval application in Fiori.  I know I haven’t covered a bunch of details here however these should be in the installation and configuration guides.

The biggest challenge we faced was installing all the of the SAP Notes correctly which would make for a good blog for someone else.

Again, the usual suspects need to be checked, SICF and security roles and configuration errors that caused us grief during testing. 

I hope some of the sanity checks help you because I had to trawl through all of this for hours to work out what we had done wrong at some point of our implementation.

Lastly, if you have any feedback on the content in this blog or would like to see more information added, drop me a line.  Share your experiences with the Generic Approval application so we can build on our collective experience

Follow up Blogs

Here are some interesting topics I'd like to blog about next, unless someone else in the community wants to tackle them as well:

  • Using the Generic Approval application in a Non-SAP environment
  • Using the Generic Approval application with another software version /IWPGW/BPM for example
  • Deep Dive into the Task Gateway Service

Questions

I'm going to have a look at answering the following questions which I raised while putting the blog together:

  • Why does SAP_WAPI_ATTACHMENT_ADD create notes in the task differently, sometimes it appears in Notes, other times as an attachment, what the....

39 Comments