How to join Header and Trailer records

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

How to join Header and Trailer records

Post by us1aslam1us »

Hi

Can anyone please help me in understanding this issue:

I am having two sequential file one is having the Detail records and the other is having the trailer information like number of records processed in the detail record and the rundate.But i need to join these two file and pass on this to the vendor.initially i thought it is possible to merge these two file using a merge stage but i am not getting the complete records.
How can i proceed further..

Thanks
sam
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post by balajisr »

Use Unix Cat command to merge header and trailer. Use Execsh in after job subroutine.
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

balajisr wrote:Use Unix Cat command to merge header and trailer. Use Execsh in after job subroutine.
Can u Elaborate it little more.

Thanks
sam
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The job finishes processing rows into the two files. Then you can invoke a UNIX command cat to append the contents of the trailer file to the detail file, or both into a third file. You can do this via an Execute Command activity in the job sequence that is controlling the job, since parallel jobs do not support before/after subroutines.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

us1aslam1us wrote:
balajisr wrote:Use Unix Cat command to merge header and trailer. Use Execsh in after job subroutine.
Can u Elaborate it little more.

Thanks
sam
cat filename1 filename2 > filename3
cat is the keyword which should be entred in Command and the rest in Parameter.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Yup exactly what I was doing right now :)
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

cat filename1 filename2 > filename3
cat is the keyword which should be entred in Command and the rest in Parameter.[/quote]

Hi Kumar

In the PARAMETER how can i give file names? It is just showing me the job activity stages.

Thanks
sam
pneumalin
Premium Member
Premium Member
Posts: 125
Joined: Sat May 07, 2005 6:32 am

Post by pneumalin »

Sam,
Follows the steps:
1. Click on Job Properties of your job
2. Select ExecSH from Before-job Subroutine or After-job Subroutine
3. type "cat filename1 filename2 > filename3 " in input value field.
Note: filename can be replace with your JobParamter including the absolute path of the file location. Ex.
"cat #HeaderPath#/header.txt #SourcePath#/body.txt > #TargetPath#/target.txt "

Let me know if this works for you!

NOTE: One thing to correct Ray's comment in earlier post. Parallel job DOES have the capacity to perform "ExecSH in Before-job Subroutine or After-job Subroutine".(Maybe Ray is talking about something else). The Execute Command for sequencer is another option to join Header and Trailer to your body file, and I prefer to use this option for Best practice consideration. Since the ExecSH is hidden in Job Properties of a job, sometime it is difficult for the support group to identify this action when invetigating the produciton problem, versus the Execute Command is clearly visualized in a sequencer.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What I was referring to is the ability to work with more than one partition. Your processing has been managed on more than one partition - did you collect all rows into a Sequential File stage running in sequential mode? Only in that case will executing cat via ExecSH make any sense.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
richdhan
Premium Member
Premium Member
Posts: 364
Joined: Thu Feb 12, 2004 12:24 am

Post by richdhan »

Hi Sam,

If you intent to do this within DataStage use 2 column import stages one for detail and other for trailer. The outputs of the 2 column import stages will be 1 varchar column with a fixed width. Use the funnel to merge both these outputs and load it into sequential file.

HTH
--Rich
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

I used the cat the command in the Execute_Command stage and it is working good.Thanks all for the Feedback.

Thanks
sam
Post Reply