Hi Martin,Thanks for response.
Actually depending on the number of projects present in the hierarchy the grid will be displayed.Originally the insertion of records in temp table was done using SQL statements but since it was not working I tried to do it normally with X++ code but still it did not work.Modified the code as per your changes but still the display method is not filled with records.
I will share below the original code which performs insertion through SQL statements.Please give me your inputs on this.I tried to print the records using info method after insertion of records to temp table and it is showing the record count but in the display method of temp table datasource the record is always empty.This is the code present in init method and the insertion logic present in another class but called using static method.I have attached the init method and the insertion static methods named initializeProjHierarchyTempAllProjects and
initializeProjHierarchyTemp.
public void init()
{
super();
PMIPProjectDateTemp projectDateTemp;
PMIPProjectsSorting localProjTableSorting,localProjTableSortingLoc;
delete_from projectDateTemp;
projectDateTemp.clear();
projectDateTemp.initValue();
PMIPProjectDateTemp.linkPhysicalTableInstance(projectDateTemp);
PMIPSimpleAdjustmentsProjectsHelper::initializeProjHierarchyTempAllProjects(projectDateTemp.getPhysicalTableName(),
int2Str(refAllProjectsRecId),refAllProjectsRecId,projTableLoc.PMIPRootProjId);
while select * from localProjTableSortingLoc
where localProjTableSortingLoc.RefAllProjecsIds == refAllProjectsRecId
&& localProjTableSortingLoc.MainProjId == projTableLoc.PMIPRootProjId
{
ProjTable ProjTableRec = ProjTable::findRecId(localProjTableSortingLoc.RefProjTable);
PMIPSimpleAdjustmentsProjectsHelper::initializeProjHierarchyTemp(localProjTableSortingLoc.RefRootProjTable, projectDateTemp.getPhysicalTableName(), ProjTableRec.ProjId,refAllProjectsRecId, projTableLoc.PMIPRootProjId);
}
PMIPSimpleAdjustmentsProjectsHelper::expandAllParentsOfCurProjAndMakeItVisible(int2Str(refAllProjectsRecId), projectDateTemp.getPhysicalTableName(),refAllProjectsRecId, projTableLoc.PMIPRootProjId);
}
public static void initializeProjHierarchyTempAllProjects(
str _tempTablePhysicalName,
ProjId _curProjId, int _refAllProjectsRecId, ProjId _mainProjId)
{
Partition currentPartition = getCurrentPartitionRecId();
DataAreaId currentCompany = curExt();
RecId curProjRecId = _refAllProjectsRecId;
// Construct a query to insert all (ProjTable) records from billing schedule line into the temp table
str insertTempSQL = strFmt(@"INSERT INTO %1 (
Partition, DataAreaId, RefRecId, RefSortRecId, RefNodeId, Expand, Visible, RefTableId, RefRootProjTableSub
) SELECT
%2, '%3', %4, Sort.RecId, %4, 1, IIF(Sort.RefRootProjTable = Sort.RefProjTable, 1, 0), '%6', Sort.RefRootProjTableSub
FROM PMIPProjectsSorting AS Sort WHERE
Sort.Partition = %2 AND Sort.DataAreaId = '%3'
AND Sort.RefProjTable = %4 AND Sort.RefRootProjTable = %4
AND Sort.RefProjTable = %7
AND Sort.MainProjId = '%8'",
_tempTablePhysicalName,
currentPartition,
currentCompany,
_refAllProjectsRecId,
int2Str(_refAllProjectsRecId),
TableNum(ProjTable),
curProjRecId,
_mainProjId);
PMIPSimpleAdjustmentsProjectsHelper::executeSQLStatement(insertTempSQL);
}
public static void initializeProjHierarchyTemp(
RecId _refRootProjTable,
str _tempTablePhysicalName,
ProjId _curProjId,int _refAllProjectsRecId, ProjId _mainProjId)
{
Partition currentPartition = getCurrentPartitionRecId();
DataAreaId currentCompany = curExt();
ProjTable rootProjTable = ProjTable::findRecId(_refRootProjTable);
RecId curProjRecId = ProjTable::find(_curProjId).RecId;
// Construct a query to insert all (ProjTable) records from billing schedule line into the temp table
str insertTempSQL = strFmt(@"INSERT INTO %1 (
Partition, DataAreaId, RefRecId, RefSortRecId, RefNodeId, Expand, Visible, RefTableId, RefRootProjTableSub,RefAllProjecsIds
) SELECT
%2, '%3', P1.RecId, Sort.RecId, P1.RecId, IIF(Sort.RefRootProjTable = Sort.RefProjTable, 1, 0), IIF(Sort.RefRootProjTable = Sort.RefProjTable OR P1.ParentId = '%5', 1, 0), '%6', Sort.RefRootProjTableSub, %8
FROM ProjTable AS P1
INNER JOIN PMIPProjectsSorting AS Sort ON
Sort.Partition = %2 AND Sort.DataAreaId = '%3'
AND Sort.RefProjTable = P1.RecId AND Sort.RefRootProjTable = %4
WHERE
P1.Partition = %2 AND P1.DataAreaId = '%3' AND P1.RecId = %7
AND Sort.MainProjId = '%9'",
_tempTablePhysicalName,
currentPartition,
currentCompany,
_refRootProjTable,
rootProjTable.ProjId,
TableNum(ProjTable),
curProjRecId,
_refAllProjectsRecId,
_mainProjId);
PMIPSimpleAdjustmentsProjectsHelper::executeSQLStatement(insertTempSQL);
}
Thanks
Badri