# Script END\_DD tab

This tab is used to trigger a script and stop the distribution when a transaction record appears in a specified file.

![](https://help.qlik.com/talend/en-US/change-data-capture-reference-guide/Resources/images/tcdc-script-end-dd-tab.png)

## Purpose

The aim is to trigger a procedure on the target machine at a point of time in the operation, such as for example when all the transaction records in a given batch have been replicated on the target.

To do so, on the AS/400 IBMi machine:

* Create, for example, an END\_DD01 file (the file name must start with END\_DD followed by four characters of your choice). You can create the END\_DD01 file in any library, as the library is not assigned. However, with non-AS/400 IBMi sources, the table must be created in the database followed by the model.

* Journalize the END\_DD01 file in the same journal as the files to distribute.

* Perform an I/O on the END\_DD01 file at the end of the batch.

  Information noteWarning: An update operation performs two I/Os so it is preferable for example, to run a CLRPFM or another operation such as the Add operation, for instance.

* In Talend Change Data Capture, in the parameter definition of the distribution on the desired target, you specify END\_DD01 in the name of the END\_DD file that triggers the script, and enter the script that must be executed.

During the operation, if the I/O in the END\_DD01 file is applied by Talend Change Data Capture for this pair for the selected target, the script is executed on the target, and at the end of the script, the distribution of the model on the concerned target is stopped. If the script is aborted due to an error, the distribution is stopped with errors as well.

If you want to restart the distribution on the selected target, you must do so manually, either using the Supervise tab, or the AS/400 IBMi DDCTL command. The Scheduler does not automatically restart a distribution that was stopped by an END\_DD condition.

![](https://help.qlik.com/talend/en-US/change-data-capture-reference-guide/Resources/images/tcdc-sample-script-windows-target.png) *Sample script on a Windows target*

![](https://help.qlik.com/talend/en-US/change-data-capture-reference-guide/Resources/images/tcdc-sample-script-as-400-target.png) *Sample script on an AS/400 IBMi target*

During your input, you can press the Ctrl+Z keys simultaneously to undo your action.

## Name of END\_DD file starting the script

This property is used to specify the exact name of the file whose name starts with END\_DD, and which triggers the script.

When you enter the file name in this field, the input window of the script is displayed.

## Script

Use this window to enter the script to be executed.

The instructions in the script depend on the machine type (target) on which the script will be run (AS/400 IBMi or NT).

## Instructions common to AS/400 IBMi and NT targets

| Instruction | Description |
| --- | --- |
| OnError – Action in the event of an error | ```<br>OnError CONTINUE<br>STOP<br>``` |
| ONERROR CONTINUE | Used to specify whether the script must continue to the next instruction,<br>in case an error occurs in the current instruction. |
| ONERROR STOP | Used to specify whether the script must stop with errors, in case an error<br>occurs in the current instruction. |

The distribution of the selected model on the target is also aborted with errors.

You can switch the action to be performed in case of an error, at any time.

For example, if you want the default option to be ONERROR stop, except for a file delete operation where you want to continue despite an error, you would code as follows:

```
ONERROR continue
    DELETE File
    ONERROR stop
     :
    The rest of the script
```

By default, if an error occurs, the script stops.

## /\* - Comment

```
/* comment line
```

This property is used to enter a comment line.

## End – Stop replication

```
END
```

The script is stopped without flagging an error when this instruction is encountered, and the distribution is stopped.

Without this instruction, the replication procedure continues to the next sequence.

## Rconnect – Opens a connection with an AS/400 IBMi machine running Talend Change Data Capture

```
RCONNECT IP address
```

Establishes a proprietary connection with the AS/400 IBMi machine that has the IP address you enter.

You can specify the DNS name of the AS/400 IBMi if it is recognized by the NT machine on which the script is run.

Each new connection request closes the previous connection.

## RmtCmd – Executes a command on a connected AS/400 IBMi and waits for it to be completed before continuing to run the script

```
RMTCMD Program in parameter1 …
```

This starts the command specified in AS/400Command on the AS/400 IBMi machine that was connected using the RCONNECT command.

The parameters are those required by the desired AS/400 IBMi command.

You can use all AS/400 IBMi commands, including CALL.

## Instructions specific to AS/400 IBMi targets

You can use all the AS/400 IBMi commands with the same syntax as the one used on the AS/400 IBMi command line.

Example:

```
CHGCURLIB MYLIB
CALL BIB/PGM
```

## Instructions specific to Windows targets

| Instruction | Description |
| --- | --- |
| Rule for file name | You can specify a file name preceded by a unit code, or with the UNC<br>syntax (//server/resource/path).<br><br>If the name and/or the file path contains a blank, you must put the file<br>designation within quotes (the " character):<br><br>```<br>"c:\program files\appli\file.ext"<br>```<br><br>You can facilitate file name input, by dragging and dropping from the Windows NT explorer for example, to the script entry window. |
| Create – Creates an empty file | ```<br>CREATE File<br>```<br><br>This parameter is used to create an empty file at the specified location. |
| Copy – Copies a source file to a destination | ```<br>COPY SourceFile DestinationFile<br>```<br><br>Is used to copy a file to another file. |
| Move – Moves a source file to a destination | ```<br>MOVE SourceFile DestinationFile<br>```<br><br>Is used to move a<br>file to another location. |
| Delete – Deletes a file | ```<br>DELETE File<br>```<br><br>Is used to delete a file. |
| Rename – Renames a file | ```<br>RENAME SourceFile DestinationFile<br>```<br><br>Is used to rename a file. |
| Shell – Starts a process and continues running the script | ```<br>SHELL ProgramName parameter1 …<br>```<br><br>Starts the program designated by *ProgramFile* with the parameters<br>required in another NT process and continues running the script until the<br>next instruction is found. |
| ShellW – Starts a process and waits for it to be completed before<br>continuing to run the script | ```<br>SHELLW ProgramName parameter1 …<br>```<br><br>Starts the program designated by ProgramFile with<br>the parameters required in another NT process and waits for the program<br>to finish before continuing to run the script until the next instruction<br>is found. |