Skip to main content

Development

How to Remove Special Characters Using Routines in Datastage

To implement complex business logic, Datastage designer allows us to create custom defined routines to implement it. A parallel routine provides us features to use external functionality written in C/C++ code to use in Datastage. Even though Datastage has most of the essential functions available, routines are very helpful to create custom functions for a very specific logic. In this blog, I will show you the implementation of routines to remove special characters.

Prerequisites:

  1. C++ code to remove special characters

How to Remove Special Characters Using Routines in Datastage

  2.       C++ Compilers- eg GCC in UNIX

  3.       Change the settings in DS Administration.

InfoSphere Datastage Administration –> Properties –> General –> Environment –> Compiler –> APT_COMPILER/APT_COMPILEOPT

How to Remove Special Characters Using Routines in Datastage

Steps to create Routines:

1.       Compile the C++ function in UNIX and create the object file. Make sure to compile using the same compile command which you have in the Datastage administrator for your project. Please note: we need to compile the code without MAIN() Function

              g++ -fpic -c spec_char_new.c

To create a shared object

         g++ -shared -o spec_char_new.so  spec_char_new.o

2.       Create a parallel routine in Datastage:

                  File>New>Routines>Parallel Routine

                  Fill all the required values as:

                  Routine Name:  Any name with just alphanumeric characters only.

                  External subroutine name: Name of the C function which we want to invoke

                  Type: External Function

                  Object Type: Library /Object

                  Return Type: Return type of the C function (For string function, specify as char*)

                  Library path: Library name with complete path

 

How to Remove Special Characters Using Routines in Datastage

Usage:

Here I have used a Sequential file as input and output. We need a transformer stage to use a parallel routine to call the external function in job.

In the Transformer stage, Right Click > DS_Routines>< Routine Name> call the routine
E.g : specialchar(%InStr%)

How to Remove Special Characters Using Routines in Datastage

Sample Input:

How to Remove Special Characters Using Routines in Datastage

Output:

How to Remove Special Characters Using Routines in Datastage

We can reuse the same routine anywhere in the project to remove special character by calling it in a transformer.

Thoughts on “How to Remove Special Characters Using Routines in Datastage”

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.

Anusha Ramasamy

More from this Author

Categories
Follow Us
TwitterLinkedinFacebookYoutubeInstagram