Page 1 of 1

Datastage Transform

Posted: Tue Apr 22, 2008 6:19 am
by sarat.srinivas@tcs.com
Hi All,

I want to write a transform to check whether a file exists or not in the given location. So, please help me how can I write the Basic code for checking the existance of a file in a transform.

Thanks in advance.

Regards,
ETL Developer.

Posted: Tue Apr 22, 2008 7:08 am
by ArndW
You have specified "Parallel" by wish to write a function [not a transform] in BASIC - that would be for a Server job. Which is it?
The BASIC function would be straightforward, using a DSExecute() call to the UNIX call of your choice to see if the file exists, then parsing the result and returning a true or false to the calling transform stage.

Re: Datastage Transform

Posted: Tue Apr 22, 2008 7:17 am
by sud
A crude way is to try to open the file and if that fails then something is wrong with it:

Code: Select all

FUNCTION_NAME = "ReadFromFile"

InFile = "/path/to/file/whatafile.txt"

OpenSeq InFile To InputFile
  On Error Call DSLogFatal("Error Opening File ":InFile,FUNCTION_NAME)
Then
  ReadSeq TextLine From InputFile
  ..........
  ..........

Posted: Tue Apr 22, 2008 7:37 am
by AmeyJoshi14
Hi,
One more method! :)
We were facing the same issue ,so inorder to handle this ,we have added an extra column with name(in sequential file(source file)) name as PATHNAME which is having the value of the file along with path.

In the transformer stage variable we checked whether particular file exist with the help of environment varaible(parameter name) if exist then do some transformations else pass the input as it is to output. :!:

Code: Select all

IF
DSLink18.PATHNAME=(parameter name)
THEN
1
ELSE
0
And as suggested by AndrW you can use Before job subrountine to check the whether file is present.There are many ways, one of the method is by using "dsjob -paraminfo" command . :wink:

Posted: Tue Apr 22, 2008 7:45 am
by balajisr
DSWaitForFile() is also useful.

How to find the no of Mondays in a week?

Posted: Fri Oct 31, 2008 6:04 am
by swerajan
HI all

I need a find the no of mondays each month has got using datastage, The month differs and is not a hardcoded one. Please help me out in finding the count

Posted: Fri Oct 31, 2008 7:41 am
by chulett
:!: Please don't hijack posts. This has nothing to do with the original problem, so please start a new post in the correct forum based on your job type - PX or Server.