Introduction
In modern Oracle Cloud integrations, data rarely arrives as a single record. Most real-world integrations process multiple records in arrays or repeating structures—for example employee lists, invoice lines, purchase order items, or payroll entries. To handle such scenarios effectively, developers must use the For Each Loop in Oracle Integration Cloud (OIC).
The For Each Loop in OIC is a core orchestration capability that allows an integration to iterate through repeating elements in a payload and process each element individually. This capability becomes critical when working with APIs, file-based integrations, REST responses, or SOAP payloads that contain collections.
In Oracle Integration Cloud Gen 3, the For Each action provides improved performance handling, clearer payload iteration mapping, and better debugging visibility through the integration tracking framework.
From an implementation consultant’s perspective, understanding how to correctly design and implement For Each Loop in OIC prevents common issues like incorrect payload processing, partial transactions, or inefficient integrations.
In this article, we will explore the complete implementation approach to using For Each Loop in OIC, including architecture, step-by-step configuration, real-world examples, troubleshooting, and expert best practices.
What is For Each Loop in Oracle Integration Cloud?
The For Each Loop in OIC is an orchestration action used inside an integration flow to process each element of a repeating structure (array) sequentially.
When an integration receives a payload with multiple records, the For Each action allows the integration to:
-
Iterate through each record
-
Execute actions for each record
-
Map data individually
-
Call external services for each element
-
Apply conditional logic
Example Payload
Consider a REST API returning a list of employees:
If we need to process each employee record individually—such as creating records in another system—we use a For Each Loop.
The loop will process:
| Iteration | Employee |
|---|---|
| 1 | John |
| 2 | Sara |
| 3 | David |
Inside each iteration, the integration performs actions like:
-
Calling an API
-
Writing to a file
-
Transforming data
-
Performing validation
Real-World Integration Use Cases
In real Oracle Cloud projects, For Each Loop in OIC appears frequently in integration designs.
1. Employee Data Synchronization (HCM → External System)
A common integration involves extracting employees from Fusion HCM REST API and sending them to a third-party payroll system.
Flow:
-
Call HCM API to retrieve employees
-
Use For Each Loop
-
Process each employee
-
Send employee record to payroll system
This ensures each employee record is processed individually.
2. Purchase Order Line Processing (Procurement Integration)
In procurement integrations, a purchase order often contains multiple line items.
Example payload:
| PO Number | Line Number | Item |
|---|---|---|
| PO1001 | 1 | Laptop |
| PO1001 | 2 | Monitor |
| PO1001 | 3 | Keyboard |
Integration Flow:
-
Receive purchase order payload
-
Loop through PO lines
-
Send each line to warehouse system
3. File Processing Integration (CSV/Flat File)
When processing large data files, the file may contain hundreds of records.
Example scenario:
A supplier uploads a file containing invoice data.
Integration flow:
-
Read file from SFTP
-
Parse file
-
Loop through each record
-
Create invoice in ERP
The For Each Loop ensures each record is processed independently.
Architecture / Technical Flow
Below is the typical architecture when implementing For Each Loop in OIC.
Integration Flow Structure
Technical Execution Logic
| Step | Description |
|---|---|
| Trigger | Integration receives payload |
| Identify repeating node | Array element selected |
| Loop execution | For Each processes elements |
| Individual processing | Actions executed for each record |
| Completion | Loop ends after last element |
Prerequisites
Before implementing For Each Loop in OIC Gen 3, ensure the following are configured:
1. Access to Oracle Integration Cloud Gen 3
You must have:
-
Developer role
-
Integration Designer privileges
2. Connection Setup
Connections may include:
| Connection Type | Purpose |
|---|---|
| REST Adapter | API integrations |
| SOAP Adapter | SOAP services |
| FTP Adapter | File processing |
| Oracle ERP Adapter | ERP integrations |
| Oracle HCM Adapter | HCM integrations |
3. Source Payload with Repeating Elements
The source payload must include:
-
Array or repeating nodes
-
JSON array or XML repeating element
Example:
4. Integration Type
For Each is supported in:
-
App Driven Orchestration
-
Scheduled Integrations
-
Basic Routing Integrations
Step-by-Step Build Process
Now let’s implement a For Each Loop in OIC using a practical example.
Scenario:
Retrieve employee list and process each employee.
Step 1 – Create Integration
Navigate to:
Select:
Enter:
| Field | Value |
|---|---|
| Integration Name | Process Employees |
| Identifier | process_employees |
Click Create.
Step 2 – Configure Trigger
Add a REST Trigger Adapter.
Example operation:
Example request payload:
This payload contains a repeating node called employees.
Step 3 – Add For Each Action
From the Actions palette, drag For Each into the integration flow.
Configuration screen appears.
Configure Loop Parameters
| Field | Description |
|---|---|
| Repeating Element | employees |
| Current Element | employee |
| Loop Name | ProcessEmployeeLoop |
Explanation:
-
Repeating Element → array node
-
Current Element → variable representing current iteration
Step 4 – Process Data Inside Loop
Inside the loop, you can add multiple actions.
Typical actions include:
-
Assign
-
Map
-
Invoke API
-
Switch conditions
Example:
Invoke external API for each employee.
Example Mapping
| Source | Target |
|---|---|
| employee.id | target.employeeId |
| employee.name | target.employeeName |
Step 5 – Add Invoke Action
Inside the loop:
Add Invoke REST Adapter.
Purpose:
Send employee data to external system.
Example endpoint:
Payload example:
Each iteration sends one employee.
Step 6 – Save and Activate Integration
Click:
The integration is now ready.
Testing the Technical Component
Testing ensures that the For Each Loop processes all elements correctly.
Test Payload
Expected Behavior
| Iteration | Employee |
|---|---|
| 1 | John |
| 2 | Sara |
| 3 | David |
For each iteration:
-
API invocation occurs
-
Data mapping executes
-
Response logged
Monitoring Execution
Navigate to:
Here you can verify:
-
Loop execution
-
Payload processing
-
Success or failure
Common Errors and Troubleshooting
Even experienced developers encounter issues while implementing loops.
1. Incorrect Repeating Element
Error:
Cause:
Wrong element selected.
Solution:
Verify the repeating node path.
2. Payload Mapping Failure
Error:
Cause:
Incorrect variable mapping inside loop.
Solution:
Use Current Element variable.
Example:
3. Large Payload Performance Issues
When payload contains thousands of records, loop execution may slow down.
Solutions:
-
Use batch integrations
-
Process records in smaller chunks
-
Use asynchronous integrations
4. Nested Loop Errors
Some payloads contain multiple nested arrays.
Example:
You may need multiple nested For Each loops.
Best Practices for Using For Each Loop in OIC
Experienced Oracle consultants follow several best practices.
1. Keep Loop Logic Simple
Avoid complex transformations inside loops.
Instead:
-
Pre-process data
-
Simplify mappings
2. Avoid Large Payload Processing
When processing thousands of records:
-
Use parallel integrations
-
Split payload into batches
3. Log Loop Activity
Use tracking variables to monitor loop progress.
Example:
This improves troubleshooting.
4. Handle Exceptions Inside Loop
If one record fails, the entire integration should not stop.
Use:
-
Scope action
-
Fault handlers
5. Avoid Unnecessary Nested Loops
Nested loops increase processing time.
Instead:
-
Flatten payload
-
Use transformation logic
Real Implementation Scenario
Let’s consider a real Oracle Cloud project.
Customer Master Synchronization
Integration requirement:
Sync customer data from Oracle ERP Cloud to CRM system.
Payload:
| Customer | Contacts |
|---|---|
| ABC Corp | 3 |
| XYZ Ltd | 2 |
Integration design:
-
Fetch customer data
-
Loop through customers
-
Loop through contacts
-
Send contact to CRM
Architecture:
This design ensures every contact record is synchronized.
FAQ
1. When should we use For Each Loop in OIC?
Use For Each Loop whenever a payload contains repeating elements or arrays that must be processed individually.
Examples include employee lists, invoice lines, purchase order lines, or file records.
2. Can we use nested For Each loops in OIC?
Yes. Nested loops are supported and often used when payloads contain multi-level repeating structures such as orders → lines → shipments.
However, excessive nesting may impact performance.
3. Does For Each Loop support parallel processing?
The standard For Each loop processes elements sequentially. For parallel processing, integrations must be redesigned using asynchronous patterns or integration batching.
Summary
The For Each Loop in OIC is one of the most important orchestration actions used in real Oracle Cloud integrations. It enables integrations to process repeating data structures such as arrays, file records, or transaction lines efficiently.
In Oracle Integration Cloud Gen 3, the loop functionality is more stable, easier to configure, and better integrated with monitoring and tracking tools.
Key takeaways for implementation consultants:
-
Use For Each when processing arrays or repeating nodes
-
Carefully select repeating elements
-
Keep loop logic lightweight
-
Monitor execution using integration tracking
-
Handle errors inside loop scopes
When implemented correctly, For Each Loop ensures integrations remain scalable, maintainable, and aligned with enterprise integration patterns.
For deeper technical guidance and architecture details, Oracle documentation provides extensive reference materials. Readers can explore official Oracle resources here: