George,
What I need to do now is at the end of the day, somehow take that entire file, stick a header and trailer on it, and then put it somewhere to be picked up by another application. I also need to wipe out the file to prepare for the next day’s charges.
This is the kind of task a UPoC thread allows you to easily perform.
You need the “time” mode of a UPoC thread to perform your actions at the end of the day. So you configure your thread with UPoC Options –> Read TPS -> Use Advanced Scheduling, which will allow you to
1. Indicate the time when the action should be executed, for example 11:55 pm.
2. Indicate the Tcl script to be executed.
In this TPS, you just code all the things you are trying to do, including adding the header, trailer, and moving the file to destination. Since you are building a dynamic header and trailer, you will have to open the charge file, parse it, and pull the necessary fields to run the totals (quantity and charges). The number of records is simply the number of lines in your charge file. You write all of this (header, charge lines, trailer) to a new file and copy that new file to its final destination. You also dispose of your old charge file as desired (move it to an archive directory). If you move it, then you don’t have to worry about wiping it out since the append process will create a fresh file.
I am not sure what kind of outbound thread you are currently using to create your charge file, but you could actually do this whole thing in the same UPoC thread, using the run mode (UPoC Options –> Write TPS) to append messages to the file after they have been Xlated. So basically, you configure the outbound UPoC thread to do both read and write. In the write mode, it creates your charge file by appending messages coming from the Xlate. In the read mode, it reads the completed file, creates the header and trailer, and ships the modified file to destination.
I hope this helps.