DataStage has several in-built macros and do not require any arguments. DataStage macros can be used to get information about current job, job control routines, filename and table names, and before/after subroutines and stages belonging to the current job.
DataStage ETL Tool: –
DataStage is a commonly used ETL tool in the current market. It is an extract, transform, and load tool that is part of the IBM Infosphere suite. It is a tool that is used for working with large data warehouses and data marts for creating and maintaining a data repository.
Macros: –
Macros plays an important part in any programming language. It helps to automate routine tasks.
It focuses on getting some set of input instructions to perform a specific set of operations and produces output on a computer.
Purpose of Macro: –
- Efficiency and Accuracy: –
Result of the macro is increased in efficiency and accuracy through saving in operators, time as instructions is repetitive. -
Repeatability: –
Macro operations are repeated many times.
For example: –
One developer created a macro related to calculate area of park then pass parameters to get result and it is a repetitive process use by other developers also.
3. Consistency: –
Macros have always followed some standards to perform operations.
For Example: –
If developer wants to change only one parameter and result would be same but behavior of macro will be same and get successive output.
In-built Macros in IBM DataStage: –
Some Parallel transformer Macros are listed here, as said, these can be used in anywhere in job.
DataStage has number of in-built macros and it mainly use to get information of current job,
stages and links and helps to save monitor details of the jobs such as jobname, start time of job, etc.
While using the expression editor, it comes under the DS Macro
Please see below picture: –
Below are the macros in DataStage: –
DS Macro Name | Use of Macro |
---|---|
DSHostName | This macro will return Host name of Datastage Server |
DSJobController | This returns the job name as started the current job (if any) |
DSJobInvocationId | If job enables as multiple instances, then it will return InvocationId of job |
DSJobName | This returns job name |
DSJobStartDate | This will return start date of job |
DSJobStartTime | This return start time of job |
DSJobStartTimestamp | This return timestamp of job |
DSProjectName | This return project name of running job |
We have used all DataStage above macros in our monitoring job and it helps to get information of job.
Sample Job to use macros in DataStage: –
In the below job, used three components of DataStage: –
- Row_Generator
- Transformer
- Sequential File
In transformer (TFM_DETAILS), corresponding macros give details: –
After running the job, got below output: –
Pros of Macros: –
When a macro called, then several lines of code replaced by single line: –
- Programming made easier as it is an error free code.
- The speed of execution in macro is faster.
- It reduces the length of code.
- Quicker in execution than functions or subroutines.
- Error will be resolved while writing code for macro.
- Duplication of effort is reduced.
Cons of Macros: –
If a macro called several times, then the entire code is substituted, it will increase the length and execution time of program.
Conclusion: –
DataStage macros plays an important part when we need to get current job details for monitoring purpose. As macros replaced by single line and no need to pass any parameter, processing time would be an effective as a code perspective.
Refer Links: –
https://www.ibm.com/docs/en/iis/11.7?topic=components-macros
Good read!