DataStage OSH Scripting: A Comprehensive Guide

Introduction to DataStage OSH Scripting

The DataStage Onshore Script (OSH) is a powerful tool that extends DataStage's capabilities by allowing users to write custom functions in Java or JavaScript. This feature can be used to perform complex transformations, calculations, and integrations not available with standard DataStage operators.

Setting Up the Environment

  1. Install and configure a Java Development Kit (JDK) or JavaScript runtime environment on your machine or server where DataStage is installed.
  2. Configure the Classpath or JavaScript directory in your DataStage project settings to include the path to your custom scripts.

Writing Custom Functions in Java and JavaScript

Custom functions can be written in either Java or JavaScript, depending on preference and complexity. Here are simple examples:


      public class MyCustomFunction extends Function {
          @Override
          public void eval(Hold hold, Transition transition) throws HoldItemNotFoundException, IncompatibleTypesException {
              // Perform your custom logic here
          }
      }
      

      function myCustomFunction(hold, transition) {
          // Perform your custom logic here
      }
      

Using Custom Functions in a DataFlow

  1. Java: Add an "Evaluate Java Expression" operator and specify the fully qualified class name for your custom function.
  2. JavaScript: Add a "JavaScript" operator and specify the path to your JavaScript file containing the custom function.

Troubleshooting Common Issues