Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
piyush_kumar6
Active Contributor

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

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

and we get below 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 :

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_______

28 Comments
Labels in this area