I have created two after job routines. One adds a trailer to the output file from a job and the other is meant to add a header.
The problem is that although the Write Trailer works fine, the Write Header routine is adding the line at the bottom of the file and not the top.
Any suggestions ?
Is there a way of using a before job routine to create the header before the output is added to the file ?
Creating a File Header
Moderators: chulett, rschirm, roy
Re: Creating a File Header
try something like in the Before routineJezT wrote:I have created two after job routines. One adds a trailer to the output file from a job and the other is meant to add a header.
The problem is that although the Write Trailer works fine, the Write Header routine is adding the line at the bottom of the file and not the top.
Is there a way of using a before job routine to create the header before the output is added to the file ?
Code: Select all
echo headermessage >> yourfile.txt
Depends on what your header information contains. If it is supposed to contain information about the row count, you have to create the header row after you created the file.
Why not let DataStage create your file, then use an after-job script call to create the header and trailer record and then assembled the completed file? Your on unix, do something like:
1. create a header record header.txt
2. create a trailer record trailer.txt
3. issue a cat statement like:
Why not let DataStage create your file, then use an after-job script call to create the header and trailer record and then assembled the completed file? Your on unix, do something like:
1. create a header record header.txt
2. create a trailer record trailer.txt
3. issue a cat statement like:
Code: Select all
cat header.txt datafile.txt trailer.txt > finalfile.txt
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
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
What I generally do is create all three in the same job... or seperate jobs, if that is not possible. An after job then creates the final product by 'catting' the three files together:
You could do something similar. Either that or create your header record first and change your job that creates the detail to append to it... but it might complain about the metadata mismatch.
I prefer building the three pieces and then sticking them together into a new file.
Code: Select all
cat header detail trailer > final_file
I prefer building the three pieces and then sticking them together into a new file.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers