Example 4: Creating the job

Create the Switch example job that includes one External Source stage, one Hierarchical Data stage, and two Sequential File stages.

About this task

The following figure shows the job that you create for this Switch example. The job includes one External Source stage named Employee_Files, one Hierarchical Data stage named Employee_Filter, and two Sequential File stages, named Employee_Validfile and Employee_Invalidfile. The External Source stage is linked to the Hierarchical Data stage by a link named Employee, and the Hierarchical Data stage is linked to two sequential files, Employee_Validfile and Employee_Invalidfile by a link named Valid_file and Invalid_file respectively.

The switch job.

Procedure

  1. Start the IBM® InfoSphere® DataStage® and QualityStage® Designer client.
  2. In the Repository pane, right-click the Jobs folder, and select New > Parallel job.
  3. Open the File section of the palette, and drag one External Source stage to the canvas.
  4. Open the Real Time section of the palette, and drag one Hierarchical Data stage to the canvas. Position the Hierarchical Data stage to the right of External Source stage.
  5. Open the File section of the palette, and drag two sequential file stages to the canvas. Position the two sequential file stages to the right of the Hierarchical Data stage.
  6. Create a link from the External Source stage to the Hierarchical Data stage, and create links from the Hierarchical Data stage to the two sequential file stages.
  7. Rename the stages and links as shown in the following table:
    Table 1. Names for job elements
    Element Name
    External Source stage Employee_Files
    Hierarchical Data stage Employee_Filter
    Link from External Source stage to Hierarchical Data stage Employee
    First Sequential File Stage Employee_Validfile
    Second Sequential File Stage Employee_Invalidfile
    Link from Hierarchical Data stage to Employee_Validfile Valid_file
    Link from Hierarchical Data stage to Employee_Invalidfile InValid_file
  8. Create job properties for the location of the example files:
    1. Click the Job PropertiesThe Job Properties icon icon on the toolbar.
    2. On the Parameters tab, in the Parameter Name field, enter xml_example_root_folder, and then specify the following values for the first parameter.
      Table 2. Specifying the values for field names
      Field name Value
      Prompt Root of example folder tree
      Type String
      Help Text Point to the root of the file tree folder
    3. On the Parameters tab, in the Parameter Name field, enter file_location, and then specify the following values for the second parameter.
      Table 3. Specifying the values for field names
      Field name Value
      Prompt Location of XML files
      Type String
      Default Value ls <Enter_the_location_of_the_zip>/xml_examples/switch_step/example1/input_files/*.xml
      Help Text The location of the input files.
    4. Click OK.
  9. Double-click the External Source stage to configure the stage properties.
  10. Click the Properties tab, and select Source > Source Program. Enter the path for the input files, in the Source Program field. You can use the parameter, file_location to specify the location of the input files.
    Note: The External Source stage returns the absolute location of the xml files. For example, if your data files (employee1.xml and employee2.xml) are in the C:\Test\ directory, the output of the External Source stage will be C:\Test\employee1.xml and C:\Test\employee2.xml.
  11. Click the Columns tab, and create these columns:
    Table 4. Columns for the Employee_Files stage
    Column name SQL type
    employee_file_list VarChar
  12. Click OK.
  13. By looking at the input file, employee1.xml, which contains the XML data, you determine which columns to create to hold the employee data that the Hierarchical Data stage will pass to the Employee_Validfile stage and the Employee_Invalidfile stage.
  14. Double-click the Employee_Validfile stage to configure the stage properties.
  15. Click the Properties tab, and configure the following properties that define the output file:
    Table 5. Configuring the properties
    Field name Value
    Target > File Enter the path to where you want the output file to be created, followed by the file name for example, valid_emp.txt.
    Target > File Update Mode Choose Overwrite to create the file.
    First line is column name Set to True.
  16. Click the Columns tab, and create these columns:
    Table 6. Columns for the Employee_Validfile stage
    Column name SQL type Length
    LastName VarChar 40
    MiddleName VarChar 40
    FirstName VarChar 40
    Gender VarChar  
    BirthDate VarChar  
    Title VarChar  
    HireDate Date  
    EmployeeID VarChar  
    DepartmentID VarChar  
  17. Click OK to close the Employee_Validfile stage.
  18. Double-click the Employee_Invalidfile stage to configure the stage properties.
  19. Click the Properties tab, and configure the following properties that define the output file:
    Table 7. Configuring the properties
    Field name Value
    Target > File Enter the path to where you want the output file to be created, followed by the file name for example, InValid_emp.txt.
    Target > File Update Mode Choose Overwrite to create the file.
    First line is column name Set to True.
  20. Click the Columns tab, and create these columns:
    Table 8. Columns for the Employee_Invalidfile stage
    Column name SQL type Length
    LastName VarChar 40
    MiddleName VarChar 40
    FirstName VarChar 40
    Gender VarChar  
    BirthDate VarChar  
    Title VarChar  
    HireDate Date  
    EmployeeID VarChar  
    DepartmentID VarChar  
  21. Click OK to close the Employee_Invalidfile stage.
  22. Choose File > Save , and name the job as xml_switch_example.