What are Routines and where/how are they written and have you written any routines before?   

Routines are stored in the Routines branch of the DataStage Repository, where you can create, view or edit. The following are different types of routines:
   1) Transform functions
   2) Before-after job subroutines
   3) Job Control routines

Showing Answers 1 - 5 of 5 Answers

bvrp

  • Nov 1st, 2005
 

RoutinesRoutines are stored in the Routines branch of the DataStage Repository,where you can create, view, or edit them using the Routine dialog box. Thefollowing program components are classified as routines:? Transform functions. These are functions that you can use whendefining custom transforms. DataStage has a number of built-intransform functions which are located in the Routines ➤ Examples➤ Functions branch of the Repository. You can also defineyour own transform functions in the Routine dialog box.? Before/After subroutines. When designing a job, you can specify asubroutine to run before or after the job, or before or after an activestage. DataStage has a number of built-in before/after subroutines,which are located in the Routines ➤ Built-in ➤ Before/Afterbranch in the Repository. You can also define your ownbefore/after subroutines using the Routine dialog box.? Custom UniVerse functions. These are specialized BASIC functionsthat have been defined outside DataStage. Using the Routinedialog box, you can get DataStage to create a wrapper that enablesyou to call these functions from within DataStage. These functionsare stored under the Routines branch in the Repository. Youspecify the category when you create the routine. If NLS is enabled,

bvrp

  • Nov 1st, 2005
 

RoutinesRoutines are stored in the Routines branch of the DataStage Repository,where you can create, view, or edit them using the Routine dialog box. Thefollowing program components are classified as routines:? Transform functions. These are functions that you can use whendefining custom transforms. DataStage has a number of built-intransform functions which are located in the Routines ➤ Examples➤ Functions branch of the Repository. You can also defineyour own transform functions in the Routine dialog box.? Before/After subroutines. When designing a job, you can specify asubroutine to run before or after the job, or before or after an activestage. DataStage has a number of built-in before/after subroutines,which are located in the Routines ➤ Built-in ➤ Before/Afterbranch in the Repository. You can also define your ownbefore/after subroutines using the Routine dialog box.? Custom UniVerse functions. These are specialized BASIC functionsthat have been defined outside DataStage. Using the Routinedialog box, you can get DataStage to create a wrapper that enablesyou to call these functions from within DataStage. These functionsare stored under the Routines branch in the Repository. Youspecify the category when you create the routine. If NLS is enabled,9-4 Ascential DataStage Designer Guideyou should be aware of any mapping requirements when usingcustom UniVerse functions. If a function uses data in a particularcharacter set, it is your responsibility to map the data to and fromUnicode.? ActiveX (OLE) functions. You can use ActiveX (OLE) functions asprogramming components within DataStage. Such functions aremade accessible to DataStage by importing them. This creates awrapper that enables you to call the functions. After import, youcan view and edit the BASIC wrapper using the Routine dialogbox. By default, such functions are located in the Routines ➤Class name branch in the Repository, but you can specify your owncategory when importing the functions.When using the Expression Editor, all of these components appear underthe DS Routines? command on the Suggest Operand menu.A special case of routine is the job control routine. Such a routine is usedto set up a DataStage job that controls other DataStage jobs. Job controlroutines are specified in the Job control page on the Job Properties dialogbox. Job control routines are not stored under the Routines branch in theRepository.TransformsTransforms are stored in the Transforms branch of the DataStage Repository,where you can create, view or edit them using the Transform dialogbox. Transforms specify the type of data transformed, the type it is transformedinto, and the expression that performs the transformation.DataStage is supplied with a number of built-in transforms (which youcannot edit). You can also define your own custom transforms, which arestored in the Repository and can be used by other DataStage jobs.When using the Expression Editor, the transforms appear under the DSTransform? command on the Suggest Operand menu.FunctionsFunctions take arguments and return a value. The word ?function? isapplied to many components in DataStage:? BASIC functions. These are one of the fundamental buildingblocks of the BASIC language. When using the Expression Editor,Programming in DataStage 9-5you can access the BASIC functions via the Function? commandon the Suggest Operand menu.? DataStage BASIC functions. These are special BASIC functionsthat are specific to DataStage. These are mostly used in job controlroutines. DataStage functions begin with DS to distinguish themfrom general BASIC functions. When using the Expression Editor,you can access the DataStage BASIC functions via the DS Functions?command on the Suggest Operand menu.The following items, although called ?functions,? are classified as routinesand are described under ?Routines? on page 9-3. When using the ExpressionEditor, they all appear under the DS Routines? command on theSuggest Operand menu.? Transform functions? Custom UniVerse functions? ActiveX (OLE) functionsExpressionsAn expression is an element of code that defines a value. The word?expression? is used both as a specific part of BASIC syntax, and todescribe portions of code that you can enter when defining a job. Areas ofDataStage where you can use such expressions are:? Defining breakpoints in the debugger? Defining column derivations, key expressions and constraints inTransformer stages? Defining a custom transformIn each of these cases the DataStage Expression Editor guides you as towhat programming elements you can insert into the expression.

Chalapathirao Maddali

  • Jul 11th, 2014
 

Datasatge has 2 types of routines ,Below are the 2 types.

1.Before/After Subroutine.
2.Transformer routines/Functions.

Before/After Subroutines :

These are built-in routines.which can be called in before or after subroutines. Below is the list of the same.

1.DSSendMail :Used to Send mail using Local send mail program.
2.DSWaitForFile : This routine is called to suspend a job until a named job either exists, or does not exist.
3.DSReport :Used to Generate Job Execution Report.
4.ExecDos: This routine executes a command via an MS-DOS shell. The command executed is specified in the routines input argument.
5.ExecDOSSilent. As ExecDOS, but does not write the command line to the job log.
6. ExecTCL. This routine executes a command via an Info Sphere Information Server engine shell. The command executed is specified in the routines input argument.
7.ExecSH:This routine executes a command via a UNIX Korn shell.
8.ExecSHSilent:As ExecSH, but does not write the command line to the job log.

Transformer Routines:

Transformer Routines are custom developed functions, as you all know even DS has some limitations corresponding to inbuilt functions(TRIM,PadString,.etc), like in DS version 8.1 we don’t have any function to return ASCII value of a character, Now from 8.5 they have introduced seq() function for above mentioned scenario.

These Custom routines are developed in C++ Writing a routine in CPP and linking it to our datastage project is really simple task as follows,

v Write CPP code
v Compiling with the required flags.
v Put the output file in a shared dir.
v Link it in the datastage.
v Use it in a transformer like other functions.

Below is the Sample C++ Code :

#include
#include

using namespace std;
int addNumber(int a,int b)
{
return a+b;
}

Note :We need to make sure ,our code should not contain main() function as it is not required.

Compiling with the required flags:

Get the values of below 2 Environment variables.

1.APT_COMPILER
2.APT_COMPILER_OPT

Use as below to compile the code from unix prompt.

APT_COMPILER APT_COMPILER_OPTFile_Name(with Cpp Code).

v Once you run the above command it will create object file at same path with .o as extension. Now login to DS Designer at routines folder do a right click and select new Parallel routine.
v In new opened window put required details like Name and Select type as External Function external subroutine name as the function name we need to access, . Select proper return type and also provide the complete path of the .o file.
v Now Select Arguments tab and add required arguments ,select proper Data types for arguments.
v Now you are all done. Go to your job open any transformer and in any expression just select the ellipsis button [...] you will get the list and there select routine. There you will get our new routine listed.

But remember few points while writing the function i.e the cpp code,

v Data stage cannot accept return type as string, so we need to design our function to return char* instead.

v The same applies to input arguments too. So our function can accept char* only not string. But later in the cpp code we can change it to string.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions