Page 1 of 1

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

Posted: Fri Feb 03, 2006 10:02 am
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

Posted: Fri Feb 03, 2006 10:58 am
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,

Posted: Fri Feb 03, 2006 11:22 am
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

Posted: Fri Feb 03, 2006 11:24 am
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.

Posted: Fri Feb 03, 2006 12:52 pm
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.