Enevoldsen
ServiceNow Employee

Overview

This pattern applies specifically to ERP model operations where the entity type is a BAPI. BAPI operations often require one or more input tables, and when a table needs to contain multiple rows, each row must be added individually.

 

The Flow Designer action 'Prepare ERP Data access input table values' adds one row to a BAPI input table per call. When the number of rows is driven by data available at runtime, you call it repeatedly inside a For Each loop, building up the table row by row with each iteration.

Once the loop completes, the Flow Designer action 'Construct final table output'  finalizes the table structure and makes it ready to pass to Flow Designer action 'Use ERP Data'.

 

When to use this pattern

Use this pattern when:

  • Your ERP model operation uses a BAPI as its entity type
  • The BAPI requires an input table with one or more rows

If your BAPI input table only ever needs a single row, you can call 'Prepare ERP Data access input table values' once without a loop and use 'Use ERP Data' directly, otherwise pass the result to 'Construct final table output', before calling 'Use ERP Data' .

 

Flow structure

[For Each loop — iterates over the rows to add to the BAPI input table]
  - Prepare ERP Data access input table values    (adds one row per iteration)
  - Set Flow Variable                             (captures output to JSON var)
[End loop]

Construct final table output                      (called once, after loop)
Use ERP Data                                      (receives finalized input)

 

 

Step 1: Call Prepare inside the For Each loop

In your flow, set up a For Each loop that iterates over the items you want to add as rows to the BAPI input table.

Inside the loop, call 'Prepare ERP Data access input table values' for the current iteration, passing the field values for that row.

After the Prepare action, add a Set Flow Variable step. Use the following script to capture the accumulated output into a JSON flow variable:

return fd_data._2__erp_data_access_input_value_prepare.output;

Adjust the reference name (_2__erp_data_access_input_value_prepare) to match the auto-generated step name in your flow. Each iteration appends a new row to the table in the JSON object, so the variable grows across loop iterations rather than being replaced.

 

Step 2: Call Construct final table output after the loop

Once the For Each loop completes, add 'Construct final table output' to your flow. Map the inputs as follows:

Input Value
ModelName Your ERP model name
ModelOperation The BAPI operation you are calling
TableName The name of the BAPI input table you have been populating
table The JSON flow variable accumulated during the loop

The output of this action is the fully assembled BAPI input structure expected by Use ERP Data.

 

Step 3: Pass the output to Use ERP Data

Add the Use ERP Data action after 'Construct final table output'. Use the output from the Construct action as the input to your BAPI model operation call.

 

Why this pattern works

BAPI function calls in Zero Copy Connector for ERP often require input tables with a variable number of rows. E.g. a goods movement BAPI might receive a line items table where the number of lines depends on what is being processed. The Prepare action appends one row to the table structure per call, so running it inside a For Each loop builds the complete table row by row.

The Construct final table output action then validates the structure, ensuring the JSON passed to Use ERP Data is well-formed even if the table ended up empty.

Calling Construct inside the loop would reset the structure on each iteration. It belongs outside the loop, called exactly once when all rows have been added.