This statement recursively browses down a past workflow
execution (marked runid number) giving you a list of all sub-tasks (and
sub-sub-sub... tasks). You can filter this list by the AH_Status like you did
in your statement. This won't work with activated objects (by
ACTIVATE_UC_OBJECT) - for this the query would need to slightly change.
== Using workflow runID ==
with taskIDs(TASKID) as (
select AJPP_TASKIDNR
from UC4.AJPP
where AJPP_AH_Idnr = 97805249
and AJPP_TASKIDNR > 0
UNION ALL
select AJPP_TASKIDNR
from UC4.AJPP, taskIDs
where AJPP_AH_Idnr = taskIDs.TASKID
and AJPP_TASKIDNR > 0
)
== Using latest statistic entry based on workflow name and client ==
select *
from taskids
join UC4.AH on AH_IDNR = taskids.taskid
with taskIDs(TASKID) as (
select AJPP_TASKIDNR
from UC4.AJPP
where AJPP_AH_Idnr = (select AH_Idnr from UC4.AH where AH_Timestamp1 =
(select max(AH_Timestamp1) from UC4.AH where AH_Name = 'WORKFLOWNAME' and
AH_Client = 1000) and AH_Name = 'WORKFLOWNAME' and AH_Client = 1000)
and AJPP_TASKIDNR > 0
UNION ALL
select AJPP_TASKIDNR
from UC4.AJPP, taskIDs
where AJPP_AH_Idnr = taskIDs.TASKID
and AJPP_TASKIDNR > 0
)
select *
from taskids
join UC4.AH on AH_IDNR = taskids.taskid