Sorry this took so long but without further adieu, attached is our solution to controlling the filename in CSC on both 4.0 and 4.3. Some caveats:
1. These assume that you have set the message up using cloverleaf before they get to CSC. Setting up the message means to add the filename on as the first line in the message and that line needs to be newline terminated.
2. Once the first line has been added it is also assumed that you base64 encoded the message.
3. The 4.3 solution shows only the csc_outbound_upoc because we do a bunch of custom stuff in the other upocs as well and they are specific to us so I did not include them here.
4. The c_file_ext.tcl file must be sourced in your cloverleaf tab on CSC for the client you are setting up.
The way that the 4.0 version works is that it delivers the file as the default filename that CSC uses (soc_), it then runs every X seconds on the client and renames that file to the filename that you want it called. This means that the receiving system needs to know not the pick up every file in that directory or you need to make modifications so that the files are placed in one directory and renamed into the directory that the receiving system is looking in.
The 4.3 version is much more straightforward, it grabs the filename from the message, writes the file out with that name, and then kills the message.
Oh, one more thing, our solution is the way that it is because we wanted to keep the ORIGINAL filename, your solution would not have to include all of those caveats if you just want to control the filename. This is because the outbound filename does not have to ride along with the message, in that case you would just create the filename in the c_file_ext.tcl or in the csc_outbound_upoc and use that to write (or rename) the file.
Care should be taken (regardless of your requirements) that you understand the fconfigure command in TCL or you WILL be pulling your hair out when trying to send out a PDF or other image file.
The usual jargon applies here in that I do not warrant that this solution will work for you. It does work for us in many different instances but you need to test it and understand exactly what it is doing before using it.
Good luck!