Skip to Content

This Blog describes the Mass Processing of UWL tasks where Task is not of decision type Task

Like Standard Leave Request Tasks. In this blog I have described how to add new custom columns

in UWL also.

Required Skill: Idea about UWL Configuration file (xml file), little knowledge of Workflow 

Container if need to add some new custom columns in UWL and  UWL administration.

Note: I assume that UWL is working fine and all the required tasks are coming to UWL

             from SAP Inbox (ECC).

         In this blog I have described how to add new custom columns in UWL, I have added

                1. Leave Start Date

                2. Leave End Date

                3. AM/PM Indicator

                4. Leave Type

And I assume that these fields have been added in workflow’s Root container, if new

Columns are not required then please skip this step and go with the default attributes.

Solution:

This solution is mainly dived in three steps:

  1. We need to create the new custom uwl configuration file.
  2. Upload the created xml file in portal with high priority with the required system alias
  3. Clear the UWL Cache 

As here the tasks will be not of decision Type Task so for processing the tasks we need

to call One Function Module (FM), which will do the actual processing in backend.

Here in blew code I have used FM called “ZHRTM_LEAVE_APPR”,

The FM code is mentioned at the end of this blog.

The XMl file mainly contains 2 parts

  1. Item Type declaration and
  2. view declaration

XML Configuration File Coding


  1. Item Type declaration

<ItemType name="uwl.task.webflow.TS90100003" connector="WebFlowConnector"
defaultView="Leave_Approval" defaultAction="launchWebDynPro" executionMode="default">
    <ItemTypeCriteria externalType="TS90100003" connector="WebFlowConnector"/>
         <CustomAttributes>
               <CustomAttributeSource id="WEBFLOW_CONTAINER"
                   objectIdHolder="externalId" objectType="WebflowContainer" cacheValidity="final">
<Attribute name="BEGDA" type="date" displayName="Leave Start Date" />
<Attribute name="ENDDA" type="date" displayName="Leave End Date" />
<Attribute name="LEAVE_DESC" type="string" displayName="Leave Type" />
<Attribute name="subject" type="string" displayName="Subject" />
<Attribute name="createdDate" type="date" displayName="Submission Date"/>
<Attribute name="RequestId" type="string" displayName="RequestId"/>
<Attribute name="ampm_ind" type="string" displayName="AM/PM" />
<Attribute name="pernr" type="string" displayName="Employee No"/>
<Attribute name="wi_id" type="string" displayName="Work Item ID"/>
          </CustomAttributeSource>
  </CustomAttributes>
<Actions>
<Action name="Approve" groupAction="yes" handler="FunctionModuleActionHandler">
   <Properties>
<Property name="FunctionModule" value="ZHRTM_LEAVE_APPR"/>
<Property name="IM_REQUEST_ID" value="${item.RequestId}"/>
<Property name="IM_COMMAND" value="EXECUTE_APPROVE"/>
<Property name="IM_PERNR" value="${item.pernr}"/>
<Property name="WI_ID" value="${item.wi_id}"/>
   </Properties>
   <Descriptions default="Approve"/>
</Action>
<Action name=" Reject" groupAction="yes" handler="FunctionModuleActionHandler">
  <Properties>
<Property name="FunctionModule" value="ZHRTM_LEAVE_APPR"/>
<Property name="IM_REQUEST_ID" value="${item.RequestId}"/>
<Property name="IM_COMMAND" value="EXECUTE_REJECT"/>
<Property name="IM_PERNR" value="${item.pernr}"/>
<Property name="WI_ID" value="${item.wi_id}"/>
  </Properties>
<Descriptions default="Reject"/>
</Action>
<Action name="launchWebDynPro" groupAction="yes" handler="SAPWebDynproLauncher"
        returnToDetailViewAllowed="yes" launchInNewWindow="yes"
       launchNewWindowFeatures="resizable=yes,scrollbars=yes,status=yes,toolbar=no,
       menubar=no,location=no,directories=no">
    <Properties>
<Property name="WebDynproApplication" value="LeaveRequestApprover"/>
<Property name="WebDynproDeployableObject" value="sap.com/ess~lea"/>
<Property name="newWindowFeatures" value="resizable=yes, scrollbars=yes,    
            status=yes,toolbar=no,menubar=no,location=no,directories=no"/>
<Property name="DynamicParameter" value="wi_id=${item.externalId}"/>
<Property name="openInNewWindow" value="yes"/>
<Property name="display_order_priority" value="3"/>
   </Properties>
  <Descriptions default=""/>
</Action>
<Action name="submitUserDecisions" groupAction="yes" handler="UIActionHandler"
                            referenceBundle="submit_msg"  returnToDetailViewAllowed="no" 
                             launchInNewWindow="SHOW_HEADERLESS_PORTAL">
<ConfirmDescriptions referenceBundle="submit_prompt"/>
</Action>
</Actions>
</ItemType>


  2. view declaration


<View name="Leave_Approval" selectionMode="SINGLESELECT" width="98%"
supportedItemTypes="uwl.task.webflow.TS90100003,
uwl.task.webflow.TS90100017, uwl.task.webflow.TS90100023"
columnOrder="subject,LEAVE_DESC, BEGDA,
ENDDA,ampm_ind,createdDate,Approve,Reject"
sortby="priority:descend, dueDate:ascend, createdDate:descend"
tableDesign="STANDARD" visibleRowCount="10" headerVisible="yes"
tableNavigationFooterVisible="yes" tableNavigationType="CUSTOMNAV"
actionRef=""
actionPosition="bottom">
<Descriptions default="Leave Management">
    <ShortDescriptions>
          <Description Language="en" Description="Leave Management"/>
    </ShortDescriptions>
</Descriptions>
<DisplayAttributes>
<DisplayAttribute name="BEGDA" type ="date" width="5" sortable="yes" format="short"  
        hAlign="LEFT">
<Descriptions default="Leave Start">
                <ShortDescriptions>
<Description Language="en" Description="Leave Start"/>
</ShortDescriptions>
</Descriptions>
</DisplayAttribute>
<DisplayAttribute name="ENDDA" type ="date" width="5" sortable="yes" format="short"
                 hAlign="LEFT">
<Descriptions default="Leave End">
<ShortDescriptions>
<Description Language="en" Description="Leave End"/>
</ShortDescriptions>
</Descriptions>
</DisplayAttribute>
<DisplayAttribute name="LEAVE_DESC" type ="string" width="" sortable="yes"
                  format="medium" hAlign="LEFT">
<Descriptions default="Leave Type">
<ShortDescriptions>
<Description Language="en" Description="Leave Type"/>
</ShortDescriptions>
</Descriptions>
</DisplayAttribute>
<DisplayAttribute name="subject" type ="link" actionRef="launchWebDynPro" width=""
                sortable="yes" format="medium" hAlign="LEFT">
<Descriptions default="Subject">
<ShortDescriptions>
<Description Language="en" Description="Subject"/>
</ShortDescriptions>
</Descriptions>
</DisplayAttribute>
<DisplayAttribute name="ampm_ind" type ="string" width="4" sortable="yes"
                   format="medium" hAlign="LEFT">
<Descriptions default="AM/PM">
<ShortDescriptions>
<Description Language="en" Description="AM/PM"/>
</ShortDescriptions>
</Descriptions>
</DisplayAttribute>
<DisplayAttribute name="Approve" type="checkbox" width="4" actionRef="Approve"
 format="default" vAlign="TOP" hAlign="CENTER">
<Descriptions default="Approve">
<ShortDescriptions>
<Description Language="en" Description="Approve"/>
</ShortDescriptions>
</Descriptions>
</DisplayAttribute>
<DisplayAttribute name="Reject" type="checkbox" width="4" actionRef="Reject" vAlign="TOP"
             hAlign="CENTER">
                <Descriptions default="Reject">
<ShortDescriptions>
<Description Language="en" Description="Reject"/>
</ShortDescriptions>
</Descriptions>
</DisplayAttribute>
</DisplayAttributes>
<Actions>
<Action name="submitUserDecisions" groupAction="yes" handler="UIActionHandler"
           referenceBundle="submit_msg" returnToDetailViewAllowed="no"
           launchInNewWindow="SHOW_HEADERLESS_PORTAL">
    <ConfirmDescriptions referenceBundle="submit_prompt"/>
</Action>
<Action reference="refresh"/>
<Action reference="defaultGlobalWizard"/>
<Action reference="addToNavigation"/>
<Action reference="removeFromNavigation"/>
<Action reference="launchSubstitutionManager"/>
</Actions>
</View>

Now we have done with the required changes in configuration file ,Now we need to upload this 

Xml file with high priority with required system. After uploading the file it will be better

if we clear the UWL Cache.

The Default UWL

Default UWL

After Upload the new configuration when we select the Leave Management sub-view

and we get below UWL

the Leave Management sub-view UWL

Now I am going to explain the Functional Module used  ZHRTM_LEAVE_APPR

As we know if we try to do auto Approval of Leave Request tasks or we want to do manual approval in some

case then we call Standard FM ‘PT_ARQ_REQUEST_EXECUTE’, so I have used the same FM in this Z FM. As we

are going to call the FM from UWL so I have created the Custom or Z FM .


FM Code :

FM-2.JPG

FM-3.JPG

FM-4.JPG

Code

FUNCTION ZHRTM_LEAVE_APPR.

*”———————————————————————-

*”*”Local Interface:

*”  IMPORTING

*”     VALUE(IM_REQUEST_ID) TYPE  TIM_REQ_ID OPTIONAL

*”     VALUE(IM_COMMAND) TYPE  PTREQ_COMMAND

*”     VALUE(IM_PERNR) TYPE  P_PERNR

*”     VALUE(WI_ID) TYPE  SWW_WIID

*”  EXPORTING

*”     VALUE(RET_CODE) TYPE  SY-SUBRC

*”  TABLES

*”      EX_MESSAGES TYPE  PTARQ_UIA_MESSAGES_TAB

*”———————————————————————-

** Mass Approval from UWL ( Approve Reject Check boxes )

data : lt_messages type PTARQ_UIA_MESSAGES_TAB,

       ls_messages type bapiret2,

       lt_commands type PTARQ_UIA_COMMAND_TAB,

       lv_haserror type PTREQ_HAS_ERROR_FLAG,

       lv_request  type PTARQ_UIA_REQUEST,

       lv_command type PTREQ_COMMAND.

data : lt_cont type table of SWR_CONT,

       ls_cont type SWR_CONT.

data : ls_wf_appr type ZTHR_WF_APPVR.

data : lv_wi_id  type SWW_WIID.

** Prepare to Approve Leave Request

lv_command = ‘PREPARE_APPROVE’.

CALL FUNCTION ‘PT_ARQ_REQUEST_PREPARE’

  EXPORTING

    IM_REQUEST_ID             = im_request_id

    IM_COMMAND                = lv_command

    IM_PERNR                  = im_pernr

    IM_MODUS                  = ‘R’

  IMPORTING

    EX_REQUEST                = lv_request

    EX_HAS_ERRORS             = lv_haserror

  TABLES

    EX_MESSAGES               = lt_messages

    EX_COMMANDS               = lt_commands

          .

** Check Leave Approval

clear lv_command.

lv_command = ‘CHECK_APPROVE’.

CALL FUNCTION ‘PT_ARQ_REQUEST_CHECK’

  EXPORTING

    IM_REQUEST           = lv_request

    IM_COMMAND           = lv_command

    IM_PERNR             = im_pernr

    IM_MODUS             = ‘R’

  IMPORTING

    EX_HAS_ERRORS        = lv_haserror

  TABLES

    EX_MESSAGES          = ex_messages ” lt_messages

    EX_COMMANDS          = lt_commands

          .

** If no error execute Leave Approval

if lv_haserror is initial.

CALL FUNCTION ‘PT_ARQ_REQUEST_EXECUTE’

  EXPORTING

    IM_REQUEST_ID        = im_request_id

    IM_COMMAND           = im_command

    IM_PERNR             = im_pernr

    IM_MODUS             = ‘R’

*   IM_DEBUG             =

* IMPORTING

*   EX_REQUEST           =

*   EX_HAS_ERRORS        =

*   EX_SHOW_CHANGE       =

  TABLES

    EX_MESSAGES          = lt_messages

    EX_COMMANDS          = lt_commands

else.

** If error exists .. update the workflow container with error messages

ret_code = sy-subrc.

loop at ex_messages into ls_messages.

ls_cont-element = ‘remarks’.

ls_cont-value   = ls_messages-message.

append ls_cont to lt_cont.

endloop.

* Get the workitem id of the current workitem

select single wi_id from SWW_WI2OBJ into lv_wi_id

       where

         top_wi_id = wi_id  and

         wi_rh_task in (‘TS90100003′ ,’TS90100006′ ,’TS90100009’ ).

** Update the container

CALL FUNCTION ‘SAP_WAPI_WRITE_CONTAINER’

  EXPORTING

    WORKITEM_ID             = lv_wi_id

    LANGUAGE                = SY-LANGU

*   ACTUAL_AGENT            = SY-UNAME

    DO_COMMIT               = ‘X’

*   IFS_XML_CONTAINER       =

* IMPORTING

*   RETURN_CODE             =

  TABLES

   SIMPLE_CONTAINER         = lt_cont

*   MESSAGE_LINES           =

*   MESSAGE_STRUCT          =

          .

endif.

ENDFUNCTION.

______Piyush_______

To report this post you need to login first.

28 Comments

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

  1. barin desai
    hi piyush

    this is interesting. in today’s sap world this is something rare where we use existing design and provide a comfertable approval process to customer.

    thank you. have you implemented this for any customer?

    – Barin

    (0) 
    1. Piyush kumar Post author
      Hi Barin,
      Thanks for the comment.
      Ya i have implemented this for 2 customers and its working very fine. After observing the provided solution for long time , i have written this blog.

      Regards,
      Piyush

      (0) 
    2. Piyush kumar Post author
      Hi Barin,
      Thanks for the comment.
      Ya i have implemented this for 2 customers and its working very fine. After observing the provided solution for long time , i have written this blog.

      Regards,
      Piyush

      (0) 
  2. Ankur Agarwal
    Sir, Nice Blog, everything works like breeze, just that these values are not passed to the custom FM.

    while debugging in R3, values of pernr and wi_id are passed as zeros not the correct values. because of this FM is not approving the leaves.

    (0) 
    1. Piyush kumar Post author
      Hi Ankur,
      Please check that pernr and wi_id is added in workflow’s root container.

      and define the below code in item type.

      Regards,
      Piyush

      (0) 
      1. Ankur Agarwal
        Dear SIr,
        I have already defined those attributes. while hard coded values are passed using these lines

        OR

        the exact values are not being passed. Please help us to know how to check if they are added in workflow root container. I hope that you mean from APAB side. Detailed steps requested.

        (0) 
        1. Ankur Agarwal
          Dear Sir, we have done changes as suggested in the Tx code PFTC and adding these attributes to workflow template 12300111. our Ts is 12300097 standard one.

          These lines passed the WI_ID to abap:

          Still there are some issues:
          1. after removing wi_id from the container the code is working fine, though was not working fine earlier. Strange!!!!
          2. pernr is not being passed still.
          3. initially in UWL we are not getting values for Leave type, Leave start, leave end, AM/PM. thought we have added them to the container.
          we are adding all these attributes to
          workflow template: 12300111
          Name: General workflow for documents
          Package: PAOC_TIM_Request

          (0) 
          1. Ankur Agarwal
            Dear Sir,
            We are finally able to get all the values in the UWL. Great blog and thank you for all your help.
            Just 1 small thing remains : AM/PM.
            looks like related to showing time, are you showing leave apply time here? Please give more info on this field?

            thanks again
            Regards,
            Ankur

            (0) 
            1. Piyush kumar Post author
              Hi Ankur,
              Where i implemented this for that client was having policies where employee can apply the half day leave from ESS. So we separated the day in AM and PM
              So that we can track that Employee is applying the leave in which half. We added the custom filed am/pm in Leave application.
              After this you know how to get data as you are now master in this.

              Regards,
              Piyush

              (0) 
        2. Ankur Agarwal
          Dear Sir,
          we have been able to send the above values to R3, by adding attributes to the task container. works well now πŸ™‚

          just 1 little thing remaining. Req. your kind inputs in this:

          Please let me know how to get the Leave attributes mentioned below from the Workflow:

          1.       Leave Type

          2.       Leave Start Date

          3.       Leave End Date

          4.       AM/PM

          Currently I am passing the Leave submitted date as Leave Start Date and Leave End Date, which I am already getting from the Workflow Container. Instead I need the values of above said attributes so that I can show the correct values in the UWL.

          (0) 
          1. Piyush kumar Post author
            Hi Ankur,
            You have to follow same process as above,first add the Leave Type,Leave Start Date,Leave End Date and other new attributes in the Workflow’s root container and then do the declaration in ItemType.

            Regards,
            Piyush

            (0) 
  3. Shankar Agarwal
    Hi Piyush

    First congrats on this useful blog.
    i am having trouble in getting the leave data like type and dates getting populated in view, can you point out any specific reason.Also the blog mentions CUSTOMNAV in table navigation type,do we need to define it?

    (0) 
    1. Piyush kumar Post author
      Hi shankar,

      Thanks for your comment.
      To get the custom column in uwl we need to add the required custom field in workflow’s root container first then define the attribute in itemtype, as mentioned below.



      Regards,
      Piyush

      (0) 
  4. Andre Sousa

    Hi Piyush,

    This blog is very interesting. I am trying to implement something simillar but I facing two issues:

    – leave information is not populated

    – when I submit an approval the following error appears:

    Wed Apr 18 17:27:04 CEST 2012 (Connector) :com.sap.mw.jco.JCO$Exception:Access via ‘NULL’ object reference not possible.

    It seams that connector not connecting to the backend. Do you have any hints?

    Anyway if I use default view I can select workitem, it opens Leave Approval application and I can approve this request.

    Thanks in advance.

    AS

    (0) 
    1. Piyush kumar Post author

      Hi AS,

      Can you give the details of <Action> which you have written for Approval ?

      Kindly have a close look of above XML code ,It may help you. I have corrected the formatting ,which got messed up while migrating from old SCN to new SCN.

      Regards,

      Piyush

      (0) 
        1. Piyush kumar Post author

          Hi Andre,

          URL for printscreen is not working , Can you check it again ?

          Kindly check your task id TS12300097  and have you uploaded the new XML config file with high priority with the required system alias ??

          Regards,

          Piyush

          (0) 
  5. Naga Devisetty

    Hi Piyush,

    Good & very useful blog Pityush!

    Is the Leave Management (Leave_Approval) created as sub-view under ‘New and In-progress Tasks’ ? What about NavigationNode .. don’t we’ve to make any entries/changes here?

    Thanks,

    MS

    (0) 
    1. Piyush kumar Post author

      Hi MS,

      Thanks for your nice comments , If you feel its helpful for you then kindly give the rating or like or both  πŸ™‚ …..

      and  Yes we created Sub-view  i am not getting .. what entries/changes you are talking πŸ™ , can u explain

      Piyush

      (0) 
      1. Naga Devisetty

        Hi Piyush,

        I’ve made everything worked .. with our custom (client’s) requirements on UWL and lastly I was in search of a sample scenario for multi-approval.. which I got from your blog.

        Now, when i’m doing Submit User Decision it throws me below error:

        Unable to perform the request. Try again and if the problem persists, inform your system administrator.

        Any idea on what could’ve went wrong? Can you explaim me what is <Action name=”SubmitUserDecisions” …></Action> block doing? How it is passed the multi-selected values to ZFM?

        Thanks, MS

        (0) 
        1. Piyush kumar Post author

          Hi MS,

          submitUserDecisions is  defined in uwl.standard xml file. download the standard file and check the action details. Below links can help

          you in this

          Link 1

          Link 2

          If possible share your xml file here , i will try to figure out the error.

          Regards,

          Piyush

          (0) 
          1. Naga Devisetty

            Hi Piyush,

            I’m aware of those links, but thanks anyways! Could you also check your gmail for the xml i’ve sent and I would appreciate your reply on it!

            Many thanks, MS

            (0) 
  6. BjΓΆrn Gerth

    Hello Piyush,

    thanks for this sophisticated blog!

    However, I wonder why in your function module you pass ‘R’= Request Mode as parameter IM_MODUS. Shouldn’t this be ‘A’ = Approval Mode?

    Best regards,

    Björn

    (0) 

Leave a Reply