I recently updated both CGIDEV2 and HSSFCGI from older 2019 versions to the latest 2023 version. After doing so, one of my jobs ran amuck. The XLSXGEN program was stuck in an endless loop.
After several hours of debug, I found the issue in my XML data – I was creating a cell type of “Formula” where the cell data was blank. Previously, this simply put *ERROR* in the cell and moved on.
More importantly, I discovered that the XLSXGEN program was looping between an “Exit” subroutine and the *PSSR subroutine.
A java error occurs in ss_formula() when formula is blank, triggering the "Failed" subroutine - no issue here.
(From procedure CellFormula)
Code: Select all
peFormula=%trim(formula);
monitor;
ss_formula(row:rowcellNbr:peFormula:cellstyle); // theRow:theRowcellNbr ????
on-error;
exsr Failed;
endmon;
<other code here>
Begsr Failed;
CellError(); //create TEXT cell containing '*ERROR*'
msgTxt='FORMULA cell failed to be created in +
row no. ' + %trim(%editc(rowNbr+1:'J')) +
', cell no. ' + %trim(%editc(rowCellnbr+1:'J')) +
', sheet ' + %trim(sheetname) +
', workbook ' + %trim(outStmf);
SndMsgBack('*DIAG ':msgTxt);
Endsr;
/end-free
P CellFormula e
But this generates another error indicating a reference to an object that no longer exists. "Row" contains a reference to
OBJECT(*JAVA:'org.apache.poi.ss.usermodel.Row').
Code: Select all
*=========================================================================
* Create a TEXT cell flagged as error
*=========================================================================
P CellError b
D CellError pi
D dataValue s 5000 varying
/free
dataValue='*ERROR*';
cellStyleArg='LGTXTC';
SetCellstyle(cellStyleArg); // assign/create cell style in variable "cellstyle"
datavalue1024=datavalue; //proc hssf_text supports a max of 1024 chars
SS_TEXT(Row:rowcellNbr:dataValue1024:cellStyle);
/end-free
P CellError e
Here is where we enter the endless loop - *PSSR executes subroutine EXIT
Code: Select all
*========================================================================
* Program status subroutine
*========================================================================
/free
Begsr *PSSR;
statCodeSave=PSDSSTSCD; //save the Error Status Code: type of error
if pssrInd=*on; //*PSSR already entered
[b]exsr Exit[/b];
endif;
pssrInd=*on;
Code: Select all
*========================================================================
* Exit program
*========================================================================
/free
Begsr Exit;
// Close the XLSGEN log file
if %open(XLSGENLOG);
close XLSGENLOG;
endif;
// Close the HSSFCGIDTA error messages file
if %open(XLSGENERRS);
close XLSGENERRS;
endif;
// Close the QTEMP warning messages file
if %open(XLSGENWMSG);
close XLSGENWMSG;
endif;
// If coming from *PSSR, ...
if pssrInd=*on;
[b]ss_freeLocalRef(outfile);[/b]
ss_freeLocalRef(tempstr);
ss_end_object_group(); //Remove space for object references in the object group
FreeRefs(); //Free JVM object references to free memory
I would like to fix the error logic in XLSXGEN so this doesn’t happen again, and would appreciate any suggestions.
FWIW - I compared the source code from my previous version. The code previously checked the content in CellFormula before using SS_FORMULA... that was removed in favor of the monitor block.
Thx,
Greg