I don't know why you are stuck with HcmWorkerLookup, but if you want to solve it like there, you can examine the HcmWorkerLookup query and the updateQuery method of the HcmWorkerLookup class.
Or you can simply look at the isActive method of HcmEmployment
public static boolean isActive(HcmEmploymentRecId _recId)
{
HcmEmployment hcmEmployment;
utcdatetime now = DateTimeUtil::utcNow();
return _recId && (select ValidTimeState(now) RecId from hcmEmployment
where hcmEmployment.RecId == _recId).RecId!= 0;
}
If you discard the while condition and join the worker table, it will give you active workers.
HcmEmployment hcmEmployment;
utcdatetime now = DateTimeUtil::utcNow();
HcmWorker worker;
while select ValidTimeState(now) hcmEmployment
join worker
where worker.RecId == hcmEmployment.Worker
{
//..info etc.
}
Note:I wrote the code in the editor, changes may be needed.