<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Maria Galman on Medium]]></title>
        <description><![CDATA[Stories by Maria Galman on Medium]]></description>
        <link>https://medium.com/@mariagalman2025?source=rss-3e9868785794------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_RESf4z1VIUvqmNm</url>
            <title>Stories by Maria Galman on Medium</title>
            <link>https://medium.com/@mariagalman2025?source=rss-3e9868785794------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 03:32:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mariagalman2025/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Enforcing a Single Root Node in PL/SQL Before Cancel-and-Replace Loads]]></title>
            <link>https://medium.com/@mariagalman2025/enforcing-a-single-root-node-in-pl-sql-before-cancel-and-replace-loads-86fe029e41a6?source=rss-3e9868785794------2</link>
            <guid isPermaLink="false">https://medium.com/p/86fe029e41a6</guid>
            <category><![CDATA[plsql]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[erp-software]]></category>
            <category><![CDATA[oracle]]></category>
            <dc:creator><![CDATA[Maria Galman]]></dc:creator>
            <pubDate>Tue, 25 Aug 2026 19:49:27 GMT</pubDate>
            <atom:updated>2026-08-25T19:49:27.681Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Problem</h3><p>In an Oracle Fusion ERP integration, a hierarchy table living in an Autonomous Transaction Processing (ATP) database — the source of truth staged before upload into Oracle Fusion — is only as trustworthy as the tree it represents. A CONNECT BY query that starts with PARENT IS NULL will happily build a tree from <em>every</em> root it finds — which is exactly the trap: the business requirement is a single root node (call it CORP_ROOT), but the moment a stray record with a NULL parent slips into the source table, you silently get a second, parallel tree.</p><p>This matters more than it looks. The hierarchy table in question feeds a <strong>File-Based Data Import (FBDI)</strong> load (<em>Import Segment Values and Hierarchies</em>) that runs in <strong>cancel-and-replace mode</strong> — every run wipes out the previous tree definition in Fusion and reloads it from scratch. If a polluted hierarchy makes it into that FBDI file, you don’t just get a wrong report: you overwrite a working, validated tree structure in production with a broken one. There’s no partial rollback once cancel-and-replace has run.</p><p>So the real question isn’t “how do we build the tree” — that part is a standard CONNECT BY exercise. The real question is: <strong>how do we know, before FBDI ever touches the data, whether the tree we&#39;re about to push is actually the single tree we expect?</strong></p><h3>The Package</h3><p>The approach: a PL/SQL package that rebuilds a flattened hierarchy table and stamps every row with a VALID flag, computed from CONNECT_BY_ROOT against a known-good root code.</p><p>Two tables are involved: XX_REF.XX_ORG_UNIT_SOURCE_TBL holds the raw parent/child pairs as maintained upstream, and XX_ORG_UNIT_HIERARCHY is the flattened, validated output the package rebuilds on every run.</p><pre>CREATE OR REPLACE PACKAGE XX_HIERARCHY_VALIDATION_PKG AS</pre><pre>    -- The single expected root code<br>    C_EXPECTED_ROOT CONSTANT VARCHAR2(100) := &#39;CORP_ROOT&#39;;</pre><pre>    -- Rebuilds the hierarchy table from the source table, VALID flag included.<br>    -- p_status  : &#39;SUCCESS&#39; or &#39;ERROR&#39; -- clean value for equality checks (e.g. OIC Switch)<br>    -- p_message : detail -- row count on success, error detail on failure<br>    PROCEDURE REBUILD_HIERARCHY (<br>        p_status  OUT VARCHAR2,<br>        p_message OUT VARCHAR2<br>    );</pre><pre>END XX_HIERARCHY_VALIDATION_PKG;<br>/</pre><pre>CREATE OR REPLACE PACKAGE BODY XX_HIERARCHY_VALIDATION_PKG AS</pre><pre>    PROCEDURE REBUILD_HIERARCHY (<br>        p_status  OUT VARCHAR2,<br>        p_message OUT VARCHAR2<br>    )<br>    IS<br>        v_count NUMBER;<br>    BEGIN<br>        EXECUTE IMMEDIATE &#39;TRUNCATE TABLE XX_ORG_UNIT_HIERARCHY&#39;;<br>        COMMIT;</pre><pre>        INSERT INTO XX_ORG_UNIT_HIERARCHY (CODE, PARENT, HIERARCHY_LEVEL, SEQ_NUM, VALID)<br>        WITH q AS (<br>            SELECT<br>                t.CODE,<br>                t.PARENT,<br>                LEVEL AS HIERARCHY_LEVEL,<br>                CONNECT_BY_ROOT t.CODE AS ROOT_CODE,<br>                SYS_CONNECT_BY_PATH(t.CODE, &#39;/&#39;) AS HIERARCHY_PATH<br>            FROM XX_REF.XX_ORG_UNIT_SOURCE_TBL t<br>            WHERE t.INTEGRATION_STATUS = &#39;Integrated&#39;<br>            START WITH t.PARENT IS NULL<br>            CONNECT BY NOCYCLE PRIOR t.CODE = t.PARENT<br>        )<br>        SELECT<br>            CODE,<br>            NVL(PARENT, &#39;None&#39;) AS PARENT,<br>            HIERARCHY_LEVEL,<br>            CASE<br>                WHEN PARENT IS NULL THEN 1<br>                ELSE ROW_NUMBER() OVER (PARTITION BY PARENT ORDER BY CODE)<br>            END AS SEQ_NUM,<br>            CASE<br>                WHEN ROOT_CODE = C_EXPECTED_ROOT THEN &#39;Y&#39;<br>                ELSE &#39;N&#39;<br>            END AS VALID<br>        FROM q<br>        ORDER BY HIERARCHY_PATH;</pre><pre>        v_count := SQL%ROWCOUNT;<br>        COMMIT;</pre><pre>        p_status  := &#39;SUCCESS&#39;;<br>        p_message := v_count || &#39; rows processed&#39;;</pre><pre>    EXCEPTION<br>        WHEN OTHERS THEN<br>            ROLLBACK;<br>            p_status  := &#39;ERROR&#39;;<br>            p_message := &#39;Procedure not executable - &#39; || SQLERRM;<br>    END REBUILD_HIERARCHY;</pre><pre>END XX_HIERARCHY_VALIDATION_PKG;<br>/</pre><p>A few design choices worth calling out:</p><ul><li><strong>CONNECT_BY_ROOT, not a second query.</strong> Every row already knows which root it descended from — no need for a separate lookup to classify it.</li><li><strong>Two clean OUT parameters, not one concatenated string.</strong> Early iterations of this procedure returned &#39;SUCCESS - 245 rows&#39; as a single string. That works until you try to branch on it in an orchestration tool: LIKE &#39;SUCCESS%&#39; is a fragile condition compared to a strict p_status = &#39;SUCCESS&#39;. Splitting status from message keeps the control-flow value machine-readable and the detail human-readable.</li><li><strong>WHEN OTHERS with </strong><strong>ROLLBACK and </strong><strong>SQLERRM, not a raw exception.</strong> A calling integration tool shouldn&#39;t have to parse a stack trace to know whether the load succeeded.</li><li><strong>A parameterless procedure is invisible to some integration tooling.</strong> Worth a callout on its own: a procedure with zero parameters can simply not appear in a DB Adapter’s operation picker in some wizard configurations, because there’s nothing to generate a request/response schema from. Adding an OUT status parameter isn’t just good practice — it can be the difference between the procedure showing up at all.</li></ul><h3>Wiring It Into OIC</h3><p>The orchestration is deliberately simple:</p><ol><li><strong>Invoke</strong> the procedure.</li><li><strong>Switch</strong> on p_status = &#39;SUCCESS&#39;.</li><li><strong>Success branch</strong> — proceed to read XX_ORG_UNIT_HIERARCHY WHERE VALID = &#39;Y&#39; and hand that off downstream (to the FBDI file generation step, in this case).</li><li><strong>Error branch</strong> — raise a fault (HTTP 500 is the semantically correct choice here: the failure is server-side, not a malformed client request) carrying p_message, and log or notify as appropriate.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1rJjgYGp-zNyjpt7CiXBZQ.png" /></figure><h3>Why This Matters for FBDI Cancel-and-Replace</h3><p>FBDI’s cancel-and-replace behavior for tree structures does exactly what it says: the existing tree in Fusion is deleted and rebuilt from the file, in full, every time. There’s no merge, no partial update, no diffing against the previous state. If the file is correct, this is a clean and predictable mechanism. If the file is wrong — say, because a second root node snuck into the source data — cancel-and-replace will faithfully load <em>that</em> wrong tree, overwriting whatever correct structure was there before.</p><p>This is precisely why the VALID flag isn&#39;t a nice-to-have report column — it&#39;s the gate. By filtering on VALID = &#39;Y&#39; before generating the FBDI file, the integration guarantees that only rows provably descending from the single expected root ever reach Fusion. A stray root, or a node with a broken parent reference, is either excluded outright (orphans never even survive the CONNECT BY walk) or flagged and filtered (parasite roots), but in neither case does it silently ride along into a cancel-and-replace operation that can&#39;t be undone with a simple retry.</p><p>Put differently: the validation logic doesn’t just answer “is the data correct?” — it answers “is it <em>safe to overwrite production with this data?</em>” before an operation that offers no rollback. That distinction is what makes it worth building as a reusable package rather than a one-off query, and worth wiring explicitly into the OIC flow rather than trusting the source table to stay clean on its own.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86fe029e41a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Encrypting Sensitive Data with DBMS_CRYPTO and Calling It from OIC]]></title>
            <link>https://medium.com/@mariagalman2025/encrypting-sensitive-data-with-dbms-crypto-and-calling-it-from-oic-44c7095f602b?source=rss-3e9868785794------2</link>
            <guid isPermaLink="false">https://medium.com/p/44c7095f602b</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[oracle]]></category>
            <category><![CDATA[oracle-integration-cloud]]></category>
            <dc:creator><![CDATA[Maria Galman]]></dc:creator>
            <pubDate>Mon, 24 Aug 2026 10:14:15 GMT</pubDate>
            <atom:updated>2026-08-24T10:14:15.128Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction — the real problem</h3><p>In many Oracle Fusion / OIC integrations, a flow sometimes needs to transmit sensitive data — a user password, for instance — without ever exposing it in plain text: not in the payload, not in the logs, not in network traces.</p><p>The obvious answer is “encrypt it.” But encrypting a piece of data and actually <strong>securing</strong> it are not the same thing. That’s the whole point of this article: showing how to set up AES256 encryption in PL/SQL, call it from an OIC flow, and — more importantly — understand where the real risk sits once encryption is in place.</p><h3>Where does this code actually live?</h3><p>Worth clarifying upfront: Oracle Fusion Applications (ERP Cloud) is a fully managed SaaS environment. There’s no direct access to the underlying database — no custom PL/SQL packages deployed inside the Fusion schema itself. Custom logic like the package below typically lives on a separate <strong>Autonomous Database (ATP)</strong> provisioned on OCI, with OIC acting as the orchestrator: it reaches Fusion through REST/SOAP APIs, and reaches ATP independently through a DB Adapter connection.</p><p>This is the pattern used here: the encryption logic runs on an ATP instance, and OIC calls it through that DB Adapter connection — separate from whatever calls OIC makes into Fusion itself.</p><h3>DES vs AES256: why the algorithm choice matters</h3><p>An earlier version of this package used DBMS_CRYPTO.ENCRYPT_DES. It works technically, but DES no longer belongs in a current architecture:</p><p>Algorithm Key length Resistance to brute force DES 56 bits Crackable within hours (reference: EFF DES Cracker, 1998) AES256 256 bits Out of reach of current computing power</p><p>With 2⁵⁶ possible combinations, a DES key can be brute-forced with relatively modest hardware. AES256, with 2²⁵⁶ combinations, makes that approach impractical. Choosing AES256 isn’t cosmetic — it’s a baseline requirement for any genuinely sensitive data.</p><h3>The mechanics of DBMS_CRYPTO</h3><p>DBMS_CRYPTO.ENCRYPT expects a single typ parameter to define the algorithm, the chaining mode, and the padding all at once. Oracle solves this with a bitmask of numeric constants added together:</p><pre>encryption_type PLS_INTEGER := DBMS_CRYPTO.ENCRYPT_AES256<br>                              + DBMS_CRYPTO.CHAIN_CBC<br>                              + DBMS_CRYPTO.PAD_PKCS5;</pre><ul><li>ENCRYPT_AES256: the encryption algorithm (AES, 256-bit key)</li><li>CHAIN_CBC: Cipher Block Chaining mode — each plaintext block is XORed with the previous ciphertext block before being encrypted, so identical blocks never produce identical ciphertext</li><li>PAD_PKCS5: padding that completes the last block to match the block size the algorithm expects</li></ul><p>These three constants are added into a single integer, passed to both DBMS_CRYPTO.ENCRYPT and DBMS_CRYPTO.DECRYPT. Both functions must use the exact same combination, or decryption fails or produces garbage.</p><h3>The PL/SQL procedure</h3><p>Here’s the final version, using AES256:</p><pre>CREATE OR REPLACE PROCEDURE encrypt<br>(<br>   p_plainText   IN  VARCHAR2,<br>   p_encrypted   OUT RAW<br>)<br>IS<br>   encryption_type   PLS_INTEGER := DBMS_CRYPTO.ENCRYPT_AES256<br>                                   + DBMS_CRYPTO.CHAIN_CBC<br>                                   + DBMS_CRYPTO.PAD_PKCS5;<br>   encryption_key    RAW (32) := UTL_RAW.cast_to_raw(&#39;OracleAES256EncryptionKey1234567&#39;);<br>BEGIN<br>   p_encrypted := DBMS_CRYPTO.ENCRYPT<br>   (<br>      src =&gt; UTL_RAW.CAST_TO_RAW (p_plainText),<br>      typ =&gt; encryption_type,<br>      key =&gt; encryption_key<br>   );<br>END encrypt;<br>/</pre><h3>A pitfall along the way: key length</h3><p>First test, first error:</p><pre>ORA-28234: key length too short<br>ORA-06512: at &quot;SYS.DBMS_CRYPTO_FFI&quot;, line 3</pre><p>AES256 requires a key of <strong>exactly 32 bytes</strong> (256 bits). A 25- or 30-character key — even one whose name suggests otherwise — won’t pass. A simple LENGTH() check catches this before the key is hardcoded:</p><pre>SELECT LENGTH(&#39;OracleAES256EncryptionKey1234567&#39;) FROM dual;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*1_RfXFOoLOo3DZ8sUPKExg.png" /></figure><h3>Testing the procedure</h3><p>Before wiring it into OIC, a quick PL/SQL unit test confirms the procedure compiles and works:</p><pre>SET SERVEROUTPUT ON;</pre><pre>DECLARE<br>   v_result RAW(2000);<br>BEGIN<br>   encrypt(&#39;MyPassword123&#39;, v_result);<br>   DBMS_OUTPUT.PUT_LINE(&#39;Encrypted result: &#39; || v_result);<br>END;<br>/</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*u4ykAvYvMuCo3fEx7K9lKA.png" /></figure><p>This representation is <strong>hexadecimal</strong> — the default display format DBMS_OUTPUT uses for a RAW value.</p><h3>Calling the procedure from OIC</h3><p>The OIC flow is built around a scope containing three steps:</p><ul><li><strong>Map CallEncryptProcedure</strong>: prepares the input parameters before the call</li><li><strong>Invoke CallEncryptProcedure</strong>: calls the PL/SQL procedure through a DB Adapter</li><li><strong>Map GetUserPasswordAPI</strong>: builds the response from the encrypted result</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-BxuTbXv_I0JU8iPqOqWVw.png" /></figure><p>Testing this flow produced a value that looked different from the one seen in SQL Developer:</p><pre>LkqxTBursR6bsGSTwqq3Vg==</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*S2cnm5A9-JTbUNNlPBD22g.png" /></figure><p>That’s not an anomaly. The procedure returns a RAW type, and an OIC payload (JSON/XML) can&#39;t carry raw binary. The DB Adapter automatically encodes the RAW value as <strong>base64</strong> before inserting it into the response. It&#39;s the exact same binary data seen in hexadecimal in SQL Developer — only its textual representation differs depending on where it&#39;s observed.</p><p><strong>Something worth flagging for downstream consumption</strong>: any system receiving this encrypted value needs to base64-decode it back to binary first, then apply AES256 decryption with the matching key. Skipping that decoding step is a common source of errors.</p><h3>The real subject: the key, not the algorithm</h3><p>AES256 is resistant to brute-force key guessing. But that’s only true in one specific scenario: when the attacker <strong>doesn’t have</strong> the key.</p><p>The encryption used here is <strong>symmetric</strong>: a single key both encrypts and decrypts. There’s no additional identity check. In practice:</p><ul><li>If someone obtains the key, they can decrypt any data protected with it — it makes no difference whether the algorithm is DES or AES256</li><li>If the key stays secret, then the algorithm’s strength matters for resisting an attempt to guess it</li></ul><p>In the current version of this package, the key is hardcoded directly in the source:</p><pre>encryption_key RAW (32) := UTL_RAW.cast_to_raw(&#39;OracleAES256EncryptionKey1234567&#39;);</pre><p>That makes it readable by anyone with access to ALL_SOURCE / DBA_SOURCE, to a DDL export of the package, or to a Git repository where the script might be versioned. This is the actual weak point of this implementation — not the algorithm.</p><h3>Toward proper key management</h3><p>A few directions worth exploring beyond hardcoding:</p><ul><li><strong>Oracle Wallet</strong>: the key is stored outside the code, in an encrypted wallet managed by the database</li><li><strong>OCI Vault</strong> (or an equivalent secrets manager): the standard enterprise approach — the key never exists in plain text inside the database</li><li><strong>Key rotation</strong>: a mechanism for periodically changing the key, synchronized across every system that uses it</li></ul><h3>Conclusion</h3><p>Setting up AES256 encryption with DBMS_CRYPTO takes a few lines of PL/SQL and fits naturally into an OIC flow through a DB Adapter, running on an Autonomous Database instance since Fusion itself doesn&#39;t allow custom PL/SQL. That part is easy. The part that actually matters is easy to overlook: encryption strength means nothing if the key sits in plain text inside the source code. A hardcoded AES256 key and a hardcoded DES key fail the exact same way — both hand the attacker everything they need the moment they read the code.</p><p>If there’s one takeaway from this exercise, it’s this: don’t ask “which algorithm should I use,” ask “who can read my key.” That’s where the real security work happens — Oracle Wallet, OCI Vault, key rotation — not in the choice between AES and DES.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44c7095f602b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Flat to Hierarchical: Restructuring BI Publisher XML with Data Set Links]]></title>
            <link>https://medium.com/@mariagalman2025/from-flat-to-hierarchical-restructuring-bi-publisher-xml-with-data-set-links-e861171b9aa7?source=rss-3e9868785794------2</link>
            <guid isPermaLink="false">https://medium.com/p/e861171b9aa7</guid>
            <category><![CDATA[oracle-bi-publisher]]></category>
            <category><![CDATA[oracle-cloud]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Maria Galman]]></dc:creator>
            <pubDate>Sat, 22 Aug 2026 22:20:14 GMT</pubDate>
            <atom:updated>2026-08-22T22:20:14.065Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How a standard Oracle Fusion report reveals a common BI Publisher pitfall — and how Data Set Links fix it.</em></p><h3>Introduction</h3><p>If you’ve built RTF or Excel templates in BI Publisher, you’ve probably run into this scenario: your report needs to display data grouped by some parent value — a subinventory, a customer, a department — but your SQL query returns a flat list of rows.</p><p>There’s a cleaner way to solve this — and it starts upstream, in the Data Model itself, not in the template.</p><h3>1. The Starting Point: Oracle’s Standard Min-Max Planning Report</h3><p>Oracle ships a standard Data Model for inventory replenishment reporting, located at:</p><pre>/Supply Chain Management/Warehouse Operations/Inventory/Data Models/Min-Max Report Data Model</pre><p>Its goal is simple: list items that need to be reordered, grouped by subinventory (SUBINVENTORY_CODE).</p><p>The Data Model has a single dataset, Q_MINMAX, built on a global temporary table (INV_MIN_MAX_GT):</p><pre>SELECT<br>    ITEM_SEGMENTS,<br>    DESCRIPTION,<br>    ERROR,<br>    SORTEE,<br>    SUBINVENTORY_CODE,<br>    MIN_QTY,<br>    MAX_QTY,<br>    ONHAND_QTY,<br>    SUPPLY_QTY,<br>    DEMAND_QTY,<br>    TOT_AVAIL_QTY,<br>    MIN_ORD_QTY,<br>    MAX_ORD_QTY,<br>    FIX_MULT,<br>    REORD_QTY,<br>    MINMAX_QTY_UOM,<br>    ORDER_QTY_UOM<br>FROM INV_MIN_MAX_GT<br>ORDER BY SUBINVENTORY_CODE ASC, SORTEE ASC, ITEM_SEGMENTS ASC</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kk2hb2pCu6J-Ksf4PO5hYA.png" /></figure><h3>2. The Observation: A Group Structure That Exists but Doesn’t Work</h3><p>After running the ESS Job <strong>Print Min-Max Planning Report </strong>and downloading the XML Data output, here’s an excerpt of what comes back:</p><pre>&lt;INVISMMX&gt;<br>&lt;G_SUBINVENTORY_CODE&gt;<br>&lt;SUBINVENTORY_CODE&gt; &lt;/SUBINVENTORY_CODE&gt;<br>&lt;G_Q_MINMAX&gt;<br>&lt;ITEM_SEGMENTS&gt;108411&lt;/ITEM_SEGMENTS&gt;<br>&lt;DESCRIPTION&gt;AA&lt;/DESCRIPTION&gt;<br>&lt;SUBINVENTORY_CODE_1&gt; &lt;/SUBINVENTORY_CODE_1&gt;<br>&lt;ONHAND_QTY&gt;0&lt;/ONHAND_QTY&gt;<br>&lt;TOT_AVAIL_QTY&gt;0&lt;/TOT_AVAIL_QTY&gt;<br>&lt;/G_Q_MINMAX&gt;<br>&lt;G_Q_MINMAX&gt;<br>&lt;ITEM_SEGMENTS&gt;108436&lt;/ITEM_SEGMENTS&gt;<br>&lt;DESCRIPTION&gt;TEST&lt;/DESCRIPTION&gt;<br>&lt;SUBINVENTORY_CODE_1&gt; &lt;/SUBINVENTORY_CODE_1&gt;<br>&lt;ONHAND_QTY&gt;150&lt;/ONHAND_QTY&gt;<br>&lt;TOT_AVAIL_QTY&gt;150&lt;/TOT_AVAIL_QTY&gt;<br>&lt;/G_Q_MINMAX&gt;<br>&lt;G_Q_MINMAX&gt;<br>&lt;ITEM_SEGMENTS&gt;108441&lt;/ITEM_SEGMENTS&gt;<br>&lt;DESCRIPTION&gt;TEST-1&lt;/DESCRIPTION&gt;<br>&lt;SUBINVENTORY_CODE_1&gt; &lt;/SUBINVENTORY_CODE_1&gt;<br>&lt;ONHAND_QTY&gt;0&lt;/ONHAND_QTY&gt;<br>&lt;TOT_AVAIL_QTY&gt;0&lt;/TOT_AVAIL_QTY&gt;<br>&lt;/G_Q_MINMAX&gt;<br>&lt;/G_SUBINVENTORY_CODE&gt;<br>...<br>&lt;/INVISMMX&gt;</pre><p>Look closely at the structure. There <em>is</em> a wrapping tag, &lt;G_SUBINVENTORY_CODE&gt;, that contains all the item rows (&lt;G_Q_MINMAX&gt;) — so on paper, the report looks like it&#39;s set up for grouping.</p><p>But look at the actual values:</p><pre>&lt;SUBINVENTORY_CODE&gt; &lt;/SUBINVENTORY_CODE&gt;</pre><p>Empty. And inside each item row:</p><pre>&lt;SUBINVENTORY_CODE_1&gt; &lt;/SUBINVENTORY_CODE_1&gt;</pre><p>Also empty.</p><p>Every single item — regardless of which subinventory it actually belongs to — ends up nested inside <strong>one single, empty group</strong>. The structure exists, but it’s not carrying any real grouping information. From a template’s point of view, there’s no reliable way to say “show me all items for SUBINVENTORY-A, then all items for SUBINVENTORY-B” — because the data needed to tell them apart was never populated in the group tag.</p><h3>3. Why It Happens</h3><p>The root cause is straightforward: the standard query pulls from INV_MIN_MAX_GT, a global temporary table populated by the concurrent program logic, and SUBINVENTORY_CODE simply isn&#39;t carried through correctly to the group level in this dataset.</p><p>More generally, this illustrates a structural limitation: <strong>a single, flat dataset cannot reliably produce a meaningful hierarchy</strong> if the grouping value isn’t clean and available at the right level. You can wrap output in as many &lt;G_...&gt; tags as you want in the RTF template — if the underlying XML doesn&#39;t actually carry distinct group values, the grouping will be cosmetic at best, and broken at worst.</p><h3>4. The Fix: Two Linked Datasets Instead of One</h3><p>Rather than trying to patch this with template-side logic (if-changed fields, manual break detection), the cleaner fix happens in the <strong>Data Model</strong>, using two datasets connected through a <strong>Data Set Link</strong>.</p><h3>Parent dataset — distinct subinventories</h3><p>This dataset returns exactly one row per subinventory. Its only job is to tell BI Publisher: <em>“here is the list of distinct groups you need to loop over.”</em></p><pre>-- Returns one row per unique CODE_ORGANISATION + SUBINVENTORY combination.<br>-- Used as the Group Link source: it tells BI Publisher the distinct<br>-- list of subinventories to iterate over when generating one block per subinventory.</pre><pre>SELECT DISTINCT<br>    iop.ORGANIZATION_CODE  AS CODE_ORGANISATION,<br>    ioqs.SUBINVENTORY_CODE AS SUBINVENTORY<br>FROM INV_MIN_MAX_GT gt<br>    JOIN EGP_SYSTEM_ITEMS_B esib<br>        ON  esib.ITEM_NUMBER     = gt.ITEM_SEGMENTS<br>        AND esib.ORGANIZATION_ID = :P_ORG_ID<br>    JOIN INV_ORG_PARAMETERS iop<br>        ON iop.ORGANIZATION_ID = esib.ORGANIZATION_ID<br>    LEFT JOIN INV_ONHAND_QUANTITIES_SUMMARY ioqs<br>        ON  ioqs.INVENTORY_ITEM_ID = esib.INVENTORY_ITEM_ID<br>        AND ioqs.ORGANIZATION_ID   = esib.ORGANIZATION_ID<br>WHERE ioqs.SUBINVENTORY_CODE IS NOT NULL<br>ORDER BY iop.ORGANIZATION_CODE ASC, ioqs.SUBINVENTORY_CODE ASC</pre><h3>Child dataset — item detail</h3><p>This dataset carries the actual item-level data, including a properly populated MAGASIN column that will serve as the join key.</p><pre>SELECT<br>    gt.ITEM_SEGMENTS       AS ARTICLE,<br>    gt.DESCRIPTION         AS DESIGNATION,<br>    ioqs.SUBINVENTORY_CODE AS MAGASIN,<br>    ioqs.QUANTITY          AS STOCK,<br>    gt.SUPPLY_QTY          AS QUANTITE_ACHAT_A_VENIR,<br>    gt.DEMAND_QTY          AS QUANTITE_COMMANDE_CLIENT,<br>    gt.TOT_AVAIL_QTY       AS STOCK_FINAL_DISPONIBLE,<br>    gt.REORD_QTY           AS PROPOSITION_DE_COMMANDE<br>FROM INV_MIN_MAX_GT gt<br>    JOIN EGP_SYSTEM_ITEMS_B esib<br>        ON  esib.ITEM_NUMBER     = gt.ITEM_SEGMENTS<br>        AND esib.ORGANIZATION_ID = :P_ORG_ID<br>    LEFT JOIN INV_ONHAND_QUANTITIES_SUMMARY ioqs<br>        ON  ioqs.INVENTORY_ITEM_ID = esib.INVENTORY_ITEM_ID<br>        AND ioqs.ORGANIZATION_ID   = esib.ORGANIZATION_ID<br>ORDER BY MAGASIN ASC, gt.ITEM_SEGMENTS ASC</pre><p>Two clean, focused queries — each with a single responsibility. One defines <em>what to group by</em>, the other defines <em>what to display inside each group</em>.</p><h3>5. The Data Set Link: Where the Magic Happens</h3><p>This is the step that actually connects the two datasets and turns them into a real hierarchy in the output XML.</p><p>In the Data Model diagram, select the key field on the child dataset (MAGASIN) and link it to the corresponding field on the parent dataset (SUBINVENTORY):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*9OP_GDBuIF3OAr83rIOMBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*nOMwxqVYFQ6_wFuBZvqc3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*SYOZm7p2vCPu3YQeBuRS8g.png" /></figure><p>BI Publisher displays the join condition directly on the canvas:</p><pre>G_1.SUBINVENTORY = G_SUBINVENTORY_CODE.MAGASIN</pre><h3>6. The Result: XML Before and After</h3><p><strong>Before</strong> — standard report, group tag present but empty:</p><pre>&lt;G_SUBINVENTORY_CODE&gt;<br>  &lt;SUBINVENTORY_CODE&gt; &lt;/SUBINVENTORY_CODE&gt;<br>  &lt;G_Q_MINMAX&gt;<br>    &lt;ITEM_SEGMENTS&gt;108411&lt;/ITEM_SEGMENTS&gt;<br>    ...<br>  &lt;/G_Q_MINMAX&gt;<br>  &lt;G_Q_MINMAX&gt;<br>    &lt;ITEM_SEGMENTS&gt;108436&lt;/ITEM_SEGMENTS&gt;<br>    ...<br>  &lt;/G_Q_MINMAX&gt;<br>&lt;/G_SUBINVENTORY_CODE&gt;</pre><p>One block. No real grouping. Every item mixed together.</p><p><strong>After</strong> — custom Data Model with a working Data Set Link:</p><pre>&lt;G_1&gt;<br>  &lt;CODE_ORGANISATION&gt;A0011_OL&lt;/CODE_ORGANISATION&gt;<br>  &lt;SUBINVENTORY&gt;SUBINV&lt;/SUBINVENTORY&gt;<br>  &lt;G_SUBINVENTORY_CODE&gt;<br>    &lt;ARTICLE&gt;108411&lt;/ARTICLE&gt;<br>    &lt;DESIGNATION&gt;TESTT&lt;/DESIGNATION&gt;<br>    &lt;MAGASIN&gt;SUBINV&lt;/MAGASIN&gt;<br>    &lt;STOCK&gt;10&lt;/STOCK&gt;<br>    &lt;QUANTITE_COMMANDE_CLIENT&gt;0&lt;/QUANTITE_COMMANDE_CLIENT&gt;<br>    &lt;STOCK_FINAL_DISPONIBLE&gt;10&lt;/STOCK_FINAL_DISPONIBLE&gt;<br>    &lt;QUANTITE_ACHAT_A_VENIR&gt;0&lt;/QUANTITE_ACHAT_A_VENIR&gt;<br>    &lt;PROPOSITION_DE_COMMANDE&gt;0&lt;/PROPOSITION_DE_COMMANDE&gt;<br>  &lt;/G_SUBINVENTORY_CODE&gt;<br>  &lt;G_SUBINVENTORY_CODE&gt;<br>    &lt;ARTICLE&gt;108436&lt;/ARTICLE&gt;<br>    &lt;DESIGNATION&gt;TEST&lt;/DESIGNATION&gt;<br>    &lt;MAGASIN&gt;SUBINV&lt;/MAGASIN&gt;<br>    &lt;STOCK&gt;150&lt;/STOCK&gt;<br>    &lt;QUANTITE_COMMANDE_CLIENT&gt;0&lt;/QUANTITE_COMMANDE_CLIENT&gt;<br>    &lt;STOCK_FINAL_DISPONIBLE&gt;150&lt;/STOCK_FINAL_DISPONIBLE&gt;<br>    &lt;QUANTITE_ACHAT_A_VENIR&gt;0&lt;/QUANTITE_ACHAT_A_VENIR&gt;<br>    &lt;PROPOSITION_DE_COMMANDE&gt;0&lt;/PROPOSITION_DE_COMMANDE&gt;<br>  &lt;/G_SUBINVENTORY_CODE&gt;<br>&lt;/G_1&gt;</pre><h3>7. The Payoff: A Simpler, More Reliable Template</h3><p>With a properly nested XML, the template logic becomes a straightforward nested loop:</p><pre>&lt;?for-each:G_1?&gt;<br>  Subinventory: &lt;?SUBINVENTORY?&gt;<br>  &lt;?for-each:G_SUBINVENTORY_CODE?&gt;<br>     &lt;?ARTICLE?&gt; - &lt;?DESIGNATION?&gt; - &lt;?STOCK?&gt;<br>  &lt;?end for-each?&gt;<br>&lt;?end for-each?&gt;</pre><h3>Conclusion</h3><p>The fix isn’t a template workaround; it’s a Data Model decision. By splitting a single flat dataset into a <strong>parent dataset</strong> (the distinct group values) and a <strong>child dataset</strong> (the detail rows), and connecting them with a <strong>Data Set Link</strong>, BI Publisher builds a genuinely nested XML — one your template can trust.</p><p>This pattern isn’t specific to inventory reports. Any Data Model where you need reliable grouping — by supplier, by legal entity, by cost center, by date — can benefit from the same approach: don’t fight for structure in the template. Build it upstream, in the data.</p><p><em>If you found this useful, feel free to connect or follow for more hands-on Oracle Fusion / OIC / BI Publisher content.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e861171b9aa7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From BI Publisher to SFTP in OIC: Why decodeBase64ToReference() Is All You Need]]></title>
            <link>https://medium.com/@mariagalman2025/from-bi-publisher-to-sftp-in-oic-why-decodebase64toreference-is-all-you-need-107bbebfc38f?source=rss-3e9868785794------2</link>
            <guid isPermaLink="false">https://medium.com/p/107bbebfc38f</guid>
            <category><![CDATA[soap]]></category>
            <category><![CDATA[sftp]]></category>
            <category><![CDATA[oracle-cloud]]></category>
            <category><![CDATA[oracle-bi-publisher]]></category>
            <category><![CDATA[oracle-integration]]></category>
            <dc:creator><![CDATA[Maria Galman]]></dc:creator>
            <pubDate>Thu, 20 Aug 2026 18:52:15 GMT</pubDate>
            <atom:updated>2026-08-20T18:52:15.252Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A field debugging story — and the one function that replaces a Stage File action entirely</em></p><h3>The Setup</h3><p>If you’ve built an Oracle Integration Cloud (OIC) integration that retrieves a report from BI Publisher via RunReportService and needs to push that report to an external SFTP server, you&#39;ve probably hit the same wall I did.</p><p>The flow looks simple on paper:</p><pre>SOAP Invoke (RunReportService) → FTP Write → SFTP</pre><p>But the moment you open the mapper, the “obvious” approach stops working — and the fix isn’t where you’d expect it.</p><h3>The SOAP Response</h3><p>Calling RunReportService via a SOAP invoke returns a response shaped like this:</p><pre>runReportResponse<br> └─ runReportReturn<br>     ├─ reportBytes<br>     ├─ reportContentType<br>     ├─ reportFileID<br>     ├─ reportLocale<br>     └─ metaDataList</pre><p>reportBytes is the report content itself, base64-encoded. It looks like exactly what you need to hand to an FTP Write action. That assumption is where the trouble starts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*FnbRfaz55zmOLTjlnhrX7g.png" /></figure><h3>Part 1 — The Natural Reflex: Mapping reportBytes Directly</h3><p>The first instinct is straightforward: reportBytes is already base64, and the FTP Write operation supports an &quot;opaque&quot; mode when you set schema structure to <em>No</em>. So why not map it straight in?</p><p>Because that’s not actually what the target expects. Even with structure set to <em>No</em>, the FTP Write “Write File” operation exposes this:</p><pre>TransferReport Request (FTP)<br> ├─ File Name<br> ├─ Directory<br> └─ ICS File *<br>     ├─ File Reference *<br>     └─ Properties *</pre><p>File Reference is a <strong>required</strong> field — and it does not accept raw base64 content. This is the detail that trips people up, because nothing in the UI tells you explicitly that these are two different kinds of objects.</p><h3>reportBytes vs. File Reference — What&#39;s Actually the Difference</h3><p><strong>reportBytes</strong></p><ul><li><strong>What it is:</strong> the actual file content, base64-encoded</li><li><strong>Size:</strong> heavy — the entire report, inline</li><li><strong>Where it lives:</strong> in the integration instance’s memory, carried through the payload</li><li><strong>What accepts it:</strong> an opaque/base64Binary element in a mapping</li></ul><p><strong>File Reference</strong></p><ul><li><strong>What it is:</strong> a lightweight pointer to a file already sitting in OIC’s internal stage</li><li><strong>Size:</strong> a few characters — just an identifier</li><li><strong>Where it lives:</strong> in OIC’s staging area, on disk</li><li><strong>What accepts it:</strong> any adapter action built to read from the stage (FTP, Stage File…)</li></ul><p>The reason this distinction exists is architectural: file-oriented adapters in OIC (FTP, Stage File) are designed to <strong>stream from the stage</strong>, not to carry large binary payloads through XSLT transformations. Passing a multi-megabyte base64 string through a mapper works against that design — which is exactly why File Reference is the required field instead of a free opaque node.</p><h3>Part 2 — The False Lead: Stage File “Read Entire File” with a Structured CSV</h3><p>Even after decoding the report with decodeBase64ToReference(), the next reasonable step feels like reading that file back before handing it to the FTP adapter. So the flow becomes:</p><pre>Assign: vDecodeBase64 = decodeBase64ToReference(reportBytes)<br>   → Stage File: Read Entire File (File Reference = vDecodeBase64)<br>   → Map / Invoke: FTP Write</pre><p>In the Stage File action, <strong>Choose Stage File Operation</strong> is set to <strong>Read Entire File</strong>, with <strong>Configure File Reference</strong> set to <strong>Yes</strong>, and vDecodeBase64 supplied as the reference to read.</p><p>It seems like the safe move — the FTP Write needs something concrete to send, so reading the file back first feels like it’s preparing that content properly. But it’s an unnecessary step: the FTP Write action already knows how to consume a File Reference directly, without needing its content read back out beforehand. Adding a Read Entire File action in between just means writing the file, reading it straight back out, and then mapping <em>that</em> output into the FTP adapter — an extra round-trip for content that never needed to leave the stage in the first place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*rHdTxsdYAN5dU9grUJhlxA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uj9f2gX9Zo0BTfHDCC9Rrg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XWKMBwhMf9oXyFZlfexklg.png" /></figure><h3>Part 3 — The Actual Solution: decodeBase64ToReference()</h3><p>The fix turns out to be a single function.</p><p>decodeBase64ToReference() decodes the base64 string <strong>and</strong> returns a usable file reference in one step. No Stage File Write, no Stage File Read, no schema.</p><p><strong>Assign action:</strong></p><pre>vDecodeBase64 = decodeBase64ToReference(reportBytes)</pre><p><strong>FTP Write mapping:</strong></p><pre>ICS File &gt; File Reference = vDecodeBase64</pre><p>That’s the entire bridge between the SOAP response and the FTP adapter. The function itself takes care of writing the decoded content to the stage internally and handing back the reference the FTP Write action is asking for — which is exactly the two-step Stage File dance from Part 2, just done in one call instead of two separate actions plus a schema.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZfA-5gWCOQsME6sKddXvDQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_1Nemi5z_2r9vg3pb6aJpg.png" /></figure><h3>A Quality Guard Before the Transfer</h3><p>One more piece worth keeping in the flow: a Switch condition before attempting the transfer, to skip empty or failed report generations:</p><pre>string-length(reportBytes) &gt;= number(20)</pre><p>If BI Publisher returns an empty or malformed reportBytes (report generation failure, no data, etc.), this avoids pushing a broken or empty file to the SFTP server.</p><h3>Part 4 — The Final Flow</h3><pre>SOAP Invoke (RunReportService)<br>   → Switch: string-length(reportBytes) &gt;= 20<br>        → Assign: vDecodeBase64 = decodeBase64ToReference(reportBytes)<br>        → FTP Write (Binary): File Reference = vDecodeBase64<br>        → File written to SFTP</pre><p>Four steps. No Stage File action. No manually crafted CSV sample. No column mapping to maintain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jv4ozT0oD2IqFZbcS__gwg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*eCrIgvgXjI675RXayO-Dsg.png" /></figure><h3>Proof It Works</h3><p>Running the flow end-to-end in Debug tracing confirms the transfer completes successfully:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-z1OEnc_KCQyDLnNlY9Z9g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oGnCkUYaHBdYRyXioOe3Ug.png" /></figure><h3>Takeaways</h3><ul><li><strong>reportBytes and </strong><strong>File Reference are not interchangeable.</strong> One is content, the other is a pointer — know which one the adapter action in front of you is actually asking for.</li><li><strong>decodeBase64ToReference()</strong> turns a base64 payload into a stage-backed file reference directly — no round-trip needed.</li><li><strong>Add a length or emptiness guard</strong> before triggering a file transfer, so a failed report generation doesn’t silently produce a broken file downstream.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=107bbebfc38f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Case of the Shifting CSV Columns: Why Your BI Publisher Report Output Doesn’t Match Your Query]]></title>
            <link>https://medium.com/@mariagalman2025/the-case-of-the-shifting-csv-columns-why-your-bi-publisher-report-output-doesnt-match-your-query-3f5ad8aa2e27?source=rss-3e9868785794------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f5ad8aa2e27</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[oracle-cloud]]></category>
            <category><![CDATA[oracle-fusion]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[oracle-bi-publisher]]></category>
            <dc:creator><![CDATA[Maria Galman]]></dc:creator>
            <pubDate>Wed, 19 Aug 2026 00:22:09 GMT</pubDate>
            <atom:updated>2026-08-19T00:22:09.554Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A debugging story about NULL values, empty XML tags, and a CSV “column order” that was never actually wrong.</em></p><h3>The Symptom</h3><p>You’ve written a solid SQL query for your Oracle Fusion BI Publisher (BIP) report. It’s a UNION ALL between two data sets, deliberately aligned to return the same five columns in the same order:</p><pre>(<br>    select TO_CHAR(a.SEGMENT1) Child, &#39;PARENT&#39; Parent, b.NAME NAME, null STATUS, a.project_id<br>    from PJF_PROJECTS_ALL_B a, PJF_PROJECTS_ALL_TL b<br>    where a.PROJECT_ID=b.PROJECT_ID<br>)<br>UNION ALL<br>(<br>    select TO_CHAR(a.TASK_ID) Child, b.SEGMENT1 Parent, a.TASK_NAME NAME<br>    , c.NEW_PROJECT_STATUS_CODE STATUS, null project_id<br>    from PJF_TASKS_V  a, PJF_PROJECTS_ALL_B b, PJF_OBJ_STATUS_CHANGES c<br>    where a.PROJECT_ID=b.PROJECT_ID<br>    and a.TASK_ID=c.OBJECT_ID(+)<br>)</pre><p>Five columns, same order, both branches: Child, Parent, NAME, STATUS, PROJECT_ID.</p><p>You run the report. You open the generated <strong>CSV output</strong>. And there it is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*qBaxiuQeto_2cv4a64nnBw.png" /></figure><p>Wait. Where did STATUS go? Worse — on rows coming from Branch 1, PROJECT_ID is showing up in the position where STATUS should be. The query clearly selects STATUS as the fourth column, before PROJECT_ID. But the CSV header comes back as CHILD,PARENT,NAME,PROJECT_ID,STATUS, and every row from Branch 1 ends with a trailing empty value where STATUS should have been.</p><p>The natural — and wrong — conclusion is: <em>“BI Publisher scrambled my column order in the CSV.”</em></p><p>It didn’t. Something simpler, and much more useful to understand, is going on underneath.</p><h3>The Real Culprit: BIP Doesn’t Generate CSV Directly — It Generates XML First</h3><p>Here’s the part that isn’t obvious until you’ve hit it once: BI Publisher’s report output (CSV included) is not produced straight from your SQL result set. The Data Model engine first serializes your query results into an <strong>internal XML document</strong>, and <em>that</em> XML is what the report layout (or the CSV output engine) actually reads from to build the file you download.</p><p>And XML has a default behavior that catches a lot of technical consultants off guard: <strong>an element whose value is NULL is not written to the XML output at all</strong> — unless you explicitly tell the engine to keep it.</p><p>In Branch 1 of the query above, STATUS is hardcoded as null. Every row from that branch has STATUS = NULL. As a result, the &lt;STATUS&gt; tag is silently dropped from the underlying XML for those rows. When the CSV is generated from that XML, there&#39;s no &lt;STATUS&gt; element to pull a value from — so the column simply doesn&#39;t materialize for that row, and everything after it (here, PROJECT_ID) shifts left to fill the gap.</p><p>The column order in the <em>query</em> is fine. The column order in the <em>data model’s structure</em> is fine. What’s actually happening is that one XML tag is missing on certain rows — and since the CSV generator only knows about the tags that exist, it renders a row that’s short one field.</p><p>This is especially easy to miss in UNION ALL scenarios where you&#39;re deliberately padding column counts with NULL literals to align heterogeneous branches (a very common pattern when consolidating several SQL data sets into one report). Some rows will have a real value for a given column, others will have NULL — and only the NULL rows exhibit the &quot;vanishing column&quot; behavior. If you&#39;re spot-checking a handful of output rows, it&#39;s entirely possible to land on a NULL-heavy row, conclude the column mapping is broken, and go down completely the wrong debugging path.</p><h3>How to Actually Diagnose It</h3><p>Don’t debug this from the CSV file itself — by the time you’re looking at the CSV, the damage (missing tag) has already happened one layer upstream. Go check the <strong>raw XML</strong> the Data Model produces, before the CSV generator ever touches it:</p><ol><li>Open your Data Model in BI Publisher.</li><li>Run/view the data set output (<strong>View Data</strong> / <strong>Get XML Output</strong>, depending on your version).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YsKFkDxBLWpAFvqwCisARA.png" /></figure><p>3. Inspect the generated XML directly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MezHerNi80SZ0SRCm0frMg.png" /></figure><p>If a tag is missing on some rows but present on others, you’re looking at exactly this behavior — not a structural or column-mapping problem. Comparing a row from each branch of your UNION ALL makes it obvious fast: the branch where STATUS is a real, non-null value will show &lt;STATUS&gt;...&lt;/STATUS&gt; correctly; the branch where it&#39;s hardcoded NULL won&#39;t show the tag at all.</p><h3>The Fix</h3><p>In the Data Model <strong>Properties</strong> panel, under <strong>XML Output Options</strong>, there’s a checkbox built for exactly this: <strong>Include Empty Tags for Null Elements</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*0hLL6PoStVzmN9ivcx0l9Q.png" /></figure><p>When enabled, every element gets written to the XML even when it has no value — as a self-closing empty tag:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l-EaSrGf6wMgV2Ahfclhsw.png" /></figure><p>instead of being omitted entirely. Once every row carries every tag, in the same position, whether populated or not, the CSV generator has nothing left to guess about — each column lands where it belongs, every time.</p><p>Here’s the property, checked, in the Data Model:</p><p><em>(XML Output Options → Include Empty Tags for Null Elements: checked)</em></p><p>To enable it yourself:</p><ol><li>Open the Data Model.</li><li>Go to <strong>Properties</strong>.</li><li>Under <strong>XML Output Options</strong>, check <strong>Include Empty Tags for Null Elements</strong>.</li><li>Save and regenerate your sample output to confirm — the CSV columns now stay aligned regardless of which branch of the UNION ALL a row comes from.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*UJUnvv_RNNzPB9Spd36b1Q.png" /></figure><h3>Why This Matters Beyond the Immediate Bug</h3><ul><li><strong>CSV/delimited output is exactly where this bites hardest</strong>, because a shifted column in a CSV is silent — no error, no exception, just numbers and codes quietly landing in the wrong field. A PROJECT_ID sitting in a STATUS column downstream can go unnoticed for a while, especially if both happen to be alphanumeric-looking values.</li><li><strong>RTF/Excel templates</strong> that map placeholders by field name are usually safe either way, since the template engine resolves by tag name, not position. The real risk is anywhere output is consumed <strong>positionally</strong> — CSV parsing being the textbook case — or anywhere logic checks for tag presence rather than tag value.</li><li><strong>Intermittent-looking bugs</strong> are the worst kind. A column that’s sometimes there and sometimes not, depending on which branch of a UNION ALL a row came from, is exactly the kind of thing that produces &quot;the file looks fine for most projects but breaks for this one&quot; tickets.</li></ul><h3>Takeaway</h3><p>Before assuming BI Publisher has reordered, dropped, or mismapped a column in your CSV report:</p><ol><li>Check the raw Data Model XML output, not the CSV file itself.</li><li>If a tag is missing only on certain rows, suspect NULL suppression before anything else — especially in UNION ALL data sets with hardcoded NULL placeholder columns.</li><li>Enable <strong>Include Empty Tags for Null Elements</strong> in the Data Model properties if you need a fully predictable, always-present column structure in your output.</li></ol><p>A five-minute look at the raw XML output saves hours of chasing a “column order bug” in a CSV that was never really about column order at all.</p><p><em>Have you run into this while building BI Publisher reports on Oracle Fusion ERP? I’d be curious to hear how it showed up in your own reports — drop a comment.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f5ad8aa2e27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The LEAD_TIME Trap: Finding the Right Column for Blanket and Contract Purchase Order Lines]]></title>
            <link>https://medium.com/@mariagalman2025/the-lead-time-trap-finding-the-right-column-for-blanket-and-contract-purchase-order-lines-cc8f8bbf56e1?source=rss-3e9868785794------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc8f8bbf56e1</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[oracle]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[supply-chain-management]]></category>
            <category><![CDATA[enterprise-software]]></category>
            <dc:creator><![CDATA[Maria Galman]]></dc:creator>
            <pubDate>Sun, 16 Aug 2026 17:45:25 GMT</pubDate>
            <atom:updated>2026-08-16T17:45:25.613Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A practical guide to a column comment that survived unchanged from EBS to Fusion — and a query fragment to get it right the first time.</em></p><h3>1. The natural reflex</h3><p>You’re building a report that needs the delivery lead time for a purchase order line. You search the Purchasing tables, and there it is — LEAD_TIME, sitting right on PO_LINE_LOCATIONS_ALL, exactly where you&#39;d expect it:</p><pre>SELECT<br>    poll.PO_HEADER_ID,<br>    poll.PO_LINE_ID,<br>    poll.LEAD_TIME<br>FROM PO_LINE_LOCATIONS_ALL poll</pre><p>It compiles, it runs, it returns a column called LEAD_TIME. Nothing about the query itself suggests anything is wrong. Most people stop right there and move on to the next requirement.</p><h3>2. What the column actually means</h3><p>Here’s what the column comment says — and it says the same thing in both Oracle E-Business Suite and Oracle Fusion, unchanged:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UDjeZzoNthJ5d6PPUWxFGA.png" /></figure><p><em>[Fusion documentation, </em><a href="https://docs.oracle.com/en/cloud/saas/procurement/25c/oedmp/polinelocationsall-9688.html#Details">https://docs.oracle.com/en/cloud/saas/procurement/25c/oedmp/polinelocationsall-9688.html#Details</a><em>]</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nFKRw_8IWQGVgJhLU85xUA.png" /></figure><p><em>[EBS 12.1.1 eTRM, </em><a href="https://etrm.live/etrm-12.1.1/etrm.oracle.com/pls/et1211d9/etrm_pnavb5d8-2.html">https://etrm.live/etrm-12.1.1/etrm.oracle.com/pls/et1211d9/etrm_pnavb5d8-2.html</a><em>— identical wording, &quot;applies to RFQs and quotations only&quot;]</em></p><p>The same restriction, worded identically, has survived from EBS through to the current Fusion release. LEAD_TIME on this table isn&#39;t a general-purpose &quot;how long does this item take to arrive&quot; field — it&#39;s specifically the lead time tied to a <strong>price break</strong>, and price breaks are a concept that only exists for <strong>RFQs and Quotations</strong>. For every other document type — Standard Purchase Orders, Blanket Purchase Agreements, Contracts — this column is simply not populated for that purpose. Querying it on a Blanket or Contract line doesn&#39;t error out. It just quietly returns NULL.</p><h3>3. Where the real lead time lives for Blanket and Contract lines</h3><p>For document types outside RFQs and Quotations, the delivery lead time at the line level is stored in PO_ATTRIBUTE_VALUES instead — a table documented by Oracle as holding <em>item attributes at the line level</em>. It&#39;s a flexfield-style table (structured around generic ATTRIBUTE1–ATTRIBUTE50 columns behind the scenes), keyed to a purchase order line via PO_LINE_ID, and it&#39;s where line-level item attributes that don&#39;t have a dedicated native column — like lead time for Blanket and Contract lines — actually get stored.</p><h3>4. A ready-to-use query fragment</h3><p>Here’s a simplified, self-contained version — no bind variables, just literal filters you can adapt directly:</p><pre>SELECT<br>    poh.SEGMENT1          AS PO_NUMBER,<br>    poh.TYPE_LOOKUP_CODE  AS PO_TYPE,<br>    pol.LINE_NUM,<br>    pol.ITEM_ID,<br>    poll.LEAD_TIME         AS LEAD_TIME_LOCATIONS,<br>    pav.LEAD_TIME          AS LEAD_TIME_ATTRIBUTE_VALUES<br>FROM PO_HEADERS_ALL poh<br>JOIN PO_LINES_ALL pol<br>    ON pol.PO_HEADER_ID = poh.PO_HEADER_ID<br>LEFT JOIN PO_LINE_LOCATIONS_ALL poll<br>    ON poll.PO_LINE_ID = pol.PO_LINE_ID<br>LEFT JOIN PO_ATTRIBUTE_VALUES pav<br>    ON pav.PO_LINE_ID = pol.PO_LINE_ID<br>WHERE poh.TYPE_LOOKUP_CODE IN (&#39;BLANKET&#39;,&#39;CONTRACT&#39;)</pre><p>Run this side by side with a query against PO_LINE_LOCATIONS_ALL.LEAD_TIME for the same Blanket or Contract lines, and the difference becomes immediately visible: one returns NULL across the board, the other returns the actual delivery lead time the business expects to see.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6_aDndKH1hYYNqMTArgncg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Vt0AuY1EZYsSes3b2MyIw.png" /></figure><h3>5. The generalizable lesson</h3><p>Purchasing tables in Oracle Fusion (and their EBS ancestors) are shared across several document types — RFQs, Quotations, Standard POs, Blanket Agreements, Contracts — and not every column applies to every type. A column name alone won’t tell you that; the scope restriction usually lives only in the column’s comment in the technical reference. Before trusting a column that looks obviously right, it’s worth checking:</p><ul><li>The column comment in Oracle’s official Tables and Views documentation</li><li>Whether that comment mentions a specific document type or scenario</li><li>If it does, and your query targets a different TYPE_LOOKUP_CODE, treat the column as unreliable for your case and look for where that same information is actually stored for your document type</li></ul><p>In this case, that meant moving from a native column that looked right but silently returned nothing, to a flexfield-based table that most people never think to check.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc8f8bbf56e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Oracle BI Publisher Excel Templates by Hand: What the Template Builder Add-in Hides From…]]></title>
            <link>https://medium.com/@mariagalman2025/building-oracle-bi-publisher-excel-templates-by-hand-what-the-template-builder-add-in-hides-from-809f6550f914?source=rss-3e9868785794------2</link>
            <guid isPermaLink="false">https://medium.com/p/809f6550f914</guid>
            <category><![CDATA[oracle-bi-publisher]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[excel]]></category>
            <category><![CDATA[enterprise-software]]></category>
            <category><![CDATA[oracle]]></category>
            <dc:creator><![CDATA[Maria Galman]]></dc:creator>
            <pubDate>Mon, 10 Aug 2026 21:44:36 GMT</pubDate>
            <atom:updated>2026-08-10T21:53:28.691Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building Oracle BI Publisher Excel Templates by Hand: What the Template Builder Add-in Hides From You</h3><p><em>A field guide to the </em><em>XDO_METADATA sheet, Named Ranges, repeating groups, and deep links — built from a real AP invoice report.</em></p><h3>1. Introduction</h3><p>The BI Publisher Template Builder add-in for Excel is the recommended way to build .xls layouts: you connect it to your Data Model, drag fields onto the sheet, mark repeating regions, and it silently generates everything you need behind the scenes — including a hidden sheet called XDO_METADATA that most people never open.</p><p>This article is about what happens when you <em>don’t</em> have the add-in available, or you just want to understand the machinery well enough to debug it when something goes wrong. Everything here comes from building and debugging a real multi-sheet AP Invoice Journal report against Oracle Fusion — Data Model, template, and the actual errors encountered along the way.</p><p>By the end, you’ll know how to:</p><ul><li>Bind a simple field and a repeating group manually, with no add-in involved</li><li>Build the XDO_METADATA sheet from scratch, including the parts the add-in normally hides</li><li>Add clickable deep links into Fusion UI records from an Excel report</li></ul><h3>2. The core mechanism: two layers of indirection</h3><p>A hand-built Excel template relies on a simple but easy-to-miss trick: <strong>a Named Range in Excel and a matching row in the </strong><strong>XDO_METADATA sheet, tied together by a shared technical ID.</strong></p><ul><li>The <strong>Named Range</strong> (Excel’s Name Manager) points to a physical cell or row range in the workbook.</li><li>The <strong>XDO_METADATA row</strong> maps that same technical ID to either a field placeholder (&lt;?FIELD_NAME?&gt;) or an XSL instruction (&lt;xsl:for-each select=&quot;.//G_1&quot;&gt;).</li></ul><p>For a <strong>simple field</strong>, the Named Range points to a single cell:</p><pre>XDO_?XDOFIELD1?  →  &#39;Journal&#39;!$A$6</pre><p>And in XDO_METADATA:</p><pre>XDO_?XDOFIELD1?   |   &lt;?INVOICE_NUMBER?&gt;   |   (empty)</pre><p>For a <strong>repeating group</strong>, the Named Range spans an entire row (from the first to the last column of the dataset):</p><pre>XDO_GROUP_?XDOG1?  →  &#39;Journal&#39;!$A$6:$F$6</pre><p>And in XDO_METADATA:</p><pre>XDO_GROUP_?XDOG1?  |  &lt;xsl:for-each select=&quot;.//G_1&quot;&gt;  |  &lt;/xsl:for-each&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*Czp4LuB0qaL4a_Bdjs0iXA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pfN2TiKv7Sgc1HFbtOcZ6g.png" /></figure><h3>The preamble you can’t skip</h3><p>Here’s the part that catches almost everyone building this by hand: XDO_METADATA isn&#39;t just the mapping table. It needs a specific header block above it — the exact rows the Template Builder add-in generates automatically and that most tutorials never mention:</p><pre>Version                |<br>ARU-dbdrv              |<br>Extractor Version      |<br>Template Code          |<br>Template Type          | TYPE_EXCEL_TEMPLATE<br>Preprocess XSLT File   |<br>Last Modified Date     |<br>Last Modified By       |<br>                        |<br>                        |<br>Data Constraints:       |<br>[... your field/group mappings start here ...]</pre><p>The Template Type = TYPE_EXCEL_TEMPLATE row is the one that matters. Without it, BI Publisher doesn&#39;t recognize the workbook as a valid Excel Template — it silently ignores every Named Range you defined. No error, no warning. Your report just renders with the raw placeholder text still showing, or blank cells.</p><h3>3. Walkthrough: building the mini “AP Invoice Journal” template</h3><p>To make this concrete, here’s a stripped-down version of the report, reduced to what matters for the mechanics.</p><h3>Data Model — two datasets</h3><p><strong>DS_INVOICES</strong> (repeating):</p><pre>SELECT<br>    ai.INVOICE_ID,<br>    xep.LEGAL_ENTITY_IDENTIFIER   AS LEGAL_ENTITY_CODE,<br>    ai.INVOICE_NUM                 AS INVOICE_NUMBER,<br>    hp.PARTY_NAME                  AS SUPPLIER_NAME,<br>    ai.INVOICE_AMOUNT              AS INVOICE_AMOUNT,<br>    TO_CHAR(ai.GL_DATE,&#39;MM/YY&#39;)    AS ACCOUNTING_PERIOD,<br>    (SELECT NAME FROM ASK_APPLICATION_CLOUDS) AS ENV_NAME<br>FROM AP_INVOICES_ALL ai<br>JOIN XLE_ENTITY_PROFILES xep ON xep.LEGAL_ENTITY_ID = ai.LEGAL_ENTITY_ID<br>JOIN HZ_PARTIES hp ON hp.PARTY_ID = ai.PARTY_ID<br>WHERE ai.GL_DATE BETWEEN :P_START_DATE AND :P_END_DATE<br>  AND ai.CANCELLED_DATE IS NULL<br>  AND ROWNUM &lt;= 20</pre><p><strong>DS_PARAMETERS</strong> (a single row):</p><pre>SELECT<br>    TO_CHAR(:P_START_DATE,&#39;DD/MM/YYYY HH24:MI:SS&#39;)  AS P_START_DATE,<br>    TO_CHAR(:P_END_DATE,&#39;DD/MM/YYYY HH24:MI:SS&#39;)     AS P_END_DATE,<br>    TO_CHAR(SYSDATE,&#39;DD/MM/YYYY HH24:MI:SS&#39;)          AS DATE_GENERATION,<br>    SYS_CONTEXT(&#39;USERENV&#39;,&#39;CLIENT_IDENTIFIER&#39;)        AS USER_NAME<br>FROM DUAL</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t0KZCH_SFih8UTM44A-lWA.png" /></figure><h3>The template row</h3><p>The row that gets cloned per record needs a placeholder in every cell:</p><pre>Legal Entity | Invoice Number | Supplier | Invoice Amount | Accounting Period | View Invoice<br>&lt;?LEGAL_ENTITY_CODE?&gt; | &lt;?INVOICE_NUMBER?&gt; | &lt;?SUPPLIER_NAME?&gt; | &lt;?INVOICE_AMOUNT?&gt; | &lt;?ACCOUNTING_PERIOD?&gt; | &lt;?INVOICE_NUMBER?&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VcF-uG5LYNMkFXNnlP67Ww.png" /></figure><h3>4. The hyperlink trick: XDO_LINK_</h3><p>A neat, under-documented feature: you can turn any bound cell into a clickable deep link into Fusion by adding a <em>second</em> Named Range on the same cell, prefixed XDO_LINK_:</p><pre>XDO_?XDOFIELD10?        → &#39;Journal&#39;!$F$6      (the visible value: invoice number)<br>XDO_LINK_?XDOFIELD10?   → &#39;Journal&#39;!$F$6      (same cell, the hyperlink)</pre><p>In XDO_METADATA, the link entry carries an XSL expression that builds the URL from the current row&#39;s context:</p><pre>&lt;xsl:value-of select=&quot;concat(<br>  &#39;https://&#39;,./ENV_NAME,<br>  &#39;.XXXXXXXXXXX.eu/fscmUI/faces/deeplink?objType=AP_VIEWINVOICE&amp;amp;action=VIEW&amp;amp;objKey=InvoiceId=&#39;,<br>  ./INVOICE_ID)&quot;/&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*g_TB3m856GPg43uqa2s0jw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HhQqJjpC514ai5fTrmKywg.png" /></figure><h3>5. Practical checklist / pitfalls</h3><ul><li>Number XDOFIELDn sequentially and uniquely across the <strong>entire workbook</strong>, not per sheet.</li><li>The group name in for-each select=&quot;.//G_x&quot; must match the Data Model&#39;s generated group name character-for-character.</li><li>Escape every &amp; in an XDO_LINK_ URL as &amp;amp;.</li><li>Always round-trip a .xls template through real Excel before uploading — never trust a .xls produced only by a script or converter.</li><li>Read the Diagnostic Log before guessing — the ExcelController and dataengine sections will tell you within seconds whether the problem is in the data, the group mapping, or the binary file itself.</li></ul><h3>6. Conclusion</h3><p>The Template Builder add-in is still the right tool for day-to-day template work — it removes all of this friction. But understanding what it generates behind the scenes turns “the report just doesn’t work” into a diagnosable problem, and it’s the only way to build templates in environments where the add-in isn’t an option.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=809f6550f914" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamic Logos in Oracle BI Publisher: Building a Reusable Subtemplate for Multi-Entity Reports]]></title>
            <link>https://medium.com/@mariagalman2025/dynamic-logos-in-oracle-bi-publisher-building-a-reusable-subtemplate-for-multi-entity-reports-172543f6efc7?source=rss-3e9868785794------2</link>
            <guid isPermaLink="false">https://medium.com/p/172543f6efc7</guid>
            <category><![CDATA[oracle-cloud]]></category>
            <category><![CDATA[oracle-bi-publisher]]></category>
            <category><![CDATA[erp-solutions]]></category>
            <category><![CDATA[oracle-fusion]]></category>
            <category><![CDATA[erp-software]]></category>
            <dc:creator><![CDATA[Maria Galman]]></dc:creator>
            <pubDate>Sat, 08 Aug 2026 21:27:01 GMT</pubDate>
            <atom:updated>2026-08-08T21:27:01.055Z</atom:updated>
            <content:encoded><![CDATA[<p>If you support Oracle Fusion reports for an organization with more than one legal entity, you’ve probably run into this problem at some point: the same report — an invoice, a receipt traveler, a purchase order — needs to display a <em>different</em> logo depending on which company generated the transaction. A logo pasted directly into the RTF template only works for one entity. As soon as a second, third, or fourth legal entity enters the picture, that static image becomes a bug waiting to happen.</p><p>In this article, I walk through how I solved this using a <strong>BI Publisher subtemplate</strong>: a small, reusable RTF component that centralizes the logo-selection logic and can be called from any main template that needs it. The pattern applies to any report where a visual element (logo, stamp, watermark) depends on runtime data.</p><h3>The Problem</h3><p>Picture a report built on a data model that returns transaction data joined with legal entity information — something like this:</p><pre>SELECT rct.trx_number,<br>       rct.customer_trx_id,<br>       rct.legal_entity_id,<br>       xle.legal_entity_identifier AS code_societe,<br>       xle.name                   AS legal_entity_name,<br>       rct.trx_date,<br>       rct.comments<br>FROM   ra_customer_trx_all rct,<br>       xle_entity_profiles xle<br>WHERE  rct.legal_entity_id = xle.legal_entity_id(+)<br>AND    xle.legal_entity_identifier = :p_code_societe<br>ORDER BY xle.legal_entity_identifier</pre><p>The data model exposes CODE_SOCIETE, driven by a bind parameter (p_code_societe). Every row carries the legal entity context needed to decide <em>which</em> logo belongs on the page. The question is: how do you translate that field into the correct image, without duplicating the same conditional block across every report that needs a logo?</p><p>Embedding all the logic directly in the main template works for a single report, but it doesn’t scale — you end up copy-pasting the same if/elseif block (and the same embedded images) into every RTF you maintain. Any time a logo changes, or a new legal entity is onboarded, you have to touch every report individually.</p><h3>Architecture Overview</h3><p>The subtemplate approach separates concerns into three pieces:</p><ol><li><strong>Data Model</strong> — supplies the field the logic depends on (CODE_SOCIETE).</li><li><strong>Subtemplate</strong> (.rtf) — a standalone RTF file containing a named template block (LOGO) with the conditional logic and the embedded images. It&#39;s registered in the BI Publisher catalog as its own object.</li><li><strong>Main Template</strong> — imports the subtemplate and calls it wherever the logo needs to appear.</li></ol><p>Because the subtemplate lives as an independent catalog object, any report can import it and reuse the same logic. Update the subtemplate once, and every report that references it picks up the change automatically.</p><h3>Step 1 — Data Model: Exposing the Legal Entity Context</h3><p>The only requirement on the data model side is that the field driving the logic (here, CODE_SOCIETE) is present in the dataset returned to the template. In the query above, it comes straight from XLE_ENTITY_PROFILES.LEGAL_ENTITY_IDENTIFIER, joined on LEGAL_ENTITY_ID. Nothing exotic — the subtemplate will simply read this field from the current row context.</p><h3>Step 2 — Building the Subtemplate</h3><p>The subtemplate is a plain .rtf file, but instead of ordinary report content, it defines a named, reusable block using the template field code:</p><pre>&lt;?template:LOGO?&gt;<br>&lt;?if:CODE_SOCIETE=&#39;S1&#39;?&gt;<br>  [Logo image for entity S1]<br>&lt;?end if?&gt;<br>&lt;?if:CODE_SOCIETE=&#39;S2&#39;?&gt;<br>  [Logo image for entity S2]<br>&lt;?end if?&gt;</pre><p>Here’s the actual content of the subtemplate — one template block, two if conditions, each wrapping its own embedded logo image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rqJqm-KhNBO_9prnf4C-qA.png" /></figure><p><em>The </em><em>LOGO template block: each </em><em>&lt;?if:CODE_SOCIETE=&#39;...&#39;?&gt; wraps the image for that legal entity, closed with </em><em>&lt;?end if?&gt;, and the whole block ends with </em><em>&lt;?end template?&gt;.</em></p><p>A few practical notes from building this out:</p><ul><li><strong>One </strong><strong>&lt;?template:NAME?&gt; block per subtemplate file.</strong> The name (LOGO in this case) is what the main template will reference later with call-template.</li><li><strong>Images are embedded directly in the RTF</strong>, not linked externally — this keeps the subtemplate self-contained and avoids dependencies on external URLs or UCM references that can break across environments.</li><li><strong>Conditions are evaluated against the current data context</strong> at the point where call-template is invoked in the main template, so the field (CODE_SOCIETE) must be in scope there.</li><li>Consider adding a fallback branch (e.g., an &lt;?else?&gt; with a default/neutral logo) so the report doesn&#39;t render blank if an unexpected entity code shows up — a small safeguard that saves a support ticket later.</li></ul><h3>Step 3 — Registering the Subtemplate in the Catalog</h3><p>This is the step that trips people up, because the naming convention is easy to misread. In the BI Publisher catalog, you create a <strong>Sub Template</strong> object (not a regular report template) and upload the actual file:</p><ul><li><strong>Template File:</strong> SubTemplate01.rtf</li><li><strong>Template Type:</strong> rtf</li><li><strong>Locale:</strong> English (or your default locale)</li></ul><p>The file you upload is a genuine .rtf — there&#39;s no .xsb file sitting on your disk anywhere. The .xsb extension only appears later, in the <em>reference path</em> used by the import instruction in the main template. It&#39;s BI Publisher&#39;s internal convention for pointing at a compiled subtemplate object in the catalog, not the extension of the file you actually uploaded. Once you understand that distinction, the wiring in the next step stops being confusing.</p><h3>Step 4 — Wiring the Subtemplate into the Main Template</h3><p>Back in the main template, two field codes do the work. First, the import, placed once near the top of the template (this doesn’t render anything visible — it just loads the subtemplate definitions):</p><pre>&lt;?import:xdoxsl:///Custom/Financials/LogoSubTemplate.xsb?&gt;</pre><p>The path mirrors where the Sub Template object lives in the BI Publisher catalog. Then, wherever the logo should actually appear on the page:</p><pre>&lt;?call-template:LOGO?&gt;</pre><p>In practice, this call sits inside the report’s data loop — in this case a for-each over the legal entity group (G_LE) — so that CODE_SOCIETE is actually in scope when the if conditions inside the subtemplate are evaluated:</p><pre>&lt;?for-each:G_LE?&gt;<br>  &lt;?call-template:LOGO?&gt;<br>  CODE_SOCIETE<br>  LEGAL_ENTITY_NAME<br>  ...<br>&lt;?end G_LE?&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cxHAU9AcDr7YB4vcoYsF5g.png" /></figure><p><em>The import sits once near the top of the template; </em><em>call-template:LOGO is invoked inside the </em><em>for-each G_LE loop, right where </em><em>CODE_SOCIETE is available in the data context.</em></p><p>At render time, BI Publisher resolves the LOGO block from the imported subtemplate, evaluates the if conditions against the current row&#39;s CODE_SOCIETE, and drops in the matching logo image.</p><h3>Result</h3><p>Running the same report with different values for p_code_societe confirms the subtemplate logic is doing its job — same layout, same data structure, different logo pulled in automatically based on the legal entity context:</p><p><em>p_code_societe = S0011 → the entity&#39;s associated logo is rendered.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8p_Ws9xMTI1byVhzNfM2eQ.png" /></figure><p><em>p_code_societe = S0069 → a different legal entity, a different logo, with zero changes to the main template.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ztMk0H_ylPuIfBZaZXKsg.png" /></figure><p>No manual switching, no duplicated templates per entity — just one report definition and one subtemplate driving the branding.</p><h3>Testing &amp; Common Pitfalls</h3><p>A few issues worth checking if the logo doesn’t show up as expected:</p><ul><li><strong>Catalog path mismatch.</strong> The path in &lt;?import:xdoxsl:...?&gt; must exactly match where the Sub Template object sits in the catalog folder structure. A typo here fails silently or throws a template-loading error rather than a clear &quot;file not found.&quot;</li><li><strong>Field out of scope.</strong> If call-template is invoked outside the context where CODE_SOCIETE is available (e.g., outside the data loop that carries it), the if conditions have nothing to evaluate against and no branch will match.</li><li><strong>XML parsing errors on preview.</strong> Malformed conditional syntax inside the subtemplate (unmatched &lt;?if?&gt;/&lt;?end if?&gt;, stray characters introduced by Word&#39;s autocorrect) tends to surface as generic XML parsing failures at render time — always preview the subtemplate content directly before wiring it into a larger report to isolate whether the problem is in the subtemplate or the main template.</li><li><strong>Missing default branch.</strong> Without a fallback, any CODE_SOCIETE value not explicitly handled renders no logo at all, which can look like a bug rather than an unhandled case.</li></ul><h3>Why This Matters</h3><p>The subtemplate pattern isn’t just about logos — it’s a general technique for <strong>factoring out repeated presentation logic</strong> across BI Publisher reports. Anywhere multiple reports need the same conditional block (a legal disclaimer that varies by country, a signature block that depends on approval status, a stamp tied to document type), the same import/call-template structure applies. Centralizing that logic in one catalog object means:</p><ul><li><strong>One place to update</strong> when a legal entity’s branding changes or a new entity is added.</li><li><strong>Consistency</strong> across every report that pulls from the same subtemplate — no risk of one report’s logo block drifting out of sync with another’s.</li><li><strong>Cleaner main templates</strong>, since the conditional bulk lives in a dedicated object instead of cluttering the report’s core layout.</li></ul><p>It’s a small piece of BI Publisher’s toolkit, but it’s the kind of pattern that pays for itself the first time a company rebrands or a new subsidiary is onboarded — you touch one file instead of a dozen.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=172543f6efc7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>