---
article_id: KB0406794
article_type: FAQ
component_ids:
  - BNS-ARI-CI-FND-PRT
component_descriptions:
  - SAP Integration Suite, managed gateway > Managed Gateway Foundation & Tools > Managed Gateway for Managed Gateway Portal
products:
  - SAP Integration Suite, managed gateway for spend management and SAP Business Network
personas:
  - Buyer
language: en
created: 2022-10-31
updated: 2026-05-07
source: Knowledge Base
url: https://support.ariba.com/item/view/KB0406794
connect_url: https://support.ariba.com/item/view/KB0406794?min=1
sap_for_me_url: https://me.sap.com/notes/KB0406794
---

# How to use the For-Each function on the Managed Gateway for Spend&Network Mapping Tool?

## Symptom

How to use the For-Each function on the Managed Gateway for Spend&Network Mapping Tool?

## Resolution

The For-Each function works as a loop in the mapping. Follow the steps below to perform the mapping:

1. Click in the repeatable segment on the target structure with the right button.
2. Select **For-Each**.
3. Select the repeatable segment on the source structure.
4. Save the mapping.

It is also possible to perform an Inner Loop on the **For-Each** by adding a **Target Position Variable** into it. For this, please follow the steps below:

1. Right-click on the **For-Each** line.
2. Click **Target Variable** > **Add Position Variable**.
3. Click the parent field of the target field.
4. Repeat step 1 and click **Add Source Condition**.
5. Place the condition on the respective parent field on the source structure.
6. Click **Position Variable** > **OK**.

A source condition can also be set to trigger the For-Each. For this, please follow the steps below:

1. Right-click on **For-Each** line.
2. Click on **Add Condition to For-Each**.
3. Select the segment desired on the Source structure.
4. Set the condition based on the business need.
5. Click **OK**.

Please note that the **For-Each** function's purpose is to create new repeatable structures, and not to update the existing values of a looped structure. This means that the **For-Each** will be recommended only for non-standardly repeated segments (e.g., PO\_EXTENSIONIN/item for PurchaseOrderExportRequest). If the structure needed is already repeated by the standard mapping (e.g., PO\_ITEMS/item for PurchaseOrderExportRequest), then the Position/Variable loop should be used instead. [https://help.sap.com/docs/sisgw/sap-ariba-cloud-integration-gateway-configuration-guide/adding-target-variables](https://help.sap.com/docs/sisgw/sap-ariba-cloud-integration-gateway-configuration-guide/adding-target-variables)

## See Also

For more information about how to perform the **Target Variables** loop, please refer to the following resources:

[3180750 - How to use the position looping functionality in SAP Integration Suite, Managed Gateway for Spend Management and SAP Business Network Mapping](https://me.sap.com/notes/0003180750)[Tool?](https://me.sap.com/notes/0003180750)[https://me.sap.com/notes/0003180750](https://me.sap.com/notes/0003180750)

SAP Help Portal > SAP Integration Suite, Managed Gateway for Spend Management and SAP Business Network > SAP Integration Suite, Managed Gateway for Spend Management and SAP Business Network Configuration Guide > Managing Custom Mappings > Editing Custom Mappings > *[Adding Target Variables | SAP Help Portal](https://help.sap.com/docs/sisgw/sap-ariba-cloud-integration-gateway-configuration-guide/adding-target-variables)*

## Keywords

Cig, mapping tool, for each, loop, looping, variable, target variable, position, target position, repeat
