Passing a file name to the destination

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Passing a file name to the destination

  • Creator
    Topic
  • #48169
    Rentian Huang
    Participant

      Greetings Cloverleafers!!!

      – V5.2 on AIX

      I need to take the date in the input file name and pass it to the destination like this:

      POyyyymmddVMD.txt -> IB thread(fileset-Local) -> OB thread(fileset-Local) -> RESyyyymmdd

      Is there a way to assign part of the file name to a global variable, and this variable must be able to go across from the IB thread to the OB thread?

      Thanks in advance!

      Sam   8)

    Viewing 6 reply threads
    • Author
      Replies
      • #57888
        Ryan Spires
        Participant

          I have seen where you can store the filename into a Global until the message is created and in the engine, then store the filename into the userdata of the metadata.

        • #57889
          Rentian Huang
          Participant

            Ryan,

            Thanks for your hint!

            Sounds the only place I can find the input file name from the IB thread is in the “Directory Parse” TPS.

            Then I used this tcl to store the file name in a global variable:

            Code:

            global viamdFDate

            keylget args MODE mode
            keylget args CONTEXT context
            if {![keylget args ARGS.DEBUG debug]} { set debug “0” }
            if {![keylget args ARGS.FILTER filter]} { error “No filter argument provided” }

            set dispList {}
            switch -exact — $mode {
            start {}
            run {
            keylget args MSGID mh
            set data [msgget $mh ]

            set return_files {}
            foreach file $data {
            if [string match $filter $file] {

            set viamdFDate $file
            lappend return_files $file
            }
            }
            msgset $mh $return_files
            lappend dispList “CONTINUE $mh”
            }
            shutdown {}
            time {}
            default {
            error “Unknown mode ‘$mode’ in tps_fileset_dir_parse”
            }
            }
            return $dispList

            But when I tried to use is in another tcl, I get this error:

            Code:

            11/28/2005 16:06:01 [xlt :xlat:ERR /0:viamd_lawson_po_xlate] Tcl error:
                   msgId   = message0
                   proc    = ‘tpsSetUserData’
                   args    = ‘{{VALUE} {PO}}’
                   result  = ‘can’t read “viamdFDate”: no such variable’
                   errorInfo: ‘
            can’t read “viamdFDate”: no such variable
               while executing
            “msgmetaset $mh USERDATA ${value}_$viamdFDate”
               (”run” arm line 7)
               invoked from within
            “switch -exact — $mode {
                   start {
                       # Perform special init functions
                       # N.B.: there may or may not be a MSGID key in args
                  …”
               (procedure “tpsSetUserData” line 9)
               invoked from within
            “tpsSetUserData {MSGID message0} {CONTEXT xlt_post} {ARGS {{{VALUE} {PO}}}} {MODE run} {VERSION 3.0}”‘

            Here is the tcl that uses the global variable:

            Code:


            keylget args MODE mode               ;# Fetch mode

            ####### Global variable to hold the date in the viaMD’s file name #######
            global viamdFDate

               set dispList {} ;# Nothing to return

               switch -exact — $mode {
                   start {
                       # Perform special init functions
               # N.B.: there may or may not be a MSGID key in args
                   }

                   run {
            # ‘run’ mode always has a MSGID; fetch and process it
            keylget args MSGID mh
            keylget args ARGS.VALUE value
            #msgmetaset $mh USERDATA $value

            msgmetaset $mh USERDATA ${value}_$viamdFDate
            lappend dispList “CONTINUE $mh”
                   }

                   time {
                       # Timer-based processing
             # N.B.: there may or may not be a MSGID key in args
                   }
                   
                   shutdown {
               # Doing some clean-up work
            }
               }

               return $dispList

            Where did I do wrong???  

          • #57890
            Dennis Pfeifer
            Participant

              If the tcl procs are in a different thread, then they are not in the same TCL interpreter.

              Try placeing your 2nd proc in the IB TPS area, .. and the global should be available .. (I’m assuming that the IB DIR PARSE is in the same interpreter)…

              Dennis

              P.S.

              I’m guessing a little .. All I have at home are the good old 3.2 docs …..

            • #57891
              Rentian Huang
              Participant

                Dennis,

                I am sorry I didn’t make that clear enough:

                1. The first tcl that defines the global is in the “Directory Parse” TPS (IB thread)

                2. The second tcl that uses the global is in the Xlate Route Details “Post Procs” (IB thread)

                I need the second tcl to be in the Route Post Procs because I am, after different route details, routing the results to different file names (another tcl in the OB thread looks at the USERDATE and sets the file name for the output)

                Any more idea?

                Thanks a lot!

                Sam   😉

              • #57892
                Dennis Pfeifer
                Participant

                  the 2nd proc will need to be in the inbound thread.

                  In that proc, you’ll need to store the file name in the message, or as meta data.

                  I suggest storing it in the message itself. ..

                  The third proc will be as you descibe in the Route Post Procs, using the data in the message ..

                  Dennis

                • #57893
                  Charlie Bursell
                  Participant

                    FWIW, after many years of trying, I have been promised that in 5.4 the name of a Fileset/Local file will be placed in the meta data.  Yeah  😀

                    Dennis is correct.  For a global to be shared amog procs, the procs must run in the same interpreter.  There are three different interpreters in use in a Cloverleaf process:  The Inbound, Xlate, and Outbound.

                  • #57894
                    Rentian Huang
                    Participant

                      COOL!!! It works like magic!!!!!

                      Now I have a better idea of the Engine sharing global information.

                      Just FYI, here are the steps I did:

                      Code:


                      1. IB thread: save the input file name to a global variable in the “Directory Parse” TPS
                      2. IB thread: assign the global that contains the file name to USERDATA in IB DATA TPS
                      3. OB thread: read the USERDATA and set the input file name to the OBFILE, in the OB DATA TPS

                      You have my sincere thanks!!    😀

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