How to combine 3 files (Header,Detail and Trailer)

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
reddy
Premium Member
Premium Member
Posts: 168
Joined: Tue Dec 07, 2004 12:54 pm

How to combine 3 files (Header,Detail and Trailer)

Post by reddy »

Hi Guys,

Good morning.Are you guys ready for Superbowl party

I would like to combine header record as my first record and trailer as my last record to my detail file.

How can i merge all 3 files one by one means header,detail and trailer.

Have a nice weekend.

Thanks in advance

Reddy
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

Hi Reddy,


Whenever you state your question. Please provide all the possible details that would be helpful in providing a viable solution. Just TWO sentences is not sufficient. This is always not a good idea as your are cutting down your chances of getting a good solution.

Now, I'm assuming that you header, detail and trailer records are of different lengths that one header has one detail and one trailer record.

So, you have a header file, a detail file and a Trailer file. And you have to create a new file for each record from the header, then append the detail record, followed by the trailer record. And this happens for all the records. Right?

If that the case, then sort all the three files according to the joining keys.

Find out the which is the longest record of the three. Header, Detail or Trailer??? Then your output file will have just one column with the longest length as its length.

Now, use Stage variables to get the header, detail and trailer records, join them and dump them to the output file of one column.

In here, I'm guessing that the header, detail and trailer records are of different lengths. If they have same record lengths, then it will be a little easier.

Let me know if you have any questions,
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
reddy
Premium Member
Premium Member
Posts: 168
Joined: Tue Dec 07, 2004 12:54 pm

Post by reddy »

Naveen,

Sorry for confusing you guys.

Here i am giving details of my requirement:

Currently i am sending a sequential file with 20 columns to the client,client ask me to add header as a first record with filecreation date field(only one column) and trailer as a last record with no.of output records (only one column)

I am planning to create separate 2 sequential files one for header and another trailer and to append header,current file and tariler file.

Can please provide your thoughts.

Thanks for help.
Reddy
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Simply concatenate them together 'after job' with the appropriate operating system command - in the correct order, of course. :wink:

UNIX would be 'cat', Windows - copy? type? something like that.
-craig

"You can never have too many knives" -- Logan Nine Fingers
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

Reddy,

Craig gave the simplest solution for your problem. It couldn't have been much simpler.

I was under the impression that you were trying do this:

Code: Select all



Header Record
Detail Record
Trailer Record
Header Record
Detail Record
Trailer Record
Header Record
Detail Record
Trailer Record
         |
         |
         |
Header Record
Detail Record
Trailer Record

But you actually trying to do this:

Code: Select all


Header Record
Detail FILE
Trailer Record

which is much simpler.
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
Post Reply