To pass parameters to Xtract components in Alteryx, you can use a batch macro that contains a workflow with control parameters.
The following example shows how to parameterize the Xtract ODP component.
Note: As of now, the parameterization using batch macros and control parameters is only supported for the components Xtract BAPI, Xtract ODP and Xtract Table.
Create an Extraction #
The goal of this example is to parameterize a selection filter for the DataSource 0MATERIAL_ATTR, so that only materials with a material number between the parameters p_MATNR_low and p_MATNR_high are extracted.
- Open a new workflow and create an Xtract ODP extraction.
- Look up the DataSource 0MATERIAL_ATTR.
- Create 2 new runtime parameters of type String and name them p_MATNR_low and p_MATNR_high.
- Assign the parameters as selection filters to the column MATNR, so that only materials with numbers between p_MATNR_low and p_MATNR_high are included in the result data.
For more detailed information on how to create an ODP extraction, see Define an ODP Extraction.
Create a Batch Macro with Control Parameters #
- Create a new workflow that contains an extraction as described in Create an Extraction.
- To use the worklow as a batch macro, navigate to the Workflow Configuration and select Batch Macro as the Workflow Type from drop down list.
- Save the file. Once the workflow is saved as a batch macro each tool in the workflow gets a lightning bolt anchor. Only Interface Tools can connect to these anchors.
- Add a Control Parameter tool from the Interface toolbox and label the parameter e.g., name one cp_MATNR_low and another cp_MATNR_high to differentiate between the two (1).
- Connect the Control Parameter tools to the Xtract component. This creates the Action tool Update Value (2).
- To assign the control parameters to an Xtract parameter, select an Update Value tool and mark the Xtract parameter in the tree menu Value or Attribute to Update (3). For this example, assign the control parameter cp_MAKT_low to the Xtract ODP runtime parameter p_MATNR_low and cp_MAKT_high to p_MATNR_high.
- Drag&Drop the Macro Output tool from the Interface toolbox onto the canvas to create an output for the batch macro (4).
- Save the macro.
Note: To use formulas with parameters, select Update Value with Formula from the drop-down list Select an action type in the Action Configuration menu. Enter a formular directly into the Formula field at the bottom of the menu or click […] to open a formula editor.
Parameterizing Components without Runtime Parameters
Some Xtract components don’t use runtime parameters, but have other settings available for parameterization in the Action Configuration menu.
Example: Parameterizing a WHERE-clause of an Xtract Table component
- To parameterize a WHERE-clause, mark the WHERE-clause in the tree menu Value or Attribute to Update.
- To parameterize only parts of a WHERE-clause, activate Replace a specific string and specify what part of the WHERE-clause is to be replaced e.g., in the WHERE-clause
KNA1~LAND1 = 'param'“param” can be used as a placeholder for the actual input.
Integrate the Batch Macro into a Workflow #
This example uses the Text Input tool to define the parameters for the extraction.
- Add a Text Input tool to define the the input for the batch macro. Enter valid parameter values and add a new column for every control parameter (1).
Beispiel: 000000000000000023 as input for p_MATNR_low and 000000000000000100 as input for p_MATNR_high.
- To import the batch macro right-click the canvas and navigate to Insert > Macro. Add the macro that contains the Xtract component.
- Connect the Text Input to the batch macro (2).
- Select the batch macro (2) and use the drop-down list Choose field to assign the values from the Text Input columns to the control parameters of the batch macro.
- Add the Browse tool (3) to check the results of the batch macro and run the workflow.