Skip to Content

How often have you seen the following UWL UI:

image

and how often have you wished that you could have a UWL with a better UI like:

image

Many times in your portal implementation you are completely revamping the look and feel of the portal and the standard UWL just doesn’t fit in. You can always take the SAP shipped PAR file and modify that to achieve the desired look & feel, however it’s not easy as it’ll paobably require decompiling of lots of classes and even then it can become pretty complex.

You can now make use of the UWL API released with NetWeaver 2004s SP9 to achieve this. The JavaDoc can be referenced from http://www.sdn.sap.com/irj/sdn/javadocs

    <property name=”ServicesReference” value=”SAPJ2EE::library:tckmcbc.uwl~api”/>

Also make sure that you have bc.uwl.service.api_api.jar file in the build path for your project. Now in the JSP proceed as follows:

The above code gets a handle to the UWL service from the portal runtime and creates a session for the current user.

The above code makes use of the Item Manager to get a collection of the worklist items for the current user.

The above code gives the items in a java.util.List object which you can iterate through to retrieve the individual items and also the other details like Subject, Due Date etc.

Now the only thing that remains is to know the URL of the individual items for being able to launch the items from the custom UWL items hyperlinks. Here it’s important to know the type of the work item i.e. whether it’s coming from the Adhoc Workflow or Guided procedure or R/3 workflow. To get the type of item do this:

String connectorId = item.getConnectorId();

This returns a string with value as AdHocWorkflowConnector or GuidedProceduresConnector or WebFlowConnector. The URL should be formed depending on the type of the item. For example for the AdHocWorkflowConnector the default URL is:

+
“/irj/portal?NavigationTarget=ROLES%3A//portal_content/every_user/general/uwl/com.sap.netweaver.bc.uwl.uwlSapWebDynproLaunch&System=SAP_LocalSystem&WebDynproDeployableObject=sap.com%2Ftc%7Eeu%7Ejwf%7Ewf%7Ewdtd&WebDynproApplication=JWFTaskDetail&DynamicParameter=internalId%3D” + item.getInternalId() + “%26action%3Dsubprocess%26item_type%3D” + item.getItemType() + “%26external_obj_type%3D”+ item.getExternalType() + “%26dueDate%3D” + item.getDueDate() + “%2B12%253A00%253A00.0%26appContext%3D” + item.getAppContext() + “%26System%3DSAP_LocalSystem%26launchContext%3DUWL%26subject%3D” + item.getSubject() + “%26external_obj_id%3D” + item.getExternalObjectId() + “%26item_id%3D” + item.getExternalId() + “%26wi_id%3D” + item.getExternalId() + “&NavigationContext=”
+

Now when you click on the link you are presented the same work item screen that you would have got with the standard UWL.

To report this post you need to login first.

28 Comments

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

  1. Anonymous
    Hey Manish, great blog. I would surely try it in my next implementation 🙂 !!! Thanks buddy.
    (0) 
    1. Patrick Lotter
      Hi all!

      Short question,

      where is difference between putting this code in a portal component or a stand-alone web dynpro for java application?

      Kind regards, Patrick.

      (0) 
  2. gopal krishna
    In this FLASHY UWL can you develop this using Bean class.
    Not defining the below code in jsp.
    IUWLService uwlService = (IUWLService) PortalRuntime.getRuntimeResources().getService(IUWLService.ALIAS_KEY);
    UWLContext uwlContext = new UWLContext();
    IUser user = componentRequest.getUser();
    uwlContext.setUser(user);
    uwlService.beginSession(uwlContext, 20);
    And the above code in the class implementation.
    (0) 
    1. Manish Chaitanya Post author
      Hi Gopal,

      Yes you should be able to write that code in a class provided you pass uwlService, uwlContext and componentRequest explicitly to that class.

      Regards,
      Manish

      (0) 
      1. gopal krishna
        Thanks for your great reply.
        I am trying in this way is this the correct way.
        public void doProcessBeforeOutput() throws PageException {
                  Form myForm = this.getForm();
                 try{
            IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
                       HttpServletRequest servletRequest = request.getServletRequest();
             obj.setMsg(“GOPAL GEMS”);
                      
                       IUWLService uwlService ;
                       uwlService = (IUWLService)PortalRuntime.getRuntimeResources().getService(IUWLService.ALIAS_KEY);
                       //uwlService = (IUWLService)PortalRuntime.getRuntimeResources().getService(“UniversalWorklistService”);
                       //servletRequest.setAttribute(“test”,obj);
                       UWLContext uwlContext = getUserContext(request);
                       IUWLViewManager viewManager = uwlService.getViewManager(uwlContext);
                       IUWLItemManager itemManager = uwlService.getItemManager(uwlContext);
                       IUWLSession session = uwlService.beginSession(uwlContext,20);
                       QueryResult result = itemManager.getItems(uwlContext,null,null);
                       String count = String.valueOf(result.getTotalNumberOfItems());
                       
                       QueryProperties queryParams = new QueryProperties();
                       ArrayList cond = new ArrayList();
                       ArrayList compoundExprs = new ArrayList();
                       IDescriptionResourceBundle descbundle = new IDescriptionResourceBundle();
                       
                       Descriptions desc = new Descriptions();
                       //CompoundExpression expr = new CompoundExpression.
                       itemManager.               
                       IPortalComponentContext compContext = request.getComponentContext();
                       myForm.addText( “Count=” + count);
                        this.setJspName(“UWL.jsp”);
                 }catch(Exception e){}
            }
        (0) 
        1. Manish Chaitanya Post author
          Hi Gopal,

          I didn’t understand where you want to show the UWL. You are creating an instance of Form with

          Form myForm = this.getForm();
          as well as sending the response to UWL.jsp.

          Also I’m not sure if this will work:
          UWLContext uwlContext = getUserContext(request);

          I would prefer this:
          UWLContext uwlContext = new UWLContext();
          IUser user = componentRequest.getUser();
          uwlContext.setUser(user);

          Thanks & regards,
          Manish

          (0) 
          1. gopal krishna
            Yaa Manish,
            That did not worked for me.
            I am trying to pass uwlService, uwlContext and componentRequest to a class.Rather than writing all the code in jsp.
            Thanks for your help
            Gopal.
            Your’s “Accessing a web page protected by BASIC authentication” is also an excellent one.

            (0) 
  3. Doug Steckel
    Thanks Manish,

    In my search to understand how we might create a workflow notifier to notify users of backend workflow items. I ran across this blog and it was very helpful. Imagine an iView like your flashy example below but with only a visual cue (waving flag maybe) and the same (1 items 0 new) text. It would be a clacable jumping off point to the actual UWL on another portal page. That’s what we’re thinking about doing.

    I have no great UWL experience and was a little confused as in the example code there seemed to be no reference to other backend systems, workfows, etc. What am I missing?

    Also, we are not yet on 2004s so I assume this simply can not hapen until then. I’d be interested to hear your or anyone elses suggested alternatives. Maybe access a BAPI from a java or WebDynpro iView to obtain the same information for the notifier described?

    Thanks for this great blog!

    Doug

    (0) 
    1. Manish Chaitanya Post author
      Hi Doug,

      Thanks for your comments.

      As you mentioned, in the example code is no reference to other backend systems, workfows, etc. The reason is that any workfolw would be connected to the SAP Portal UWL by using UWL connectors. And my example code fetches the items from Portal’s UWL service. So it’ll fetch all itmes from all the workflows that have been connected to Portal’s UWL service.

      Yes, if you are not yet on 2004s then, you can’t use the UWL API that my blog suggests.

      The only other alternative that even I can think of in what you have already mentioned. Calling a BAPI from a java iView for the notifier.

      Thanks & regards,
      Manish

      (0) 
  4. Mohammad Azimzadeh
    Hi,

    I am new in SAP and web dynpro. I have a question about this UWL. first of all let me tell you what I want to do, I want to create a UWL in portal application of web dynpro. I used your code but i can not see anything! can you plz tell me what else do I have to do and where should I your code. right now I put them in here:
    public void doContent(IPortalComponentRequest request, final IPortalComponentResponse response)
        {
    //your code
    }

    (0) 
  5. gopal krishna
    Hi Manish,
    I had implemented and done all the configurations as you said in portalapps.xml.And I am getting an error
    Portal Runtime Error

    An exception occurred while processing a request for :
    iView : N/A
    Component Name : N/A

    Could not find portal application SAPJ2EE::library:tc~kmc~bc.uwl~api.
    Exception id: 02:26_15/05/07_0002_6015150
    See the details for the exception ID in the log file
    kindly please help me in this regard.
    I am using sneak preview version EP 6.0 SP16
    Thanks,
    Gopal.sattiraju

    (0) 
  6. Sue Kee
    Hi there,

    i saw there the codes are implemented in a jsp. Would like to check if the above are applicable in Web Dynpro? if so, can check with you with jar file contains the PortalRuntime class?

    Thanks in advance.

    Regards,
    Sue

    (0) 
  7. Suresh Kumar
    Hi Manish,

    I hope you are doing well. I have gone through your blog https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/5450. [original link is broken] [original link is broken] It is very nice to get latest notifications with the simple code given by you.  Here I have implmented the same, it is working fine with portal component.

    In our requirement I have to implement the same scenario using portal service.

    I have implemented one service with the same code what you have given, in the service we can’t get the portal request for that i have used the code “IUser user = UMFactory.getUserFactory().getUserByLogonID(userID);”. While using this code I am getting exception. The below is the exception i have got while running the service

    service UWLException exception  com.sap.netweaver.bc.uwl.UWLException: (Default) Logged in users context or session doesn’t exist.

    Could you please give me a suggestion how can I implement the same code using portal service. I have tried in many ways at last I am failed to get the solution.

    Regards
    Suresh

    (0) 
  8. Tony Isaac
    Hi Manish,

    I am trying to develop a custom UWL listing with webdynpro ,following this blog. Since componentRequest is not availble , I am trying to get user with Other user-data fetching API and I am able to pass the user to UWLContext also.But when I am trying to fetch ItemMaster, I am getting that object as null. Do u have any idea about this. Please share you sugestion.

    Thanks ,
    Tony Isaac.

    (0) 
  9. Bhabesh Patel
    Very good block and I am able to use it also…how do I construct the task URL for GuidedProceduresConnector like you have shown for AdHocWorkflowConnector??
    (0) 
  10. Gaurang Dayal
    Hi Manish,

    Thanks a lot for a nice blog.. i’m using the same to view and execute workflow tasks. my question is how to form a URL for a web flow connector similar to the one you’ve given for the AdHocWorkflowConnector.

    Best Regards
    Gaurang Dayal

    (0) 
  11. Avijit Dhar
    Hi Manish,

    Thanks for the blog. But can you provide some help on how can the url for the WebFlowConnector type workitems can be created as you shown for the AdhocWorkFlowConnector. Atleast if you can give some hint.

    Thanks and Regards
    Avijit

    (0) 
    1. Manish Chaitanya Post author
      Avijit,

      The best way to handle it is this: run an HTTP tracing tool in the browser, access the workitems from portal and see what URL is being called. That way you’ll get the pattern and ‘ll be able to form the URLs.

      Thanks,
      Manish

      (0) 

Leave a Reply