NK1 Iterate Logic

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf NK1 Iterate Logic

  • Creator
    Topic
  • #53933
    Shannon Laughlin
    Participant

      Hello!  I’m working on some code that should only send NK1;1-3 if NK1;3 = M and NK1;2.1 != null.  On the ADT coming into Cloverleaf the NK1 has multiple repeating segments but the receiving system only wants the NK1 segment for the Mother.  I have a segment Iterate on NK1 as follows:

      Action:  Iterate

      Type:  segment

      Basis: 0(0).NK1

      Variable: %n1

      The code is as follows:  

       IF  0(0).NK1(%n1).#3(0).[0] eq =M &&  0(0).NK1(%n1).#2(0).[0] ne @null

       Copy:  0(0).NK1(%n1).#1(0).[0]->0(0).NK1(0).#1(0).[0]

       Copy:  0(0).NK1(%n1).#2(0).[0]->0(0).NK1(0).#2(0).[0]

                 0(0).NK1(%n1).#2(0).[1]->0(0).NK1(0).#2(0).[1]

       Copy:  0(0).NK1(%n1).#3(0).[0]->0(0).NK1(0).#3(0).[0]

      This is the NK1 data as it is coming inbound to CL:

      NK1|1|Asdf^Asdfasdf|F||(562)543-2132||EMC

      NK1|2|Asdfasdf^Asdfasdf|M|6545 What^^Signal Hill^CA^90806|(562)652-1300||NOK||||||NO EMPLOYER|||20090505

      In this example, we only want the 2nd iteration of the NK1 to be mapped in the outbound ADT but currently, both iterations are being sent.  Any suggestions are greatly appreciated.

      Best Regards,

      Shannon

    Viewing 2 reply threads
    • Author
      Replies
      • #79592
        Jim Kosloskey
        Participant

          Shannon,

          A couple of things:

          I have never use anything but %s for the Segment repetition variables so I am unsure %n will function properly.

          The other is a question – are there any BULKCOPY or PATHCOPY Actions involved?

          If so you may find the output is already built with all of the repetitions before your logic applies. In that case if you want to keep the BULK and/or PATH copies, you will need to have logic to null out the unwanted repetitions.

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

        • #79593
          Shannon Laughlin
          Participant

            Hi Jim! I do have a bulkcopy at the beginning of my xlate and I was wondering if that was the problem.  I removed the bulk copy and the correct NK1 segment was sent outbound.  How do I null the unwanted NK1 reptitions so I can keep the bulkcopy?  I tried a few different ways to do this but was unsuccessful so far.  

            Thank you,

            Shannon

          • #79594
            Shannon Laughlin
            Participant

              Hi Jim,

              Please disregard my last question.  I figured out how to remove the additional iterations!  Thank you again for your help!

              Best Regards,

              Shannon

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