Target ORC segment gone in data flow when needed for edit

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Target ORC segment gone in data flow when needed for edit

  • Creator
    Topic
  • #52335
    Marv Beck
    Participant

      I’m trying to do this in tcl and it should be easy.  The problem I’m having is the field I need is in the OBR segment.  By the time I drop to it in my foreach loop, the ORC segment has already gone in the data flow.  I’m trying to do this in tcl because I’m not familiar at all with translates.  I’ve attached my code.   Any suggestions would be appreciated.  

      ~marv

    Viewing 3 reply threads
    • Author
      Replies
      • #73848
        Jerry Tilsley
        Participant

          Marv,

          With the ORC and OBR segments instead of just looping through all segments trying to find them do something like this.

          Code:


          #find all OBR segments
          set obr_locations [lsearch -regexp -all $segments ^OBR]

          #now we can loop through only the OBR segments
          foreach obr_location $obr_locations {
               #Do OBR related stuff here such as finding the field you need.
          }

          #find all ORC segments
          set orc_locations [lsearch -regexp -all $segments ^ORC]

          #now we can loop through only the ORC segments
          foreach orc_location $orc_locations {
               #Do ORC related stuff here such as using the field you found in the OBR segment
          }

          You can flip the two sets of code into either order or ORB then ORC or vice versa depending on what you are doing.

        • #73849
          Marv Beck
          Participant

            Than you, Jerry, for your reply.  Your approach is clever and should work.  

            I’ve a question:  I set up the [lsearch -regexp -all $segments ^OBR] and assigned it to obr_locations.  However, when I do a “foreach obr_location $obr_locations” what I’m getting is the location of the OBR segment within the message, not the segment itself.  How do I tie the location back to the segment?

            ~marv

          • #73850
            Bob Richardson
            Participant

              Greetings,

              The lsearch returns either a -1 for nothing found or the list of indexes into the original searched upon list of (here) your OBX segments.

              So… something like:

              foreach idx $obr_list { set obr_seg [lindex $segments $idx] ; …. other logic}

              That ought to work for you.

              Enjoy.

            • #73851
              Marv Beck
              Participant

                Thank you, Bob, that did the trick.  Code is in place and working.

                ~marv

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