Skip to Content

Hi Everyone,

This is my first blog.Hope you all will read it & give me your valuable suggestions regarding the content.

The objective of the blog is to create a very simple custom WDJ Application to process tasks using BPM JAVA API in NWDS 7.3 instead of using Universal Worklist provided by SAP. Though SAP provided us an user inbox under Universal Worklist Tab in Portal.But some time client want a customized user inbox created using WDJ Application.With the Business Process Management (BPM) application programming interfaces (API’s), we can customize and enhance the way we use business processes and execute tasks and can design user friendly inbox for better user experience and performances.

Steps:

1.0.Install SAP Net weaver Developer Studio (NWDS 7.3).

2.0.BPEM End User & Every User Core Role should be assigned to user.

3.0.Create the Web Dynpro Java Application in NWDS 7.3

3.1. Create a WebDynpro Java DC comprising of one component controller,view and application inside it. Iamge_1.JPG
3.2.

Add following  dependencies to the Web Dynpro Java DC through Component Properties View.

a)tc/bpem/façade/ear  – BPEM-FAÇADE

b)tc/je/sdo21/pi – ENFCADE

Image_2.JPG
3.3.

Add following Application Properties to enable the default Logon Portal Page into WDJ application.

Name:sap.authentication

Type:True

Description:Authentication Mode

Image_3.JPG
3.4. Create a node “Task” with the attributes CreationDate,ID,Name and URL in both Component Controller(New1Comp) and View Controller(New1CompView) and create context mapping also. Image_4.JPG
3.5. Create a view with a label and a table with four columns Name,ID, CreationTime and URL and assigned an event for the “onSelect” property of the table. Image_5.JPG

3.6. Create one action “OnSelectTask” and implemented the following code inside it.


public void onActionOnSelectTask (com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@beginonActionOnSelectTask(ServerEvent)
            String url=wdContext.currentTaskElement().getURL();
            wdThis.wdGetNew1CompController().LinkToOpenTask(url);
    //@@end
  }

3.7.In Component Controller implemented following codes in wdDoInit() and LinkToOpenTask( java.lang.String url )methods.


public void wdDoInit()
  {
//@@beginwdDoInit()
ArrayList<TaskDetail> testList = new ArrayList<TaskDetail>();
try {
//To get the logged on user details
IUser user = UMFactory.getAuthenticator().getLoggedInUser();
      String firstName = user.getFirstName();
      String lastName = user.getLastName();
      String userName = firstName != null ? firstName + " " + lastName: lastName;  
      wdComponentAPI.getMessageManager().reportSuccess("Welcome "+userName);
// Retrieve the TaskInstanceManager.
TaskInstanceManager taskInstanceManager = BPMFactory.getTaskInstanceManager() ;
// Build the set of statuses to query.
Typically, use READY, RESERVED and IN_PROGRESS statuses, which mean that the tasks are ready to work on and the user is a potential or actual owner of the task.
HashSet<Status> statuses = new HashSet<Status> ();
statuses.add(Status.READY);
statuses.add(Status.RESERVED);
statuses.add(Status.IN_PROGRESS);
// Query those statuses.
The returned set contains TaskAbstracts, which are basic descriptions of a task instance and thus contain the required information to build up the task worklist. The method always executes the query for the user who is currently logged in and returns texts in the locale which is set for the user.
Set<TaskAbstract> myTasks = taskInstanceManager.getMyTaskAbstracts(statuses);
//Use Iterator of type TaskAbstract to loop trough the myTasks.
Iterator<TaskAbstract> taskIter = myTasks.iterator();
URL taskExecutionURL=null;
while(taskIter.hasNext()){
//Get single Task
TaskAbstract myTask = taskIter.next();
// Get the ID of the Task.
java.net.URI taskInstanceId = myTask.getId();
// Use the ID of a task instance to generate the URL of the task execution UI. This can then be opened as an action, for example when the user clicks the task.                
taskExecutionURL = taskInstanceManager.generateTaskExecutionUrl(taskInstanceId);
TaskDetail taskDetail = taskInstanceManager.getTaskDetail(taskInstanceId);
testList.add(taskDetail);
// Filter the tasks for the current year “2013”
if((""+myTask.getCreatedTime()).contains("2013") ){
IPublicNew1Comp.ITaskElement Ele =wdContext.nodeTask().createTaskElement();
Ele.setID((""+myTask.getId()).substring((""+myTask.getId()).lastIndexOf("/")+1));
Ele.setName(myTask.getPresentationName());
Ele.setCreationDate(""+myTask.getCreatedTime());
Ele.setURL(taskExecutionURL.toString());
wdContext.nodeTask().addElement(Ele);
}}
catch (BPMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
wdComponentAPI.getMessageManager().reportException(e);
}
//@@end
}

public void LinkToOpenTask( java.lang.String url )  {
//@@beginLinkToOpenTask()
//Open window to view the Task
IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(url, "Task",false);
window.show();
    //@@end
  }

3.8. Build,Deploy & Run the application

4.0. Result:

4.1. Logon Screen:- Image_6.JPG
4.2. User will be able to see all the listed tasks and click on selected task and perform it. Image_7.JPG

Thanks & Regards,

Patralekha Sur

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply