Page 1 of 1

Passing a Job Parameter for picking up a dynamic File Name

Posted: Tue Feb 01, 2005 1:05 pm
by Shaina Austin
Hi,

My scenario here is that I have to automate my server job and it should pickup the file name dynamically. The file name comes from the source suffixed with the current date, i.e., xxx20050201.txt and next day it will be xxx20050202.txt

I need help in passing this file name as a parameter so that the job picks up the correct file name. Moreover, at the time when the job runs, the directory where the file resides will have only one file starting with xxx.

I am able to parameterize the file name in a parallel job, but I am unable to do this in the server job.

Any help is greatly appreciated.

Thx.

Posted: Tue Feb 01, 2005 1:22 pm
by ketfos
Hi,
Have Before Job Routine as -
IF the file is on Unix , do

Varx =`ls xxx*` (before job routine)
Then pass this Varx as parameter.

Ketfos

Posted: Tue Feb 01, 2005 3:08 pm
by roy
Hi,
If your file is sequential you can use the filter command:
cat <filee path>/xxx*
even saves you the parameter usage ;)

IHTH,

Posted: Tue Feb 01, 2005 5:23 pm
by vmcburney
You do the same thing in your server job that you would do in your parallel job. Where you enter the file name use the job parameter enclosed by hash symbols. Eg. #PROJECT_PATH#/#SOURCE_DIR#/#FILE_NAME#
or
#PROJECT_PATH#/#SOURCE_DIR#/xxx#FILE_DATE#.txt
or
#FILE_PATH/#FILE_NAME#

Lots of ways to do it.

Posted: Tue Feb 01, 2005 11:15 pm
by talk2shaanc
Use this routine, it will give you the file name.

*Function GetFileName(FileName,FilePath)
Deffun DSRMessage(A1, A2, A3) Calling "*DataStage*DSR_MESSAGE"
RoutineName='GetFileName'


Call DSExecute("DOS", 'Dir /b ':FilePath:'\':FileName:'*', Output, SystemReturnCode)

If Trim(Output) = "File Not Found" Then
Message = DSRMessage("DSTAGE_TRX_I_0005", "<L>*** Output from command was: ***<L>", ""):Output
GoTo ErrorExit
End Else
Message = DSRMessage("DSTAGE_TRX_I_0006", "<L>*** No output from command ***", "")
End
If SystemReturnCode = 0 Then
Message = DSRMessage("DSTAGE_TRX_I_0003", "Executed command: ", ""):'Dir ':FilePath:'\':FileName:'*':Message
Call DSLogInfo(Message, RoutineName)
End Else
Message = DSRMessage("DSTAGE_TRX_I_0004", "Error when executing command: ", ""):'Dir ':FilePath:'\':FileName:'*':Message
GoTo ErrorExit
End

* Exit with no error.
ErrorCode = 0
GoTo NormalExit

* Exit with error, logging warning message first.
ErrorExit:
Call DSLogWarn(Message, RoutineName)
ErrorCode = 1
Abort


NormalExit:
Ans=Output
Return(Ans)
------
pass this value as a parameter, to your job.

Posted: Tue Feb 01, 2005 11:19 pm
by talk2shaanc
sorry forgot to mention this will work for NT server.

Posted: Wed Feb 02, 2005 3:28 am
by Sainath.Srinivasan
You can link the file to a generic file name and use the generic file name in your jobs.

For e.g., you can do the following in 'Before-Job subroutine'

ln GenericFileName xxx*

and in your job, you can use the file called 'GenericFileName'.

Once your job finishes, you can (optionally as a good practice) remove the link saying

rm GenericFileName

This is assuming that you will have only one file name in that dir with the starting (prefix) of xxx.

Alternatively, try to obtain the date from the Unix run date (date) command and suffix with xxx in the above link as you find suitable.

Posted: Thu Feb 24, 2005 12:26 am
by sankar18
To handle the dynamic filename, have the filename as job parameter like filename and date, job parameter enclosed by hash symbols. Eg.

#PATH#/#DIR#/#FILENAME##DATE#.txt

while running the job the give the value for path, dir, filename, date. so that it will pick the correct file.

Posted: Thu Feb 24, 2005 5:22 am
by vigneshra
Hi
Declare a parameter in the job for holding filename. From the shell script you call the job, just get the name of the file from the specified directory (since the only file in the directory is the required file), and pass it as the job parameter to the job. That solves the problem!

Posted: Thu Feb 24, 2005 11:25 pm
by suma
Hi,,
I understand from your example that the prefix of ur
File Name xxx is constant,
So i can write a routine to get the sysdate Iin wat ever format u need)
and concatenete with the prefix of your fileName and use the value that is returned as FIle Name.

But my problem is,
i am not sure what exactly i should do to use the value that is returned from the routine as the File name?

While browsing the Forum i came to know that we can use this code in the Job COntrol

DEFFUN RoutineName(Arg1, Arg2, Arg3) Calling "DSU.RoutineName"

But again how can i get the value that is returned and use it as my file name.
Is there any way to directly use the returned value as FileName or
it can be done thro parameters only.

Can any one help me to solve this.

Thanks

SumA
Thanks

Re: Passing a Job Parameter for picking up a dynamic File Na

Posted: Mon Mar 14, 2005 5:45 am
by vskr72
Shaina - Pls let me know what solution you adopted. I have asimilar requirement but, the OS is unix. appreciate your help.

Kumar