Xlate That Should Be Easy (If It Weren’t Obvious)

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Xlate That Should Be Easy (If It Weren’t Obvious)

  • Creator
    Topic
  • #51537

    Clearly I am missing something obvious (this happens all the time) with an Xlate I am trying to do and cannot seem to get to work for the life of me.

    I’ve got a situation where I am trying to “clean up” some incoming data when I send it out. Specifically, I have TXA-23 coming in with (possibly) multiple repeating values, eg:

    |ABC~XYZ|

    This is fine as far as it goes, but sometimes what comes in (sending system’s fault) is something like:

    |~ABC|

    In this scenario I would like to “clean up” that field and send it out as:

    |ABC|

    for the benefit of the receiving system, which creates false errors if the first occurrence is empty. However, if there are multiples, like the first example, I’d like that to go out as is.

    What I tried to do was set up a counting mechanism, and evaluate the value of the occurences via the ITERATE command, and map them out if valued but not if unvalued, like so:


    COPY =0 —> @TXA23CNT

    ITERATE
    (Type: field, Basis: 0.(0).TXA.#23, Variable %f1)

    [code]
    COPY =0 —> @TXA23CNT

    ITERATE
    (Type: field, Basis: 0.(0).TXA.#23, Variable %f1)

Viewing 3 reply threads
  • Author
    Replies
    • #70698
      Jim Kosloskey
      Participant

        Daniel

        Change the condition to check for @null not =

        You can’t use a temp variable as a counter.

        Instead of @TXA23CNT us something like %f99 inside the address pathing for the field. When using %f99 as a variable (like inside the MATH Action) put a $ in front like this: $%f99.

        Something like this:

        COPY =0 —> $%f99

        ITERATE

        (Type: field, Basis: 0.(0).TXA.#23, Variable %f1)

         IF 0.(0).TXA.#23(%f1) ne @null

           COPY 0.(0).TXA.#23(%f1) —> 0.(0).TXA.#23(%f99)

           MATH ADD:  =1 $%f99—> $%f99

        %f99 becomes now the counter you manage and the Xlate will honor the value it contains (temp variables used as iteration counters get equated to 0).

        I like to use 99 (%f99) for counter I manage as a visual reminder this is a counter I manage.  My thinking is I am unlikely to reach 99 for any Xlate managed iteration counters.

        I also use plenty of comments to remind me.

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

      • #70699

        Thanks Jim!

        See, I knew this, but had forgot the obvious (use %f99 for the counter)…

      • #70700

        Hmm…well, it “works” now, in that if I get |ABC~XYZ| coming in, I get |ABC~XYZ| going out.

        Strangely, maddeningly, though – if I get |~ABC| coming in, I still get |ABC~ABC| going out. This isn’t the end of the world, as I think it will work as a practical matter (ie, receiving system will take it), but it is not what I would expect it to do.

        Odd, no?

      • #70701

        *DUH*

        Nevermind, I need to override the original BULKCOPY first to clear out the output field.

        *DOUBLE DUH*

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