Generate a Sequential file with a header and footer??
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 503
- Joined: Wed Jun 29, 2005 8:14 am
Generate a Sequential file with a header and footer??
We have a requirement to write to a sequential file from a table. its not complex and is one to one mapping. But the thing is that we want to include a header and a footer to the file. Is it possible to do it in Datasatge??
I was wondering a work out such as union with a dummy table to generate this header row, but will like to know if there is a direct function present in datasatge or not?
I was wondering a work out such as union with a dummy table to generate this header row, but will like to know if there is a direct function present in datasatge or not?
-
- Participant
- Posts: 221
- Joined: Fri Feb 17, 2006 3:38 am
- Location: India
- Contact:
I dont think that would work, unless the "details" has a single record.parag.s.27 wrote:Yes you can do it in a single job......
just create 3 files with header, details and footer....
and then use Link collector having proper link execution order...
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
-
- Participant
- Posts: 221
- Joined: Fri Feb 17, 2006 3:38 am
- Location: India
- Contact:
no it will coz i did that just include 2 stage variables stgcnt1 and stgcnt2
then increment as stgcnt1+1 for stgcnt1
and
stgcnt2+1 for stgcnt2
and apply constraint..
for header- if stgcnt1=1 then.......
then simply details
and then footer as
if stgcnt2=1....
coz this will be satisfied only once
then increment as stgcnt1+1 for stgcnt1
and
stgcnt2+1 for stgcnt2
and apply constraint..
for header- if stgcnt1=1 then.......
then simply details
and then footer as
if stgcnt2=1....
coz this will be satisfied only once
Thanks & Regards
Parag Saundattikar
Certified for Infosphere DataStage v8.0
Parag Saundattikar
Certified for Infosphere DataStage v8.0
-
- Participant
- Posts: 221
- Joined: Fri Feb 17, 2006 3:38 am
- Location: India
- Contact:
to be more precise
Code: Select all
Header Data sequential file
|if Stgcnt1=1 then (write the header data)1\
|
------>transformer--------->details2----------------2---Link collector
|
|if Stgcnt2=1 then (write footer data)3--/
footer Data sequential file
Thanks & Regards
Parag Saundattikar
Certified for Infosphere DataStage v8.0
Parag Saundattikar
Certified for Infosphere DataStage v8.0
Thats fine. But the link collector will go for roundrobin processing. It will take the first record from 1, first record from 2 and then first record from 3, then come back to 2 and continue.
SO your output file will look like
header
detail
trailer
detail
detail
.......
.......
.......
.......
Thats what i mean. Its not the logic inside the transformer, its the way link collector will work.
SO your output file will look like
header
detail
trailer
detail
detail
.......
.......
.......
.......
Thats what i mean. Its not the logic inside the transformer, its the way link collector will work.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
-
- Participant
- Posts: 221
- Joined: Fri Feb 17, 2006 3:38 am
- Location: India
- Contact:
My mistake as usual...
hope this will help : -
first create file with header and detail data....and then use another link collector to include trailer to that newly created file.....
yup its complex....
so
Header + Detail = 1st link collector..
then
Header + Detail + Footer = 2nd link collector
hope this will help : -
first create file with header and detail data....and then use another link collector to include trailer to that newly created file.....
yup its complex....
so
Header + Detail = 1st link collector..
then
Header + Detail + Footer = 2nd link collector
Thanks & Regards
Parag Saundattikar
Certified for Infosphere DataStage v8.0
Parag Saundattikar
Certified for Infosphere DataStage v8.0
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You could also use ExecSH (or your own routine) as a before-job subroutine to echo the header into the file, append detail records in the job and use ExecSH (or your own routine) as an after-job subroutine to append the trailer using echo and the >> redirection operator.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 503
- Joined: Wed Jun 29, 2005 8:14 am