public void init()
{
AFZ_PurchaseRequisitionSummaryReportTableTmp prTmp;
PurchReqTable purchReqTable;
PurchReqLine purchReqLine;
WorkflowTrackingStatusTable workflowTrackingStatus,
workflowTrackingStatusTable, workflowTrackingStatusTmp;
WorkflowTrackingTable workflowTrackingTable, workflowTrackingTableTmp;
WorkflowTrackingCommentTable workflowTrackingCommentTable;
UserInfo userInfo;
RecId _recId, workflowElementTableRecId;
Name _name, actionTakenByName;
HcmWorkerRecId workerRecId;
HcmWorker hcmWorker;
int i = 1;
super();
delete_from prTmp;
while select purchReqTable
{
prTmp.PurchReqId = purchReqTable.PurchReqId;
prTmp.PurchReqName = purchReqTable.PurchReqName;
prTmp.PRPreparerName = purchReqTable.originatorName();
prTmp.RequisitionStatus = purchReqTable.RequisitionStatus;
prTmp.PRPreparedDate = purchReqTable.CreatedDateTime;
prTmp.SubmittedDateTime = purchReqTable.SubmittedDateTime;
prTmp.AFZPRBudgetId = purchReqTable.AFZPRBudgetId;
prTmp.AFZProjId = purchReqTable.AFZProjId;
prTmp.AFZPRCategoryId = purchReqTable.AFZPRCategoryId;
PurchReqBusJustification PurchReqBusJustification;
select * from PurchReqBusJustification where PurchReqBusJustification.RefRecId
== purchReqTable.RecId
&& PurchReqBusJustification.RefTableId == purchReqTable.TableId;
prTmp.Details = PurchReqBusJustification.BusinessJustification;
//prTmp.BusinessJustification = purchReqTable.BusinessJustification;
prTmp.AFZPRNotes = purchReqTable.AFZPRNotes;
prTmp.AFZPurchPoolId = purchReqTable.AFZPurchPoolId;
prTmp.POApproverLevel1 = '';
prTmp.POApproverReceiveDateL1 = utcDateTimeNull();
prTmp.POApproverApproveDateL1 = utcDateTimeNull();
prTmp.POApproverLevel2 = '';
prTmp.POApproverReceiveDateL2 = utcDateTimeNull();
prTmp.POApproverApproveDateL2 = utcDateTimeNull();
prTmp.POApproverLevel3 = '';
prTmp.POApproverReceiveDateL3 = utcDateTimeNull();
prTmp.POApproverApproveDateL3 = utcDateTimeNull();
prTmp.POApproverLevel4 = '';
prTmp.POApproverReceiveDateL4 = utcDateTimeNull();
prTmp.POApproverApproveDateL4 = utcDateTimeNull();
prTmp.POApproverLevel5 = '';
prTmp.POApproverReceiveDateL5 = utcDateTimeNull();
prTmp.POApproverApproveDateL5 = utcDateTimeNull();
prTmp.POApproverLevel6 = '';
prTmp.POApproverReceiveDateL6 = utcDateTimeNull();
prTmp.POApproverApproveDateL6 = utcDateTimeNull();
_recId = purchReqTable.RecId;
while select workflowTrackingStatus order by CreatedDateTime asc
where workflowTrackingStatus.ContextTableId == tableNum(PurchReqTable)
&& workflowTrackingStatus.ContextRecId == _recId
&& workflowTrackingStatus.TrackingStatus ==
WorkflowTrackingStatus::Completed
join workflowTrackingTable order by CreatedDateTime asc
where workflowTrackingTable.WorkflowTrackingStatusTable ==
workflowTrackingStatus.RecId
&& workflowtrackingtable.TrackingContext ==
workflowtrackingcontext::WorkItem
&& workflowTrackingTable.TrackingType == WorkflowTrackingType::Approval
join userInfo
where userInfo.id == workflowTrackingTable.User
{
select workflowTrackingStatusTmp order by RecId desc
where workflowTrackingStatusTmp.ContextTableId == tableNum(PurchReqTable)
&& workflowTrackingStatusTmp.ContextRecId == _recId
&& workflowTrackingStatusTmp.TrackingStatus == WorkflowTrackingStatus::Completed;
if(workflowTrackingStatusTmp.RecId == workflowTrackingStatus.RecId)
{
prTmp.FinalApprovedDate = workflowTrackingTable.CreatedDateTime;
if(prTmp.POApproverLevel1 == '' && workflowTrackingTable.User
&& workflowTrackingTable.TrackingType ==
WorkflowTrackingType::Approval)
{
if(userInfo.name)
prTmp.POApproverLevel1 = userInfo.name;
else
prTmp.POApproverLevel1 = workflowTrackingTable.User;
workflowTrackingTableTmp.clear();
select RecId, WorkflowTrackingStatusTable, CreatedDateTime from
workflowTrackingTableTmp order by RecId,CreatedDateTime desc
where workflowTrackingTableTmp.WorkflowTrackingStatusTable ==
workflowTrackingStatus.RecId
&& workflowTrackingTableTmp.CreatedDateTime <
workflowTrackingTable.CreatedDateTime
&& workflowTrackingTableTmp.TrackingType ==
WorkflowTrackingType::Creation
|| workflowTrackingTableTmp.TrackingType == WorkflowTrackingType::Delegation
&& workflowTrackingTableTmp.TrackingContext ==
workflowtrackingcontext::WorkItem
&& workflowTrackingTableTmp.WorkflowElementTable ==
workflowTrackingTable.WorkflowElementTable;
prTmp.POApproverReceiveDateL1 =
workflowTrackingTableTmp.CreatedDateTime;
prTmp.POApproverApproveDateL1 = workflowTrackingTable.CreatedDateTime;
}
else if(prTmp.POApproverLevel2 == '' && workflowTrackingTable.User
&& workflowTrackingTable.TrackingType == WorkflowTrackingType::Approval)
{
if(userInfo.name)
prTmp.POApproverLevel2 = userInfo.name;
else
prTmp.POApproverLevel2 = workflowTrackingTable.User;
workflowTrackingTableTmp.clear();
select RecId, WorkflowTrackingStatusTable, CreatedDateTime from
workflowTrackingTableTmp order by RecId, CreatedDateTime desc
where workflowTrackingTableTmp.WorkflowTrackingStatusTable ==
workflowTrackingStatus.RecId
&& workflowTrackingTableTmp.CreatedDateTime <
workflowTrackingTable.CreatedDateTime
&& workflowTrackingTableTmp.TrackingType ==
WorkflowTrackingType::Creation
|| workflowTrackingTableTmp.TrackingType == WorkflowTrackingType::Delegation
&& workflowTrackingTableTmp.TrackingContext ==
workflowtrackingcontext::WorkItem
&& workflowTrackingTableTmp.WorkflowElementTable == workflowTrackingTable.WorkflowElementTable;
prTmp.POApproverReceiveDateL2 = workflowTrackingTableTmp.CreatedDateTime;
prTmp.POApproverApproveDateL2 = workflowTrackingTable.CreatedDateTime;
}
else if(prTmp.POApproverLevel3 == '' && workflowTrackingTable.User
&& workflowTrackingTable.TrackingType ==
WorkflowTrackingType::Approval)
{
if(userInfo.name)
prTmp.POApproverLevel3 = userInfo.name;
else
prTmp.POApproverLevel3 = workflowTrackingTable.User;
workflowTrackingTableTmp.clear();
select RecId, WorkflowTrackingStatusTable, CreatedDateTime from
workflowTrackingTableTmp order by RecId, CreatedDateTime desc
where workflowTrackingTableTmp.WorkflowTrackingStatusTable ==
workflowTrackingStatus.RecId
&& workflowTrackingTableTmp.CreatedDateTime <
workflowTrackingTable.CreatedDateTime
&& workflowTrackingTableTmp.TrackingType ==
WorkflowTrackingType::Creation
|| workflowTrackingTableTmp.TrackingType == WorkflowTrackingType::Delegation
&& workflowTrackingTableTmp.TrackingContext ==
workflowtrackingcontext::WorkItem
&& workflowTrackingTableTmp.WorkflowElementTable ==
workflowTrackingTable.WorkflowElementTable;
prTmp.POApproverReceiveDateL3 = workflowTrackingTableTmp.CreatedDateTime;
prTmp.POApproverApproveDateL3 = workflowTrackingTable.CreatedDateTime;
}
else if(prTmp.POApproverLevel4 == '' && workflowTrackingTable.User
&& workflowTrackingTable.TrackingType ==
WorkflowTrackingType::Approval)
{
if(userInfo.name)
prTmp.POApproverLevel4 = userInfo.name;
else
prTmp.POApproverLevel4 = workflowTrackingTable.User;
workflowTrackingTableTmp.clear();
select RecId, WorkflowTrackingStatusTable, CreatedDateTime from
workflowTrackingTableTmp order by RecId, CreatedDateTime desc
where workflowTrackingTableTmp.WorkflowTrackingStatusTable ==
workflowTrackingStatus.RecId
&& workflowTrackingTableTmp.CreatedDateTime <
workflowTrackingTable.CreatedDateTime
&& workflowTrackingTableTmp.TrackingType ==
WorkflowTrackingType::Creation
|| workflowTrackingTableTmp.TrackingType == WorkflowTrackingType::Delegation
&& workflowTrackingTableTmp.TrackingContext == workflowtrackingcontext::WorkItem
&& workflowTrackingTableTmp.WorkflowElementTable ==
workflowTrackingTable.WorkflowElementTable;
prTmp.POApproverReceiveDateL4 = workflowTrackingTableTmp.CreatedDateTime;
prTmp.POApproverApproveDateL4 = workflowTrackingTable.CreatedDateTime;
}
else if(prTmp.POApproverLevel5 == '' && workflowTrackingTable.User
&& workflowTrackingTable.TrackingType ==
WorkflowTrackingType::Approval)
{
if(userInfo.name)
prTmp.POApproverLevel5 = userInfo.name;
else
prTmp.POApproverLevel5 = workflowTrackingTable.User;
workflowTrackingTableTmp.clear();
select RecId, WorkflowTrackingStatusTable, CreatedDateTime from
workflowTrackingTableTmp order by RecId, CreatedDateTime desc
where workflowTrackingTableTmp.WorkflowTrackingStatusTable == workflowTrackingStatus.RecId
&& workflowTrackingTableTmp.CreatedDateTime <
workflowTrackingTable.CreatedDateTime
&& workflowTrackingTableTmp.TrackingType ==
WorkflowTrackingType::Creation
|| workflowTrackingTableTmp.TrackingType == WorkflowTrackingType::Delegation
&& workflowTrackingTableTmp.TrackingContext ==
workflowtrackingcontext::WorkItem
&& workflowTrackingTableTmp.WorkflowElementTable ==
workflowTrackingTable.WorkflowElementTable;
prTmp.POApproverReceiveDateL5 = workflowTrackingTableTmp.CreatedDateTime;
prTmp.POApproverApproveDateL5 = workflowTrackingTable.CreatedDateTime;
}
else if(prTmp.POApproverLevel6 == '' && workflowTrackingTable.User
&& workflowTrackingTable.TrackingType ==
WorkflowTrackingType::Approval)
{
if(userInfo.name)
prTmp.POApproverLevel6 = userInfo.name;
else
prTmp.POApproverLevel6 = workflowTrackingTable.User;
workflowTrackingTableTmp.clear();
select RecId, WorkflowTrackingStatusTable, CreatedDateTime from
workflowTrackingTableTmp order by RecId, CreatedDateTime desc
where workflowTrackingTableTmp.WorkflowTrackingStatusTable ==
workflowTrackingStatus.RecId
&& workflowTrackingTableTmp.CreatedDateTime <
workflowTrackingTable.CreatedDateTime
&& workflowTrackingTableTmp.TrackingType ==
WorkflowTrackingType::Creation
|| workflowTrackingTableTmp.TrackingType == WorkflowTrackingType::Delegation
&& workflowTrackingTableTmp.TrackingContext ==
workflowtrackingcontext::WorkItem
&& workflowTrackingTableTmp.WorkflowElementTable ==
workflowTrackingTable.WorkflowElementTable;
prTmp.POApproverReceiveDateL6 = workflowTrackingTableTmp.CreatedDateTime;
prTmp.POApproverApproveDateL6 = workflowTrackingTable.CreatedDateTime;
}
}
}
prTmp.insert();
}
}
}