toupper before table

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf toupper before table

  • Creator
    Topic
  • #55329
    Brett DiNovi
    Participant

      Hello,

      I’m looking for an elegant inline way to perform a toupper function on the inbound values of a table call. I have the table and can perform toupper on the InVals as a pre-proc, but it still seems to be interpreting the lowercase values. Is there a way to execute the toupper function and the table call without having a separate row for each?

      Thanks

    Viewing 9 reply threads
    • Author
      Replies
      • #84976
        Jim Kosloskey
        Participant

          Why not use the STRING Action (if it is available in your release of Cloverleaf) or some Tcl putting thee result in a temp variable, then do the lookup with the temp variable?

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

        • #84977
          Brett DiNovi
          Participant

            I can, and have done that as a temporary solution, but I thought it’d be more appropriate to do it in a single table function.

            Instead of:

            Call 1: string toupper(input) -> @temp

            Call2: @temp -> table -> output

            I want:

            Call 1: string toupper(input) -> table -> output

            The problem is that executing the toupper function on my InVals at pre-proc doesn’t appear to affect the input to the table. It still takes the original value of my InVals.

            This isn’t a pressing need, but I like to refine code where possible and wanted to see what could/could not be done to input values of a table in-line.

          • #84978
            Jim Kosloskey
            Participant

              I think the way this works is the Action takes place THEN your code gets activated so what you want to do is not within the design constraint of the Xlate.

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

            • #84979
              Brett DiNovi
              Participant

                I’m fairly new to Cloverleaf (but not integration engines), and still trying to figure out the ropes.

                If this is the case, then what is the distinction between the pre-proc tcl insert and the post-proc insert? Where does each execute in the stream of commands?

              • #84980
                Jim Kosloskey
                Participant

                  The post proc happens after the Action and your Tcl pre (if any). However, you cannot change the output in a post proc.

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

                • #84981
                  Brett DiNovi
                  Participant

                    I’m a visual learner, so excuse my attempt at pictures, but is this the “flow” of the processing?

                    InVals -> pre-proc -> Action (table call, etc) -> post-proc -> OutVals

                    I guess if it were in that order I’d be able to achieve the processing I’m going for. Does that mean it’s more like the below?

                    InVals -> Action (table call, etc) -> pre-proc -> post-proc -> OutVals

                    Something has to take place between pre and post procs though, right? Otherwise there would be no need to distinguish between the two.

                  • #84982
                    Charlie Bursell
                    Participant

                      No.  In a COPY statement the input is always copied to the output.  You have to explicitly change it via a store to xlateOutVals.  For a CALL statement this does not happen.  You must store to outbound via XPM commands

                      If in a COPY the first action in your Xlate is like: set var [lindex $xlateInVals 0]  

                      Then:  set var [lindex $xlateOutVals 0]

                      Will produce the same results

                      We used to do this as a joke to confuse co-workers  ðŸ˜€

                      Your flow would be

                      xlateInVals => xlateOutVals _> pre proc to include set XlateOutvals to new value.  Pre proc in this context could be in line or external

                      I agree with Jim that your best bet would be to copy to a temp value that has the toupper and call Table with that

                      OR

                      Do a table call in your pre proc and set xlateOutVals with that.

                      In all of the interfaces I have ever done, and I did a few, I never had a legitimate reason to use a post proc in Xlate

                    • #84983
                      Brett DiNovi
                      Participant

                        Thanks for the breakdown, Charlie and Jim.

                        So, in summary:

                        – I can’t do any pre-processing to a tables input values

                        > Because table calls are, in essence, a COPY command, and

                        > COPY commands are only impacted by tcl procs after the value of OutVals has been set. (i.e. InVals and OutVals are functionally equivalent at tcl start)

                        > Wipe post-proc on COPY from my brain  ðŸ˜€

                        I went forward with your suggestion, but stored the temp value in the outbound message rather than a designated variable.  

                        input -> toupper(input) -> output

                        output -> table -> output

                      • #84984
                        Robert Kersemakers
                        Participant

                          As Charlie said, you can do a table lookup inside a COPY.

                          COPY infield -> outfield

                          Code:

                          lassign $xlateInVals field
                          set upfield [string toupper $field]
                          set translated [hcitbllookup table_name.tbl $upfield]
                          set xlateOutVals [list $translated]

                          or in 1 line:

                          Code:

                          set xlateOutVals [list [hcitbllookup table_name.tbl [string toupper [lindex $xlateInVals 0]]]]

                          Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

                        • #84985
                          Brett DiNovi
                          Participant

                            Future reader(s),

                            This topic was revisited amongst my team and I today, with us coming to the below determination after some additional testing with CL 6.1.2.

                            Order of Processing:

                            xlateIn -> xlateOut -> Pre-proc -> Action (table call, string, etc) -> Post-proc

                            Using the above you are able to perform an in-line table call modification so long as you modify the OutVals within a Pre-proc.

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