Delete repeating segment in xlate

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Delete repeating segment in xlate

  • Creator
    Topic
  • #48139
    April Dunbar
    Participant

      Good morning,

      I am trying to delete an instance of the DG1 segment if the DRG type = PROVISIONAL within an iterate.  I have tried different approaches, but I haven’t been able to achieve the result I want yet.  Any help/suggestions would be greatly appreciated!

      Here is what I have in my xlate:

      Iterate – type (segment), basis (1(0).0(0).DG1), variable (%s1)

          If (1(0).0(0).DG1(%s1).00380.[0].[0] eq =PROVISIONAL

                 Copy (1(0).0(0).DG1(%s1).00380.[0] -> @null)

      *I have tried to suppress the record (removed the copy) and it deletes the messages for those that meet the IF statement.  So I know the IF is correct, I just can’t figure out how to get rid of the one DG1 segment and pass the rest of the message with the good DG1 segments.

      Thanks, April 😕

    Viewing 2 reply threads
    • Author
      Replies
      • #57802
        Jonathan Hamilton
        Participant

          I think your problem is you are trying to modify the input record layout when really you just want to control what is going into the output record layout.  You can’t modify the input record layout in Xlate.

          One option is simply to not map the DG1 to the destination record layout.  If you are using bulkcopy you would need to replace it with several pathcopies for each segment you want included.  Then in your if statement if true do nothing else pathcopy the DG1 that you want.

          If (1(0).0(0).DG1(%s1).00380.[0].[0] eq =PROVISIONAL

                    COMMENT {DO NOTHING!”}

          ElseBody

                    Copy (1(0).0(0).DG1(%s1).00380.[0] -> @null)

          Another option would be to use pathcopy @null in place of your copy.  I have had problems in the past that the segment header would remain after removing the remainder of the segment.

          Pathcopy (@null -> 1(0).0(0).DG1(%s1))

        • #57803
          Jim Kosloskey
          Participant

            Johnathon,

            do you see that effect (empty segment) when using PATHCOPY even if the target segment is an optional segment?

            The reason I ask is although I have never used PATHCOPY to null out a segment in a repeating group or repeating segment, I have eliminated segments when the segment is defined as optional. When the segment is defined as required and the individual fields are nulled the segment will still exist because it is required.

            Jim Kosloskey

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

          • #57804
            Jonathan Hamilton
            Participant

              It was an optional OBX segment.  I ended up writing a post_xlt_tps scripts that deleted empty OBX segments to fix the problem.  This was also back on 3.8.1P and I haven’t tried duplicating it on newer versions.  Now I typically try to only populate what I need so I don’t have to back the data out.

              Jonathan

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