Back to

Advanced mapping

Setting conditions: IF statements

Conditional Run statements can provide additional control over the way data is uploaded into SAP. Conditional Run perform at a field level to set conditions for executing the selected portions of the TRANSACTION script. Conditional Run statements can be inserted around a single row or a block of rows. You may add multiple Conditional Run blocks, as long as they do not interfere with any other existing Conditional Run blocks.

Every cell belonging to the specified column is checked against the specified constant value. When the Conditional Run is performed, TRANSACTION executes only the row for which the given condition holds true.

For example, when column H is compared to the word “Credit”, then TRANSACTION perform the actions contained within the IF condition only when the condition is true. In this case, a value of H is uploaded to the D/C Column of the FB50 transaction.

NOTE: The comparison of the constant value specified in the Conditional Run statement with the value in an Excel column depends upon the Data read preferences Microsoft Excel defaults. See “Application Defaults” for more information.

For example, suppose column D of your Excel worksheet contains a decimal value and TRANSACTION needs to execute only those rows that contain the value 3.141 (value of PI) in column D. In this case, column D is formatted to show numbers only up to one decimal place, but internally column D stores up to three decimal places. If the Data read preferences is set to As stored, the condition required will be "D=3.141". However, if this option is set to As displayed, the condition required will be "D=3.1".

A Conditional Run command in the Mapper is equivalent to using a +IF SHUTTLEScript command.

Adding Conditional Run statements

The If Conditional Properties dialog box settings are:

Start Row/End Row: Type the Start Row and End Row you want to use, if other than the row or range of rows you initially selected on the Expert Tab: Recording Preview.

Else Row: Type the Else row where you want to store the If-Else row value.

IF first transaction: This setting is used to address SAP transactions in which dialog boxes, for example, occur only once on the first transaction record. Click this setting to execute the rows specified for the IF first transaction condition on the first record in the data source. For example, when the Classification View for a material is being changed, the Class Type dialog box pops up on the first record only, but not on any subsequent records.

IF NOT first transaction: Similar to the IF first transaction setting, this condition is used to address SAP transactions in which dialog boxes, for example, occur after the first transaction. Click this setting to execute the rows specified for the IF NOT first transaction condition on all records after the first record in the data source.

IF on SAP field: Similar to IF condition. Condition applies only to SAP fields that are enabled. It can apply to disabled fields only if their corresponding screen is enabled in the mapper. However, IF on SAP cannot apply to SAP input fields. IF on SAP is not available in batch mode recording.

IF on Index Field: IF on Index Field is available only for scripts that were recorded in GUI scripting mode. Use IF on Index Field with regular loops (NOT indexed loops) to search and update multiple rows based on one field’s value. With IF on Index Field, you can find a row based on a value in a given column. Map only those fields that need to be updated.

In the IF Condition Properties box, select If on Index Field. If you want to update multiple rows based on the search field, check the Find All box. In the Select box, select the field or SAP line that you want to search on, select the operator, and then specify the update value or the Excel column from which the update value will be read.

Note: IF on Index Field supports text values only.

IF to verify text: Available for imported A1 Dataloader scripts and for TRANSACTION scripts recorded with GUI scripting. Confirms that a value in Excel corresponds to a value in SAP. It does not change or remove data.

IF: Click the IF setting to base the condition on an Excel column, or Access table/column, or in version 10.6.1, the XML field that you specify for the condition. When IF is selected, the Select Column, Operator, and Value fields are displayed near the bottom.

The allowed operators are:

=, >, <, >=, <=, <>, {BLANK}, {NOT BLANK}, {STARTS WITH}, {CONTAINS}, {ENDS_WITH}, {BETWEEN}

Select Column, Operator, Value: When the IF condition is selected, select the Excel column or Access table/column that you want to use for the condition, select the Operator for the condition, and then type the Value (text or number) for this comparison. When you select a column, the screen field and condition appear in a tooltip.

Compare with Column: Select this check box to compare the Select Column (Excel column or Access table/column) to the column you select. If you mark the Compare with Column check box, the Value field displays a selection list of the columns available for this comparison. The following operators are allowed:

<> and =

When you complete the If Conditional Properties dialog box, the Mapper displays your changes using two  Conditional Run icons connected by a line.

IF statements in .txr files distilled from BAPIs

Adding notes

You can add notes in the Mapper Notes column to If condition rows. However, notes cannot be seen if the script is opened in an earlier version of the product.

Also in this section

Editing in the Mapper

Filtering mapper settings

Advanced looping capability

Limiting input fields

Mapping Google spreadsheets

Validating data

Validate by list

Compensating for missing SAP screens and fields

Undo and Undo All

Mapping long text

Converting data types to strings

Attaching documents

Auto mapping

Downloading from SAP

Editing a TRANSACTION script