Hi Vishal,
I agree with Rick.We have very useful standard FMs to implement ur requirement.
Step1:To get the the parent workitem ID u need to fetch from either SWWWIHEAD(provide the workfloe template number to WI_RH_TASK filed,if u need can provide the creation date range to WI_CD field,get workitem ID from WI_ID field ) or u can fetch from table SWW_WI2OBJ( provide CATID = 'BO',TYPEID = 'BO name' ,INSTID = 'key file value of BO' ,WI_RH_TASK = 'Workflow template number WS*').
Or u can use the FM 'SAP_WAPI_WORKITEMS_TO_OBJECT' also.
Step2:To get all the child related workitem to this parent worktiem use FM 'SWI_GET_RELATED_WORKITEMS' by providing the parent workitem ID get all the child workitem details in the table parameter 'related_wis'.
Step3:If u know the 'Dialog task number ' in the workflow for which u want agent then read this itab with that task number and get the exact workitem ID generated for this.
If u dont know the task number or dont want to read with hard coded task number then read the itab by workitem type field WI_TYPE = 'W'(means dialog workitem).
If u need to know the status then use the field ''WI_STAT.
Step4: Now u have the workitem ID of the dialog task for which u want the agent.Use the FM SAP_WAPI_WORKITEM_RECIPIENTS or SAP_WAPI_GET_WI_AGENTS to get the agent details.
If u find any difficulty to implement this let me know,we have implemented this in our project and can provide u the code also if u need.
Thanks
Hafizul