Hello all! This is the continuation of my first blog. Please have a look at it before this.
https://blogs.sap.com/2023/08/15/subtotals-on-adobe-forms/
As said in the conclusion of my first blog, if the data contains 5000 records, the loop has to be run 5000 times plus the number of subtotal rows.
In the Above case it was 6 + 3 = 9 times
So Time Complexity will be O( No of Data + No of Subtotal Rows )
————————————————————————————————————————————–
We can optimize it to O(number of subtotal rows) by using a simple technique🤔 Let’s start.
// Get rows_table Reference that is coming from ABAP
var rows_table = xfa.resolveNodes("$record.ROWS_NO.DATA[*]");
// Get length of the table for running the loop.In our above case it will be 3. Loop Will be Run for three times
var length = rows_table.length;
// Loop Subtotal Row, get index one by one and apply formatting
for( var i =0 ; i<length; i++)
{
// Get Subtotal Row_index and use it for further formatting.
var row_index = xfa.resolveNode("$record.ROWS_NO.DATA[" + i + "].ROW_NO").value;
// Explanation for this part given on Previous Blog. Refer that
xfa.resolveNode("data.MainSubform.ItemDetails.Item.FORM_DATA.DATA[" + row_index + "].INVOICE_NO").colSpan = "2";
xfa.resolveNode("data.MainSubform.ItemDetails.Item.FORM_DATA.DATA[" + row_index + "].INVOICE_DATE").presence = "hidden";
xfa.resolveNode("data.MainSubform.ItemDetails.Item.FORM_DATA.DATA[" + row_index + "].INVOICE_NO").para.hAlign = "center";
xfa.resolveNode("data.MainSubform.ItemDetails.Item.FORM_DATA.DATA[" + row_index + "]").fillColor = "192,192,192";
xfa.resolveNode("data.MainSubform.ItemDetails.Item.FORM_DATA.DATA[" + row_index + "].INVOICE_NO").font.weight = "bold";
xfa.resolveNode("data.MainSubform.ItemDetails.Item.FORM_DATA.DATA[" + row_index + "].INVOICE_CURRENCY").font.weight = "bold";
xfa.resolveNode("data.MainSubform.ItemDetails.Item.FORM_DATA.DATA[" + row_index + "].INVOICE_AMOUNT").font.weight = "bold";
}
In this blog, I explained the optimization of my first blog method for subtotals.
Sincerely appreciate any feedback, comments, or questions.
Thanks
Nagaraj R