I am creating a list data table subset from a main data table. Then, I manipulate the data through Tabulate() and make into the table for processing. Then, check each of the data table N Rows, if N Rows = 0, close the data table. Finally, append the data table into the report. Below is my script.
The problem is after I add in below codes, to check the N Rows, it no longer work. No error show up.
If(N Rows(mDT)==0, Close(mDT, no save));
I believe might be some error on the code. The overall code might not be well written
Need guideline and help here.
saveFolder = "$TEMP/";
listDT = {};
listtab = {};
mDT = {};
col = Column(dt1Sub, ":PART");
colLevs = Associative Array(col) << Get Keys;
hb = V List Box( );
For (i=1, i<=NItems(colLevs), i++,
r2get = dt1 << Get Rows Where(:PART == colLevs[i]);
listDT[i] = dt1 << Subset(Rows(r2get));
listDT[i] << Set Name(Char(colLevs[i]));
listDT[i] << Save( saveFolder || Word( 1, listDT[i] << get name, "-" )||".csv");
listtab = listDT[i] << Tabulate(
Show Control Panel( 0 ),
Add Table(
Column Table( Grouping Columns( :ORDER ) ),
Column Table( Statistics( Sum ), Analysis Columns( :Qty ) ),
Row Table(
Grouping Columns(
::PART,
::PART DESC,
:LOW PART #,
:LOW PART DESC,
:FAILURE MODE
)
)
)
);
mDT= listtab << Make Into Data Table;
Close(listDT[i], no save);
mDT << New Column ("Criteria", Character, "Nominal",
Formula(
If(As Column(6)>= 3, "Failure")
)
);
mDT:Criteria << Delete Formula;
mDT << Sort(By(Column(6)),Order(Descending), Replace Table);
mDT << Select Where (:As Column(6) == 0);
mDT << Delete Rows;
If(N Rows(mDT)==0, Close(mDT, no save));
mDT << Set Window Size (2400, 800);
mDT << Get As Report;
hb << Append( ( mDT << Get As Report ) );
);
New Window( "Report", hb );