Skip to main content

Software Development

DataStage Macros

Teamwork Is Worth It

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: –

  1. Efficiency and Accuracy: –
    Result of the macro is increased in efficiency and accuracy through saving in operators, time as instructions       is repetitive.

  2. 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 NameUse of Macro
DSHostNameThis macro will return Host name of Datastage Server
DSJobControllerThis returns the job name as started the current job (if any)
DSJobInvocationIdIf job enables as multiple instances, then it will return InvocationId of job
DSJobNameThis returns job name
DSJobStartDateThis will return start date of job
DSJobStartTimeThis return start time of job
DSJobStartTimestampThis return timestamp of job
DSProjectNameThis 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: –

  1. Row_Generator
  2. Transformer
  3. 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: –

  1. Programming made easier as it is an error free code.
  2. The speed of execution in macro is faster.
  3. It reduces the length of code.
  4. Quicker in execution than functions or subroutines.
  5. Error will be resolved while writing code for macro.
  6. 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: –


Thoughts on “DataStage Macros”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Geeta Lakhwani

Geeta Lakhwani is a Technical Consultant at Perficient in Nagpur. She is always eager to learn new technologies and is excited to share her knowledge in Talend and DataStage Tools.

More from this Author

Follow Us