Basic Iteration Help

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Basic Iteration Help

  • Creator
    Topic
  • #53348
    Jon Melin
    Participant

      I am new to iterations so thank you in advance.

      I am trying to iterate through a repeating field (PV1#7.[8]) and grab the text, and if that text equals what I am looking for I want to copy that repeated section of over. Here is an example (attachment xlate.jpg).

      Also here is my iteration config (iterate.jpg)

      Here is an example of the data coming in (ib.jpg)

      I don’t receive any results so I must be putting it in the wrong location or something similar?

      Thank you in advance.

    Viewing 0 reply threads
    • Author
      Replies
      • #77362
        Jim Kosloskey
        Participant

          Jon,

          Welcome tothe wonderful world of ITERATE!!

          First this is a field repetition.

          So your basis is incorrect. It is at the group. Note the number after the .#7 in parentheses changing with each repetition. That is the field repeitiotn.

          Your basis needs to go out to the field and you need to specify it as a field repetition and use a %f counter.

          Big thing to remember – if your basis is not correct nothing related to the repitition will be correct. It is all important to get your basis corrrect.

          Next in your COPY Actions on the Source side you need to use the %f counter you define in your basis in the parentheses after the .#7 (.#7(%f1) for example  not PV1(%anything).

          Don’t forget to use a counter on the Destination side as well.

          However, it appears you only want those repetitions which meet certain criteria to be sent out so that means you wil need to manage a separate counter for the Destination side. This is more sophisticated and involves defining a %f counter which is NOT referenced in a ITERATE.

          The general rule is if you want to reference an Iteration counter (whether one defined in a basis or not) you must place a $ in front (like this $%f1). When you want to use the counter in an address path then no $ (like this %f1).

          So I like to use something like %f99. The 9x series usage is an eye catcher that indicates to me this must be a counter I am managing.

          So you initialize your counter in the early part of your Xlate (like this COPY =0 –> $%f99).

          Then where appropriate you increment the counter (like this MATH ADD =1 $%f99 –> $%f99).

          Feel free to email me directly if you have further struggles and I will relate some tricks, etc.

          email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 60 years IT – old fart.

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