Help with FRL and repeats

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Help with FRL and repeats

  • Creator
    Topic
  • #53282
    Yamil Velez
    Participant

      Hi All

         I am new to FRL and how to combine and repeat them.  I am trying to take an FRL message that is compose 2 recorded types one is the header and the other is line both have a max length of 830 characters

      Header record type starts with H

      Line record types start with L

      A message is something like this

      Hxxxxxxxxxxxxxxxxxxxxxxxx Lxxxxxxxxxxxxxxxxxxxxxx

      xxxxxxxxxxxxx Lxxxxxxxxxxxxxxxxxxxxxxxxxx

      xxxxxxxxxxxxxxxxxx Hxxxxxxxxxxxxxxxxxxxxxxxxxxx

      xxxxxx Lxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

      xxxxxxxxxxxxxxxxxxx Lxxxxxxxxxxxxxxxxxxxxxxxxxxxx

      xxx Hxxxxxxxxxxxxxxxxxxxxxx

      In the illustration above a header repeats and so does the Line

      I thought the solution would be is to create one FRL(header) and two FRL(line).  Then I would use an HRL to combine,  don’t know if this the right approach.  

      In the HRL message  I have a header with a repeat while record_type value equals H and condition value equals H

      In the Line record type  I have  a repeat while company code equal L and the conditjon value equals L

      So my problem is that when I use the tester using the tab HRL.   I am only seeing the header record type and once the line record type.  

      I am also getting the error below

      [0:TEST] header: CONDITION field header.record_type must come before header

      [0:TEST] header2: REPEATWHILE field header.record_type must be in the same field

      Thank you in advance for your help with this

      Yamil

    Viewing 7 reply threads
    • Author
      Replies
      • #77146
        Robert Kersemakers
        Participant

          Hi Yamil,

          I have a few points with your configuration.

          First: is it really necessary to define 2 L-FRLs? If these L-FRLs are really different, you also need to be able to distinguish them and define them in your HRL. If these L-FRLs are not in a specific order (something like ‘L1, L1, L2, L1’) then you have a problem and you won’t be able to solve it this way. If the order is ‘L1, L1, L2’ or ‘L1, L2 L2’ or ‘L2, L2’, then you can use an HRL.

          Second: you don’t need to repeat your H-FRL in the HRL. It only occurs once, so just put it on ‘No Repeat’.

          Third: If you want to completely solve this with HRLs/FRLs, you will need to define HRLs within an HRL. Because you have multiple H/L-occurrences within one message, you will need to group these H/L-occurences (which are defined with the HRL you already have) within a new HRL, so you can repeat the H/L-occurrences. I hope this makes sence.

          Another way of doing this (and I have done this before, because I think it’s easier) is to make a tcl-proc to break the one message with several H/L-occurences into several messages with only one H/L-occurence. This way you only need one HRL-definition.

          Hope this helps.

          Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

        • #77147
          Laurie Chaplen
          Participant

            I have a question that is related.  I have a file that comes in that has repeating segments (each in FRL and each segment with a different FRL layout):

            000

            001

            002

            003

            000

            001

            002

            003

            So in order for it to work, I have created the 4 FRL layouts and put them in an HRL but it isn’t working.  Will I instead create 4 HRLS and put them into 1 HRL?  

            Any help welcome.

          • #77148
            Robert Kersemakers
            Participant

              Hi Laurie,

              It should work with the 4 FRLs you’ve created: put them in one HRL and set all these FRLs to ‘No Repeat’ (I assume that’s the case).

              What you need to watch though, is the end of each FRL: is there a CarriageReturn or NewLine in the FRL? You will need to include it in the definition of the FRL then.

              Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

            • #77149
              Laurie Chaplen
              Participant

                There is a newline that has a blank line after each set:  How do I define the newline after the 003?

                000

                001

                002

                003

                000

                001

                002

                003

              • #77150
                Robert Kersemakers
                Participant

                  Oops, I oversaw something: you have 2 sets, so there are 2 HRLs in this one message.

                  What I normally do is use a pre-Xlate tcl proc to split this one message with 2 (or more) HRLs into 2 (or more) messages with each 1 HRL. This is the easiest way to get one HRL per message. After this you can translate the HRL.

                  Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

                • #77151
                  Laurie Chaplen
                  Participant

                    I have more than 2 sets of:  

                    000

                    001

                    002

                    003

                    each are divided by a newline (via a tcl proc).  Currently the raw message doesn’t have a new line between each set of 000-003.

                    Could you send me the tcl proc to break the sets into messages and then a post proc to put them back (or could I use the append function) as the data is coming in as a batch file.

                  • #77152
                    Laurie Chaplen
                    Participant

                      To clarify I have 1 HRL with 4 FRL’s within it.  The messages are in a batch file and the number of messages will be different per batch file.  A message is comprised of:

                      000

                      001

                      002

                      003

                      Newline (via a tcl proc) in the raw file there is no Newline dividing the sets of messages within the batch file.

                      When I test my HRL each of the FRL components is spot on.  In the testing tool when I test the HRL it works only if I do and EOF not New Line terminated.  It appears that it will read only the first message in the batch file an not the remaining messages.

                      I hope this helps.

                    • #77153
                      Robert Kersemakers
                      Participant

                        I understand your problem: the HRL defines only one message, while your file consists of multiple messages and therefore multiple HRLs.

                        I don’t really have a tcl-proc that would suit you. I can only give you one where the input is a file where each message is a STA-segment followed by several TXT-segments. This is repeated several times in one file. So with this proc I split this one file into several messages:

                        Code:

                        ######################################################################
                        # Name: verwerk_specbrief_3
                        # Purpose: Omzetten van de specialistenbrief zoals die, via een ‘ish-hcm’ file, wordt aan
                        #                      aangeboden naar het HRL-formaat specbrief.
                        # UPoC type: tps
                        # Args: tps keyedlist containing the following keys:
                        #       MODE    run mode (”start”, “run” or “time”)
                        #       MSGID   message handle
                        #       ARGS    user-supplied arguments:
                        #              
                        #
                        # Returns: tps disposition list:
                        #          Disposition list bevat berichten in ‘specbrief’ VRL-formaat
                        #

                        proc verwerk_specbrief_3 { args } {
                           keylget args MODE mode               ;# Fetch mode

                           set dispList {} ;# Nothing to return

                           switch -exact — $mode {
                               start {
                                   # Perform special init functions
                           # N.B.: there may or may not be a MSGID key in args
                               }

                               run {
                           # ‘run’ mode always has a MSGID; fetch and process it
                                   keylget args MSGID mh
                                   # Kill van originele bericht (hele file)
                                   lappend dispList “KILL $mh”

                                   set seglist [split [msgget $mh] nr]
                                   set lengthSTA 1259
                                   set lengthTXT 250
                                   set leegSTA [string repeat ” ” $lengthSTA]
                                   set leegTXT [string repeat ” ” $lengthTXT]
                                   set firsthead 1
                                   set newmsg “”
                                   foreach seg $seglist {

                                     # Lege regels eruit halen!
                                     if {[clength $seg] > 2} {
                                       set segnaam [string range $seg 0 2];

                                       if {$segnaam == “STA”} {
                                         # Indien STA-segment en het is niet het eerste STA-segment: nieuw bericht versturen!
                                         if {$firsthead != 1} {
                                           set mhn [msgcreate $newmsg];
                                           lappend dispList “CONTINUE $mhn”;
                                         }
                                         # ‘newmsg’ wordt nu gelijk aan de eerste 1259 karakters van het STA-segment
                                         set newmsg [string range “${seg}${leegSTA}” 0 $lengthSTA];
                                         set firsthead 0;

                                       } else {
                                         # Dit is het TXT segment; van de eerste 250 karakters worden de gevulde karakters genomen (trim)
                                         set tekst [string range $seg 3 [expr $lengthTXT + 3]];
                                         set newmsg [cconcat $newmsg “TXT” [string range “${tekst}${leegTXT}” 0 [expr $lengthTXT – 1]]];
                                       }
                                     }
                                   }

                                   # Na afloop van alle segmenten het laatste bericht nog versturen
                                   set mhn [msgcreate $newmsg];
                                   lappend dispList “CONTINUE $mhn”;

                               }

                               time {
                                   # Timer-based processing
                           # N.B.: there may or may not be a MSGID key in args
                               }

                        shutdown {
                           # Doing some clean-up work
                        }

                               default {
                           error “Unknown mode ‘$mode’ in verwerk_specbrief_3”
                               }
                           }

                           return $dispList
                        }

                        Of course all comments are in Dutch… But I hope you get my drift.

                        Afterwards you said you need to put the messages together again. You could do this by putting all messages in a file again.

                        Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

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