0 / 0
Migrating BASIC routines in DataStage

Migrating BASIC routines in DataStage

Server jobs in traditional DataStage® may contain BASIC routines, which are not supported in modern DataStage.

When you migrate a server job in traditional DataStage to a pipeline flow in Cloud Pak for Data, you can rewrite the routine as a script and add it as a Run Bash script or Run Python script node in your pipeline flow. For more information, see Replacing BASIC routines in DataStage.

When you migrate a server job, the routine nodes are migrated to Run Bash script nodes. The routines are stored as .sh scripts in the mounted PVC under /mnts/ds-storage/projects/<your-project-name>/scripts/. If you are not an administrator, create a storage volume connection to access the ds-storage directory. To run migrated routines, rewrite the scripts in that directory in Bash or Python code. Every node that references a particular routine will run the script of the same name.

Getting arguments and setting return values

Migration converts routine arguments to environment variables with the following name pattern: <routine_name>_<argument_name>. To set the return values for a rewritten BASIC script, write an echo statement at the end of your script to print a JSON string to the standard output. Call ds.CommandOutput(tasks.<id>) to get the JSON string and pass it into ds.GetOutputArg() as an argument along with the value you want to retrieve. See the following example script:
#!/bin/bash 

IBMCP4DCallFunction() { 
# Define the function with 2 arguments 
# Increment the values of each argument by 1 
Age=$1 
Name=$2 
Ans=0 
echo "{\"Age\":$Age, \"Name\":\"$Name\", \"Ans\":$Ans}" 
return $Ans 
} 
IBMCP4DCallFunction "$IBMCP4DCallFunction_Age" "$IBMCP4DCallFunction_Name"

In this example, the pipeline node is named RoutineAct1 and has an internal id of routine1. The values for the input arguments Name and Age are stored in the environment variables IBMCP4DCallFunction_Age and IBMCP4DCallFunction_Name. To get the value of the output argument Age in activity trigger conditions or expressions following the routine, use the function call ds.GetOutPutArg(ds.getCommandOutput(tasks.routine1), 'Age'). Here the ds.getCommandOutput call returns the JSON string and ds.GetOutPutArg('{"Age":30, "Name":"new name", "Ans":0}', 'Age') returns the value 30. Similarly, to retrieve the value of Ans, you would use ds.GetOutPutArg(ds.getCommandOutput(tasks.routine1), 'Ans').

Generative AI search and answer
These answers are generated by a large language model in watsonx.ai based on content from the product documentation. Learn more