Hello all. I'm having a problem using a data structure; when trying to sum a certain subfield of the data structure, I receive a data decimal error that I cannot resolve. Here is the code:
It gives me a decimal data error saying "Cause . . . . . : The sign or the digit codes of the packed or the zoned
decimal operand is in error. Valid signs are hex A-F, valid digit range is hex 0-9."
The other weird thing, is that before it enters the For loop, the value for ReportTable(i).NetCheck is ok. But as soon as it enters the loop, the two decimal values are always .04.
I've tried playing around with different data types in the data structure and for the NetCheckTotal variable, but I always get the same results. I just don't understand why entering a For loop would cause something like this.
Thanks
Code:
D ReportTable DS DIM(10000) QUALIFIED
D VendorNum 7P 0 INZ(*HIVAL)
D Payee 20A INZ(*HIVAL)
D InvNum 7A INZ(*HIVAL)
D DueDate 8P 0 INZ(*HIVAL)
D InvTotal 8P 2 INZ(*HIVAL)
D Discount 9P 2 INZ(*HIVAL)
D NetCheck 11S 2 INZ(*HIVAL)
D NumRec S 8 0
D VendorTotal S 8P 2
D NetCheckTotal S 11S 2
D VendorNumTemp S 7P 0
D SortArray S 50A DIM(10000)
D i S 5 0
//the following code is within a loop that is reading all records in a file and placing the info into the data structure which is later sorted
NumRec += 1;
ReportTable(NumRec).VendorNum = A7SUP#;
ReportTable(NumRec).Payee = A7SRC;
ReportTable(NumRec).InvNum = A7INVN;
ReportTable(NumRec).DueDate = A7DUDT;
ReportTable(NumRec).InvTotal = A7INV$;
ReportTable(NumRec).Discount = A7DS$;
ReportTable(NumRec).NetCheck = A7INV$ - A7DS$;
//Sort the table array ---------------------------------------------------------------
For i = 1 to %Elem(ReportTable);
SortArray(i) = ReportTable(i);
EndFor;
SortA SortArray;
For i = 1 to %Elem(ReportTable);
ReportTable(i) = SortArray(i);
EndFor;
//Processing for summary report ------------------------------------------------------
VendorNumTemp = ReportTable(1).VendorNum;
For i = 1 to NumRec;
If VendorNumTemp = ReportTable(i).VendorNum;
VendorTotal += ReportTable(i).InvTotal;
//****ERROR OCCURS ON THE LINE BELOW*************
NetCheckTotal += ReportTable(i).NetCheck;
VendorNumTemp = ReportTable(i).VendorNum;
VENNUM2 = ReportTable(i).VendorNum;
PAYEE2 = ReportTable(i).Payee;
INVNUM2 = ReportTable(i).InvNum;
DUEDATE2 = ReportTable(i).DueDate;
INVTOTAL2 = ReportTable(i).InvTotal;
DISCOUNT2 = ReportTable(i).Discount;
NETCHECK2 = ReportTable(i).NetCheck;
If *IN96 = *ON;
write HEADER2;
*IN96 = *OFF;
EndIf;
write DETAIL2;
Iter;
Else;
If *IN96 = *ON;
write HEADER2;
*IN96 = *OFF;
EndIf;
VENTOTAL2 = VendorTotal;
NETCHKTOT2 = NetCheckTotal;
write DETAIL2;
VendorTotal = *zeros;
NetCheckTotal = *zeros;
VendorNumTemp = ReportTable(i).VendorNum;
EndIf;
EndFor;
It gives me a decimal data error saying "Cause . . . . . : The sign or the digit codes of the packed or the zoned
decimal operand is in error. Valid signs are hex A-F, valid digit range is hex 0-9."
The other weird thing, is that before it enters the For loop, the value for ReportTable(i).NetCheck is ok. But as soon as it enters the loop, the two decimal values are always .04.
I've tried playing around with different data types in the data structure and for the NetCheckTotal variable, but I always get the same results. I just don't understand why entering a For loop would cause something like this.
Thanks