Friday, March 20, 2026

OIC - Handling Complex Stub and Payment Mapping in Oracle Integration Cloud (OIC)

Introduction

In real-time file-based integrations using Oracle Integration Cloud (OIC), handling relationships between Stub Records and Payment Records can become tricky.

A common scenario:

  • One Stub → Multiple Payments
  • Multiple Stubs → One Payment

This blog explains how to handle such complex mappings using XSLT logic inside OIC.


Problem Statement

From the source file:

  • We receive a structure containing:
    • StubRecord
    • PaymentRecord

But the relationship is not always 1:1:

  • Sometimes 1 Stub → Multiple Payments
  • Sometimes Multiple Stubs → 1 Payment

We need to: ✔ Match records using Transaction Number
✔ Ensure correct mapping between Stub and Payment
✔ Avoid duplication or data mismatch


Approach

Step 1: Iterate Over Payment Records

We start by looping through each Payment Record:

<xsl:for-each select="Payments/PaymentRecord">

Step 2: Check Matching Stub Count

We check how many Stub Records match the current Payment using Transaction Number:

count(StubRecord[TransactionNumber = current()/TransactionNumber])

Step 3: Conditional Logic (1:1 vs Multiple)

Case 1: 1 Stub ↔ 1 Payment

If count = 1:

  • Direct mapping is done
  • Simple and straightforward
<xsl:when test="count(...) = 1">

✔ Map fields directly
✔ No extra handling required


Case 2: Multiple Mapping Scenario

If count > 1:

  • Either:
    • One Payment → Multiple Stubs
    • Multiple Payments → One Stub

๐Ÿ‘‰ Here we handle carefully using variables


Step 4: Store Payment Info in Variable

We store payment-related data in variables so it can be reused:

<xsl:variable name="paymentAmount" select="PaymentAmount"/>
<xsl:variable name="transactionNumber" select="TransactionNumber"/>

This helps in: ✔ Avoiding repeated calculations
✔ Reusing values across multiple stub mappings


Step 5: Loop Through Stub Records

Now, iterate through matching Stub Records:

<xsl:for-each select="StubRecord[TransactionNumber = $transactionNumber]">

Inside this loop:

  • Map stub-specific fields
  • Use stored payment variables

Step 6: Final Mapping Strategy

Scenario Logic
1 Stub → 1 Payment Direct mapping
1 Stub → Multiple Payments Loop Payments
Multiple Stubs → 1 Payment Store Payment in variable, loop Stubs
Multiple ↔ Multiple Combine filtering + variables

Key Highlights

✔ Use current() for correct context reference
✔ Use count() to identify mapping scenarios
✔ Use xsl:variable to store reusable values
✔ Always filter using Transaction Number


Sample Logic Summary

<xsl:template match="/">

  <Target>

    <!-- Loop Payment Records -->
    <xsl:for-each select="ReadResponse/Payments/PaymentRecord">

      <xsl:variable name="txn" select="TransactionNumber"/>

      <Record>

        <!-- Payment Info -->
        <PaymentTxn>
          <xsl:value-of select="$txn"/>
        </PaymentTxn>

        <PaymentAmount>
          <xsl:value-of select="PaymentAmount"/>
        </PaymentAmount>

        <!-- Loop matching Stub Records -->
        <xsl:for-each select="/ReadResponse/Payments/StubRecord[TransactionNumber = $txn]">

          <Stub>

            <StubAccount>
              <xsl:value-of select="StubAccountNumber"/>
            </StubAccount>

            <StubAmount>
              <xsl:value-of select="StubAmount"/>
            </StubAmount>

          </Stub>

        </xsl:for-each>

      </Record>

    </xsl:for-each>

  </Target>

</xsl:template>


Conclusion

Handling complex relationships between Stub and Payment records requires:

  • Smart use of XSLT looping
  • Conditional checks using count()
  • Efficient reuse using variables

By implementing this approach, you can: ✔ Ensure accurate 1:1 mapping
✔ Handle multiple scenarios seamlessly
✔ Avoid duplication and mismatches


Pro Tip ๐Ÿ’ก

Always validate your mapping with:

  • Single record case
  • Multiple record case
  • Edge cases (missing or unmatched Transaction Numbers)


Thursday, March 12, 2026

OIC - Converting UTC DateTime String to Hong Kong Time in Oracle Integration Cloud

When integrating systems in Oracle Integration Cloud (OIC), it is common to receive date-time values in UTC format as strings from source systems. Sometimes downstream systems require the date-time in a different timezone, such as Hong Kong Time (HKT).

In this blog, we will see how to convert a UTC datetime string into Hong Kong time using XPath functions inside OIC.

Problem Statement

The source system sends a datetime value in UTC format as a string:

2026-01-29T10:00:00Z

But the target system expects the time in Hong Kong timezone (UTC +8).

So we need to:

  • Convert the string to xsd:dateTime
  • Adjust the timezone to +8 hours
  • Format the output datetime.

Solution

We can use the XPath functions adjust-dateTime-to-timezone and format-dateTime.

XPath Expression

xp20:format-dateTime(

   fn:adjust-dateTime-to-timezone(

      xsd:dateTime("2026-01-29T10:00:00Z"),

      xsd:dayTimeDuration("PT8H")

   ),

   "[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01]Z"

)

Explanation

1. Convert String to DateTime

xsd:dateTime("2026-01-29T10:00:00Z")

This converts the string value into an XML datetime format.

2. Adjust Timezone

fn:adjust-dateTime-to-timezone(... , xsd:dayTimeDuration("PT8H"))

PT8H means plus 8 hours

Hong Kong timezone is UTC +8

So the system adjusts the time accordingly.

Example:

UTC Time

Hong Kong Time

2026-01-29T10:00:00Z

2026-01-29T18:00:00

3. Format the Output

xp20:format-dateTime(...,"[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01]Z")

This formats the datetime into a standard ISO format.

Output:

2026-01-29T18:00:00Z

When to Use This

This approach is useful when:

Source system sends UTC timestamps

Target system expects local timezone

Integration logic is implemented in OIC mapper expressions

Typical scenarios include:

ERP integrations

HR systems

Global payroll or workforce systems

Cross-region API integrations

Key Takeaways

OIC supports timezone manipulation using XPath functions.

adjust-dateTime-to-timezone helps convert UTC to any timezone.

PT8H represents 8 hours offset for Hong Kong time.

Always convert string → xsd:dateTime before timezone adjustment.


Featured Post

OIC - Handling Complex Stub and Payment Mapping in Oracle Integration Cloud (OIC)

Introduction In real-time file-based integrations using Oracle Integration Cloud (OIC), handling relationships between Stub Records and Pa...