Skip to content

v2026.11.25 — Packed fields of every length, unsigned INT1, UTCLONG, and a leaner proto backend

Latest

Choose a tag to compare

@jrosskopf jrosskopf released this 25 Nov 19:40
· 4 commits to master since this release
97ffcc9

A packed field of even length no longer fails sap_read_table (#255), and an audit of every DDIC type that #255
prompted fixed four more silent errors: INT1 255 read as -1, every UTCLONG read as NULL, DECFLOAT lost its
fraction, and a real midnight read as NULL. A boundary-value fixture now reads every DDIC type erpl maps at its
extremes, on both backends. Text cells are cheaper on both backends, and the proto backend
(SET erpl_rfc_backend = 'proto'; SAP's NW RFC SDK is still the default) now reads large tables with less peak
memory, fewer instructions and less CPU than SAP's library.

Changes visible to callers

  • INT1 columns are UTINYINT (were TINYINT). 255 used to fail sap_read_table and came back as -1 from
    sap_rfc_invoke.
  • Even-length DEC/CURR/QUAN columns are declared one digit wider, e.g. DEC(4,1) is DECIMAL(4,1), not
    DECIMAL(3,1).
  • DECFLOAT16/34 columns are DOUBLE (were DECIMAL(16|34, 0), which cut every fraction off). A double holds
    about 15–17 significant digits: a full 16-digit DECFLOAT16 such as 9999999999999999 reads as 1e+16, and a
    DECFLOAT34 keeps about 17 digits.
  • An initial TIMS (000000) reads as 00:00:00, so TM IS NULL no longer matches midnight. A blank TIMS and
    an initial DATS still read as NULL.
  • UTCLONG values are read instead of turning into NULL, and erpl writes the spelling SAP's library accepts.

Fixed

  • [rfc] A packed field of even length no longer fails the whole read
    (#255).
    sap_read_table sized a DEC/CURR/QUAN field one digit short for
    every even DDIC length -- DEC(4,1) became DECIMAL(3,1) -- so a value using
    all its digits (100.0, 999.9) aborted the scan with Could not convert
    string ... to DECIMAL(3,1)
    . The byte count is now LENG / 2 + 1, the rule the
    invoke path already used. The reporter's diagnosis was exact. Columns of even
    length are declared one digit wider than before; ODP columns of even length
    too (ODP reports a character width there, so they only widen).

  • [rfc] INT1 is unsigned. ABAP's INT1 holds 0..255 and was mapped to the
    signed TINYINT: 255 failed sap_read_table and came back as -1 from
    sap_rfc_invoke, silently, and 128..255 could not be sent. It is now
    UTINYINT on every path.

  • [rfc] UTCLONG values are read instead of turning into NULL. Only the
    compact YYYYMMDDHHMMSS,fffffff spelling parsed; what SAP's library sends
    (YYYY-MM-DDTHH:MM:SS,fffffff) and what RFC_READ_TABLE sends
    (YYYY-MM-DD HH:MM:SS.fffffff) became NULL without an error, so every UTCLONG
    read as NULL on both paths. All three parse now (sub-microsecond digits are
    truncated, never rounded), text that is none of them is an error, and erpl
    writes the form SAP's library accepts -- it refused the compact one.

  • [rfc][odp][ape] DECFLOAT16/34 columns are now DOUBLE (was DECIMAL(16|34, 0)).
    A decimal float has no fixed scale, and the zero scale cut every fraction
    off -- 1.234567890123456 read as 1, on sap_read_table and on
    sap_rfc_invoke alike. Callers that compared a DECFLOAT column to a DECIMAL
    literal, or relied on exact decimal arithmetic on it, see a type change.

  • [rfc] An initial TIMS (000000) reads as 00:00:00, not NULL. Midnight
    is a real time; TM IS NULL no longer matches it. A blank TIMS still reads as
    NULL, and an initial DATS stays NULL.

  • [rfc] Packed, DECFLOAT and UTCLONG values read through sap_rfc_invoke
    converted the reader's whole buffer instead of the value's length, so the
    units after the terminator -- uninitialised memory -- were part of the text.

  • [rfc] A boundary-value fixture covers every DDIC type erpl maps:
    scripts/sap/provision.d/26-types-boundary.sh creates ZERPL_TYPES_BV
    (packed fields at every length up to DEC(31,14), CURR/QUAN, INT1..INT8, FLTP,
    DECFLOAT, DATS, TIMS, RAW, NUMC, CHAR, ACCP, PREC, LANG, UTCLONG at their
    largest, most negative, initial and smallest values, plus non-BMP text) and
    Z_ERPL_TYPES_BV, and sap_read_table_packed_even_length.test reads it
    through sap_read_table and sap_rfc_invoke on both backends.

  • [rfc] sap_read_table reads text cells faster on both backends. Every
    cell arrives as a blank-padded CHAR(512) field; the trailing blanks were
    converted to UTF-8 and then trimmed again one byte at a time. They are now
    dropped on the UTF-16 units first, so only the text is converted. Results are
    identical (a row hash over DD04T matches); DD04T takes 46% fewer instructions
    through SAP's library and 19% fewer through the proto shim.

Faster (proto backend)

  • [rfc] A text cell as wide as erpl's buffer is copied without scanning it. The shim searched each
    512-character RFC_READ_TABLE field for its last non-blank only to refuse text that does not fit; erpl's buffer
    always fits. DD04T: 31% fewer instructions (erpl-proto #106).
  • [rfc] Large replies are mapped by the shim itself, and decompression copies in bulk. Freeing a large
    reply let glibc raise its mmap threshold, after which later replies fragmented DuckDB's heap; the shim now maps
    and unmaps each large reply directly, without changing the host's allocator settings (Linux glibc; musl, macOS
    and Windows keep the plain buffer). On a 297,000-row sap_read_table('DD04T') the proto backend now peaks at
    664–827 MB against SAP's library's 975–1160 MB, with 53 G instructions against 109 G and 10.3–11.4 s of CPU
    against 17.5–18.5 s (erpl-proto #107).
  • [rfc] The shim renders text as SAP's library does: CHAR read through RfcGetString drops trailing blanks,
    UTCLONG uses SAP's spelling, and narrow field descriptors carry SAP's byte offsets (erpl-proto #109).

erpl-proto 35be92c → 020adea.