Hi all. I’m working on a project where I am populating a temp table via X++ code on a form, and I want to pass that data into a (MorphX) report so I can print it. I’ve got the code working fine, by copying the data into a RecordSortedList, but I’m curious as to whether or not there would be a cleaner way to do this. The way I’m doing it, I have to loop through the temp table to copy it to the RecordSortedList, then later loop through the RecordSortedList and feed it to the report.
Here’s the code that executes on my form, when the user presses ‘print’:
RecordSortedList list;
Args rptArgs;
ReportRun reportRun;
// (myTempTable has already been populated.)
list = new RecordSortedList(tablenum(myTempTable));
list.sortOrder(fieldNum(myTempTable, Field1), fieldNum(myTempTable, Field2));
while select * from myTempTable
order by myTempTable.Field1, myTempTable.Field2
{
list.ins(myTempTable);
}
rptArgs = new Args(reportStr(MyReportObject));
rptArgs.object(list);
reportRun = new ReportRun(rptArgs);
reportRun.init();
reportRun.run();
And here’s the code from my report:
public class ReportRun extends ObjectRun
{
RecordSortedList inputList;
}
public void init()
{
super();
inputList = element.args().object();
}
public boolean fetch()
{
boolean moreData;
MyTempTable myTempTable;
moreData = inputList.first(myTempTable);
while (moreData)
{
element.send(myTempTable);
moreData = inputList.next(myTempTable);
}
//ret = super();
return true;
}
As I said, this works fine. I’m just curious if I’m doing this the hard way.
[8-)]