SAP Virtual/Onsite Trainings

Document Categories:

What's New?

Contribute?

Sample Specs

What's Hot?

Web Dynpro for ABAP Tutorials 


Join the Mailing List
Enter name and email address below:
Name:
Email:
Subscribe  Unsubscribe 

Display Dynamic Attachments in Work Item in Workflow

By Anirban Bhattacharjee, KPIT Cummins and Infosystems

Purpose: The purpose of this article is to show you how to display dynamic attachments in work items in workflow

Business Scenario: This is useful in all workflows across all modules. The scenario I am taking for an example is the Travel and Expense Workflow, related to the PR05 and TRIP transactions. When an employee creates an expense report in the T&E Module, he needs to attach receipts to justify the expense. The application in R/3 (PR05 / TRIP) or the ESS MSS Application via portal processes this attachment to the GOS Attachments folder. After the attachment the employee submits the TRIP which triggers the workflow and routes the work item for approval. In the workflow just before the foreground work item creation, we can read the GOS Folder and attach the documents as a physical attachment.

But many times the employee forgets to do the attachment and completes it after TRIP submission and hence work-item creation. The approver now cannot see this new document attached after workflow trigger and TRIP Submission.

This article will show how to make this happen. You will be able to enable a feature such that approvers can view all attachments done after TRIP Submission and hence the workflow trigger.

Process: The process will involve the following steps

·         Create a custom business object that will read the GOS Attachment. This method will be called as the default method in the BOR.

·         Create a custom workflow for demo. In this workflow we will use the main SAP Business Object for TRIP; BUS2089 (Employee Trip).

·         We will instantiate the custom BOR in the workflow and attach it to the _ADHOC_OBJECT element to create the dynamic GOS attachment link.

·         We can test in Business Workplace (SBWP) or the UWL in Portal if you have portal in your project.

STEP 1: Create a Custom Business Object

(I am not going into the details of business object creation. That is not in this document scope)

We call this business object as ZTRIP_NEW (Display TRIP Attachments in Real Time).

We create a method GOS_ATTACH_DISPLAY as shown below

(Please overlook the other methods. They are not related to this topic)

This method has no parameters

This is an instance depended method, that is the BOR must be instantiated to call this method

In order to display the GOS Attachments, we will call the function module GOS_ATTACHMENT_LIST_POPUP.

Here we will pass the importing parameter IP_MODE as ‘D’ to ensure that the attachments can only be displayed.

The approver should not be able to add or remove any attachments.

The code you will write in this method is shown below

begin_method gos_attach_display changing container.

DATA: is_object TYPE sibflporb.

is_object-typeid = 
'BUS2089'.
is_object-catid  = 
'BO'.
is_object-instid = object-
key.
* GOS Attachments
CALL FUNCTION 'GOS_ATTACHMENT_LIST_POPUP'
  
EXPORTING
    is_object             = is_object
    ip_check_arl          = 
'X'
    ip_check_bds          = 
'X'
    ip_notes              = 
'X'
    ip_attachments        = 
'X'
    ip_urls               = 
'X'
    ip_mode               = 
'D'
*  IMPORTING
*    EP_SAVE_REQUEST       =
*  TABLES
*    IT_OBJECTS            =
          .
end_method.

Please note that we are building the TRIP key here along with Business Object (BUS2089 for TRIP) and Category ID (BO for Business Object).

This function module will read this unique key combination of the instance (TRIP and Employee Number) with the Business Object ID and Cat ID and display the attachment list.

Now once the method is created, we will mark this method as a default method. I will explain later why we are doing this.

In the BOR Screen, navigate to the Basic Data (CTRL+SHIFT+F1) of the BOR by clicking on the HAT Icon as shown

We navigate to this screen now. Click on the DEFAULTS Tab

Enter the Method GOS_ATTACH_DISPLAY and pass attribute as TRIP Number. This will display in the work item as a link

We save and activate the BOR and mark the method and the BOR as Implemented and Released.

(This is a standard process to be followed when creating a custom BOR).

The above process completes our first step of creating and activating or Custom BOR that will read the GOS attachment.

STEP 2: Create a Custom Workflow

We will create a custom workflow with simply two steps.

The first step will instantiate our custom BOR, second step will be the user decision that will be sent to the approver.

The workflow will be modeled on the standard SAP business object BUS2089 as the main business object.

Run PFTC and create the workflow template, name it as shown and save it

Click here to continue...

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image