using @USER0 in Sequential stage file name

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
mickboland
Participant
Posts: 27
Joined: Sun Mar 20, 2005 4:23 am
Location: Brisbane, Australia

using @USER0 in Sequential stage file name

Post by mickboland »

I know you can use job parameters in a Sequential file stage filename eg:
#$EXTRACTS#\#CONNECTORSCRIPTNAME#_#RICEF# REJECTED.csv


Is there a way to use @USER0 in the Filename of a Sequential file stage?
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

No
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
mickboland
Participant
Posts: 27
Joined: Sun Mar 20, 2005 4:23 am
Location: Brisbane, Australia

Post by mickboland »

is there any way to dynamically set the filename apart from job parameters?
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Search the forum for macros, or consider writing out a standard file name and then using an after-routine to rename the file. That gives you a powerful option.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
rleishman
Premium Member
Premium Member
Posts: 252
Joined: Mon Sep 19, 2005 10:28 pm
Location: Melbourne, Australia
Contact:

Post by rleishman »

It's a bit ugly, but...
You could put the SEQ stage inside a Shared Container and create a parameter to the stored container that you reference in the SEQ file name.

When you drag the container into your job, set the parameter to anything you like.
Ross Leishman
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I usually write to a standard name and change it in an after-stage or after-job subroutine. To use @USER0 you would need to craft your own routine, but the logic is straightforward. If, for example, the file is in the current (project) directory, you can use &UFD& as a Type 19 UniVerse file. Otherwise, generate an appropriate operating system command.

Code: Select all

SUBROUTINE ChangeFileName(InputArg, ErrorCode)
* InputArg is pathname of file to change name
* Name change appends value of @USER0 
CALL !GET.PATHNAME(InputArg, DirPath, EntryName, Code)
NewName = EntryName : @USER0   ; * adapt to suit
If System(91)
Then
   Command = "REN " : InputArg : " " : NewName
   Shell = "DOS"
End
Else
   Command = "mv " : InputArg : " " :  NewName
   Shell = "UNIX"
End
Call DSExecute(Shell, Command, Output, ExitStatus)
RETURN
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mickboland
Participant
Posts: 27
Joined: Sun Mar 20, 2005 4:23 am
Location: Brisbane, Australia

Post by mickboland »

I need to set the parameter value at runtime.
mickboland
Participant
Posts: 27
Joined: Sun Mar 20, 2005 4:23 am
Location: Brisbane, Australia

Post by mickboland »

thanks ray - i will tinker with this rename method.


Is there a way to get the filename that the job has assigned to the seq file?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Park it anywhere from the routine, for example the job's user status area. This is readily accessed as an "activity variable" in a job sequence. But you could just as easily write it (the filename) into a text file or a database table or hashed file.

Code: Select all

SUBROUTINE ChangeFileName(InputArg, ErrorCode)
* InputArg is pathname of file to change name
* Name change appends value of @USER0
CALL !GET.PATHNAME(InputArg, DirPath, EntryName, Code)
NewName = EntryName : @USER0   ; * adapt to suit
If System(91)
Then
   Command = "REN " : InputArg : " " : NewName
   Shell = "DOS"
End
Else
   Command = "mv " : InputArg : " " :  NewName
   Shell = "UNIX"
End
Call DSExecute(Shell, Command, Output, ExitStatus)

* Generate full pathname of new file name and write to user status area
Call !MAKE.PATHNAME(DirPath, NewName, NewPath, Code)
Call DSSetUserStatus(NewPath)

RETURN
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply