Change OBFilename

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Change OBFilename

  • Creator
    Topic
  • #47851
    Nora Katz
    Participant

    Question:

    Is there some way to make a filename for an OutBound File by incorporating the name of the original file?  

    Example:  inbound file name:  “somefilename”

                   OBFILE as defined in Protocol:  obfilename

                   unique outbound filename:  obfilename_somefilename

Viewing 13 reply threads
  • Author
    Replies
    • #56898
      David Caragay
      Participant

      Nora,

      I would use the msg metadata to pass the inbound file name to the outbound thread and then name your ob filename using this passed data.

    • #56899
      Anonymous
      Participant

      Nora,

      The key will be capturing the original file name in the first place.  Are you using fileset local to read the file?  FTP?  Did you write a file reader procedure of your own?

      Once you have the file name then you will want to stash the file name in the driver control metadata field so that it travels along with the message until the end and the driver will then use that file name to write it out.

      FYI, you can’t save the file name in a global variable because each thread has it’s own namespace and Cloverleaf doesn’t publish the namespace names anywhere.

      Let me know how you’re reading the file and either me or someone else can tell you how to capture the file name.

      Cheers,

    • #56900
      Nora Katz
      Participant

      Greg,

      I developed a tcl proc to process a file, so I chose the protocol: file, and I manually changed the file name each time I had a file to process.   I didn’t think this procedure would be used extensively.  Now, I find that I need to process quite a few files, and manually changing the file name each time was too tedious.   I would like to use the protocol:  fileset-local and process all files in a given folder.

      Nora

    • #56901
      Anonymous
      Participant

      Nora,

      Using fileset local you will have to write a directory parse TPS procedure that will save the file name in a global variable so that when the driver reads the file you can take the global variable and store it into metadata (IB data TPS).  This also means that your directory parse procedure will have to restrict reads to one file at a time.

      There has been a change request that has been around for a while for the engine to store the file name in metadata automatically but it hasn’t been implemented yet.

      The alternative to all this would be to write a procedure that reads a file.

    • #56902
      Nora Katz
      Participant

      Greg,

      Are there any examples around that I can look at?  

      Nora

    • #56903
      Anonymous
      Participant

      I haven’t had a project where I did what I was suggesting, that’s just how I would do it.  Someone will have to jump in with examples of writing procedures for directory parse.  I’m writing my self a not to include a dir parse procedure in class though 😉

      To give you a place to start, create a fileset local thread and write a simple dir parse procedure that echo’s the message text.  You’ll find that it’s actually the list of files that would be read by the file driver.  You can manipulate that list using TCL.  What ever list of files that you continue will be the list that the driver will read.

    • #56904
      Bakha Nurzhanov
      Participant

      Nora – e-mail me if you have questions.

      Nora Katz wrote:

      Question:

      Is there some way to make a filename for an OutBound File by incorporating the name of the original file?

    • #56905
      Jason Melton
      Participant

      Hi,

      Im a bit new to all of this can some and am hoping i can get some pointers from anyone that has used these bits of tcl as to where I am going wrong.

      I have tried to use the above files and get an error in my output from ftp_file_archive saying can’t read “fileName” : no such variable.

      I have 2 threads.  conn1 using protocol fileset-ftp  and collects the file with ftp_file_fetch  on the directory parse tps.

      Adding a few echos to the script and i can see the filename and the contents.

      I then have a static raw route to conn2 which connects to another ftp server and hopefully writes the file.  It seems to be this point which is dieing.  

      No doubt im doing something stupid  ðŸ™„

      Regards,

      Jason

    • #56906
      Jim Kosloskey
      Participant

      Jason,

      Make sure your metadata USER field has a keyed list with the key OBFILENAME. It is from that key (OBFILENAME) that the proc in question is setting the value of fileName variable.

      If the OBFILENAME does not exist in the USERDATA metadata field, then the variable fileName will not get established thus the error you see.

      Jim Kosloskey

      email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

    • #56907
      Michael Hertel
      Participant

      I didn’t realize that I was reading a rebirth of an old post until now but….

      The 5.4 docs say that there is a new DRIVERCTL item named FILENAME to attach the inbound filename to the message.

      This is cool, I’ll have to look at this closer.

      -mh

    • #56908
      Bakha Nurzhanov
      Participant

      I have not had chance to install 5.4 yet and it would be great if metadata will have ability to carry FILENAME with the message through the engine.

      Jim is absolutely right. I have another set of procs that do set OBFILENAME key list value in message metadata. Let me know if you want me to send that to you via e-mail or whether I should post it on the board.

      Essentially it takes file name from inbound Fileset-Local or Fileset-FTP and stuffs it into userdata in metadata.

      Drop me a message here or e-mail me.

    • #56909
      Jason Melton
      Participant

      Hi Bahka,

      If you could post that it would be very useful.

      Kind Regards,

      Jason

    • #56910
      Bakha Nurzhanov
      Participant

      Here is the TCL code (see attached). Please note that you need to have both TCL procs work in tandem with each other to capture file name into a global variable first and then populate USERDATA meta data field with the value of that global in the second proc. See attached screenshots for proc placement.

      Hopefully this helps.

    • #56911
      Jose Carrasquillo
      Participant

      Hi Bakha,

      Could you attach tcl proc “ftp_set_obfile_ibdel”?

      Thanks,

Viewing 13 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,126
Forums
28
Topics
9,295
Replies
34,439
Topic Tags
287
Empty Topic Tags
10