Build HTML Reports with One Uniface Table Builder

Résumé

Pixel shares a reusable Uniface ProcScript entry for building HTML report tables from a compact column-type string. It formats text, numbers, money in cents, and quantities in thousandths, replacing repetitive per-table loops and helping make multi-report customer apps easier to maintain.

DEV Community

One table builder for all HTML reports - column types in a short string in Uniface ProcScript

Stage 32 of the customer app from the series Building a customer app in Uniface 10 added six analysis services. Each has a report that collects the results of the other operations into one HTML file with five or six tables. In stage 31 every table had its own loop with getitem, escaping and $concat calls - about 15 lines per table. Tested with Rocket Uniface 10.4.03 Community Edition (10.4.03.021) on Windows, October 2026. The app uses SQLite through the SLE driver (SQLite 3.50.2). The rows All operations return their result the same way: sql/data gives a Uniface list, one item per row, and each row is a list of columns. Money is in cents, quantities in thousandths (QTY_MILLI). The column string A table needs to know three things: the title, the header and which columns to show in which format. The columns are passed as a string of pairs - a letter for the kind and a digit for the column: T text, HTML-escaped N number as it is M money: cents formatted with two decimals Q quantity: thousandths formatted with three decimals T2T3Q4M6 means: column 2 and 3 as text, column 4 as quantity, column 6 as money. One digit is enough because no row has more than nine columns. The entry entry HTML_TABLE
params
string pTitle : IN
string pData : IN
string pHead : IN
string pCols : IN
string pHtml : INOUT
endparams
variables
string vNl, vRow, vLine, vKind, vV
numeric vI, vJ, vLen, vPos, vNum
endvariables
vNl = "%%^"
pHtml = $concat(pHtml, "

", pTitle, "

", vNl)
if (pData = "")
pHtml = $concat(pHtml, "

None.

", vNl)
return 0
endif
pHtml = $concat(pHtml, " ", pHead, vNl)
vLen = $length(pCols)
forlist vRow in pData
vLine = ""
vI = 1
while (vI < vLen)
vJ = vI + 1
vKind = pCols[vI:1]
vPos = pCols[vJ:1]
getitem vV, vRow, vPos
if (vKind = "M")
vNum = vV
call FMT_CENTS(vNum, vV)
endif
if (vKind = "Q")
vNum = vV
call FMT_QTY(vNum, vV)
endif
call HTML_ESC(vV)
vLine = $concat(vLine, "", vV, "")
vI = vI + 2
endwhile
pHtml = $concat(pHtml, vLine, "", vNl)
endfor
pHtml = $concat(pHtml, "", vNl)
return 0
end
pCols[vI:1] is ProcScript's substring: start position and length. The loop steps through the string two characters at a time. The header is passed ready as HTML, because it is a constant in each report. The calls A report is now one line per table: call HTML_TABLE("Coverage (consumption of the last 90 days)", vD1, "SKUProductStockOut in 90 daysDays of stock", "T2T3Q4Q5N6", vHtml)
call HTML_TABLE("Inventory differences", vD5, "CountPostedWarehouseSKUBookCountedDifferenceValue", "N1T2T3T4Q5Q6Q7M8", vHtml)
The header text is escaped once when the service is generated, not at runtime. What the reports look like Coverage section of the stock report with the test data: SKU Product Stock Out in 90 days Days of stock
TS32-B Item B 0,200 2,300 7
TS32-A Item A 4,000 6,000 60
TS32-C Item C 1,000 0,000 -1
Notes FMT_CENTS and FMT_QTY run one small SQL statement per cell. For reports with a few hundred rows this is fast enough; for large exports the formatting belongs into the main query. An empty result shows "None." under the title instead of an empty table. Thirty-six tests of the stage call the operations behind the reports; six more write each report and look for a section title and the closing .
Build HTML Reports with One Uniface Table Builder
Powered by Readybot.io

Les dernières actus de Pixel

Incident Response: Look Beyond the Red Alert

Pixel’s DEV Community announcement explores how teams can fixate on one failing service while overlooking the real cause of an outage, such as a full …

Sach: AI Fact-Checks WhatsApp Forwards in India

Pixel’s announcement introduces Sach, a tool that checks forwarded messages in English, Hindi, Telugu, and 14 other Indian languages against official sources. It gives cited …

Java 25 Removes SecurityManager: What to Fix

Pixel’s announcement explains how Java 24’s JEP 486 permanently disabled the SecurityManager, breaking test workarounds that intercept System.exit. It recommends returning exit codes or throwing …