About this task
Once you have defined the CDC environment, you can create a Job in Talend Studio using a tAS400CDC component to extract the changes made to the data in the source system.
Drop a tAS400CDC component and a
tLogRow component from the Palette
onto the design workspace, and link the two components using a connection.
Double-click the tAS400CDC component to display its
Basic settings view.
- Select Repository from the Property Type drop-down list and click on [...] to fetch the schema which corresponds to your CDC connection. The fields which follow are automatically filled in with the information required to connect to the CDC database.
- Select Repository from the Schema drop-down list and click on [...] to fetch the schema which corresponds to the AS/400 table to be monitored.
- In the Table Name field, enter the name of the source table monitored by CDC, CUSTOMERS in this example.
- In the Source Library field, enter the name of the source library. By default, this is the same name of the source database.
- In the Subscriber field, enter the name of the subscriber who will extract the modified data. By default, the subscriber is named APP1.
- In the Events to catch field, select the check box which corresponds to the event(s) to be caught.
From your AS/400 system, execute
CHGJRN JRN(<Source_library_name>/<Journal_name>) JRNRCV(*GEN)to detach the old receiver from the journal and create and attach a new receiver to the journal to retrieve the last change.
The tAS400CDC component by default executes the following RUNCDC command:
<CDC_library_name>/RUNCDC FILE(<Source_library_name>/<Source_table_name>) LIBOUT(<CDC_library_name>) MODE(*DETACHED) MBROPT(*ADD)
Alternatively, you can automate the detachment and attachment process by selecting the Customize Command check box and adding the following custom command on the Advanced Settings view of the tAS400CDC component:
<CDC_library_name>/RUNCDC FILE(<Source_library_name>/<Source_table_name>) LIBOUT(<CDC_library_name>) MODE(*DETACHED) MBROPT(*ADD) DTCHJRN(*YES)Note that the default RUNCDC command setup in the tAS400CDC component reads changes of only one table. If you want to read changes on multiple (up to 300) tables at the same time and those tables are all on the same journal, you can use multiple tAS400CDC components in your Job, add an custom command
for the first tAS400CDC component and disable the command for other tAS400CDC components by selecting the Disable Command check box on the Advanced settings view. The first tAS400CDC component will execute the RUNCDC command and extract change data from all source tables, and other tAS400CDC components will simply read data prepared by the first tAS400CDC component.
<CDC_library_name>/RUNCDC FILE(<Source_library_name>/<Source_table_name1> <Source_library_name>/<Source_table_name2> ... <Source_library_name>/<Source_table_nameN>) LIBOUT(<CDC_library_name>) MODE(*DETACHED) MBROPT(*ADD)
Alternatively, you can disable command for all tAS400CDC components and execute the custom command manually on your AS/400 system.
Save the Job and press F6 to run it.
In the console, you can read the output results which correspond to what is displayed in the View All Changes dialog box.