{"id":1498,"date":"2016-07-01T20:08:09","date_gmt":"2016-07-01T19:08:09","guid":{"rendered":"http:\/\/oprsteny.cz\/?p=1498"},"modified":"2016-07-01T20:08:09","modified_gmt":"2016-07-01T19:08:09","slug":"abap-get-workflow-tasks-assigned-to-a-user","status":"publish","type":"post","link":"https:\/\/oprsteny.cz\/?p=1498","title":{"rendered":"ABAP &#8211; Get Workflow tasks assigned to a user"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"358\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=358\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" data-orig-size=\"44,50\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Picasa&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1365690880&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"SAP\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" class=\"alignleft size-full wp-image-358\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" alt=\"SAP\" width=\"44\" height=\"50\" \/>Sometimes you need to find out whom a particulat workflow task belongs to or other way, which workflow tasks belong to a specific user.<!--more--><\/p>\n<h1>Tasks of a specific user<\/h1>\n<p>To find out pending tasks of a specific user you can simply read table SWWUSERWI passing USER_ID as a parameter.<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_03.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1501\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=1501\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_03.png\" data-orig-size=\"586,385\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Table SWWUSERWI\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_03.png\" class=\"size-medium wp-image-1501 alignnone\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_03-300x197.png\" alt=\"Table SWWUSERWI\" width=\"300\" height=\"197\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_03-300x197.png 300w, https:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_03-457x300.png 457w, https:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_03.png 586w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Another method is calling a method RH_LOCAL_INBOX_GET with parameters USER_ID, USER_LANGU and READ_OTYPE (this is to determine an Org.structure type &#8211; for user it will be &#8216;US&#8217;)<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_01.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1499\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=1499\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_01.png\" data-orig-size=\"334,279\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Function module RH_LOCAL_INBOX_GET\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_01.png\" class=\"size-medium wp-image-1499 alignnone\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_01-300x251.png\" alt=\"Function module RH_LOCAL_INBOX_GET \" width=\"300\" height=\"251\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_01-300x251.png 300w, https:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_01.png 334w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_02.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1500\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=1500\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_02.png\" data-orig-size=\"1082,292\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Result of function module RH_LOCAL_INBOX_GET\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_02-1024x276.png\" class=\"size-medium wp-image-1500 alignnone\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_02-300x81.png\" alt=\"Result of function module RH_LOCAL_INBOX_GET\" width=\"300\" height=\"81\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_02-300x81.png 300w, https:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_02-768x207.png 768w, https:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_02-1024x276.png 1024w, https:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_02-500x135.png 500w, https:\/\/oprsteny.cz\/wp-content\/uploads\/RH_LOCAL_INBOX_GET_02.png 1082w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<h1>Who is responsible for a specific task<\/h1>\n<p>For example let&#8217;s assume we have a workflow with name <strong>WS90100079 <\/strong>and there is a &#8220;Decision task&#8221; in this workflow with name\u00a0<!--StartFragment --><strong>TS90100211<\/strong>.<\/p>\n<p>A new instance of this workflow has been started with key (instance ID) &#8216;ABCD123456&#8217;.<\/p>\n<p>Now we need to find out in our program the agent responsible for processing this task&#8230;how to do it?<\/p>\n<ol>\n<li>We need to get the first workitem ID of the workflow instance:\n<pre lang=\"abap\">SELECT SINGLE\u00a0top_wi_id INTO lv_top_wiid\r\n  FROM sww_wi2obj\r\n  WHERE instid = 'ABCD123456'\r\n    AND wi_rh_task = 'WS90100079'.<\/pre>\n<\/li>\n<li>We need to get the workitem ID of the Decision task <strong>TS90100211<\/strong> in our workflow instance (we get it by\u00a0linking via lv_top_wiid from previous step)\n<pre lang=\"abap\">SELECT SINGLE\u00a0wi_id INTO lv_wiid\r\n  FROM swwwihead\r\n  WHERE wi_chckwi = lv_top_wiid.<\/pre>\n<\/li>\n<li>We will get the user(s) responsible for processing the workitem we got in step 2 &#8230; there might be more users responsible and all such users will be listed.\n<pre lang=\"abap\">SELECT user_idINTO TABLE lt_userid\r\n  FROM swwuserwi\r\n  WHERE wi_id = lv_wiid.<\/pre>\n<\/li>\n<\/ol>\n<p>Or we can do it in one joined SELECT command:<\/p>\n<pre lang=\"abap\">SELECT u~user_id INTO lt_userid              \"#EC CI_NOFIRST\r\n  FROM sww_wi2obj AS o\r\n    JOIN swwwihead AS h ON o~top_wi_id = h~wi_chckwi\r\n    JOIN swwuserwi AS u ON u~wi_id = h~wi_id\r\n  WHERE o~wi_rh_task = 'WS90100079'\r\n    AND o~instid     = me-&gt;mv_objkey\r\n    AND h~wi_rh_task = 'TS90100211'.<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you need to find out whom a particulat workflow task belongs to or other way, which workflow tasks belong to a specific user.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[16,9,467],"tags":[446,468,471,470,469],"class_list":["post-1498","post","type-post","status-publish","format-standard","hentry","category-abap","category-development","category-wokflow","tag-abap","tag-rh_local_inbox_get","tag-swwuserwi","tag-swwwihead","tag-sww_wi2obj"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3nYbe-oa","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1498"}],"version-history":[{"count":3,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1498\/revisions"}],"predecessor-version":[{"id":1504,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1498\/revisions\/1504"}],"wp:attachment":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}