Making a field required in a VRl

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Making a field required in a VRl

  • Creator
    Topic
  • #52374
    Thomas Fortino
    Participant

      AIX 5.2

      Platform V Rel 2

      Hello All.

      I’m mapping 15 fields to | pipe delimited VRL.

      I recieved a request to update the VRL or translation to make a field required or at least make the delimiter appear even if there is no data for the field.

      What’s currently happening is if the last fields are empty then the output VRL file doesn’t contain the | delimiter.

      I looked at the Cloverleaf documentation and didn’t see how to make make the delimiter appear. The user wants to see 14 delimiters for a 15 field file at all times.

      Thanks,

      Tom Fortino

    Viewing 1 reply thread
    • Author
      Replies
      • #73954
        Jim Kosloskey
        Participant

          Tom,

          Isn’t interesting the lack of understanding some systems have regarding delimited files.

          I know of no way intrinsicaly within Cloverleaf to cause what you want.

          However, what I have done to accomodate this requirement is to add a last field (in your case a 16th field). I then COPY a literal that I know won’t be in the data actually received to this last field. This will cause all of the delimiters to appear.

          To get rid of the last field I use a reusable proc we have to remove the literal I COPY’d to the last field before the mesage is delivered (after the Xlate not inside the Xlate).

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

        • #73955
          Robert Kersemakers
          Participant

            Thanks for this tip, Jim. I had the same requirement and was wondering how to get this to work.

            Works like a charm: add an extra field to the VRL, copy something into this field and then use a tcl-proc to always remove the last field.

            Code:

            proc orbis_VRL_remove_last_field { args } {
             

             keylget args MODE mode               ;# Fetch mode
             keylget args ARGS uargs
             set debug 0         ; keylget uargs DEBUG debug
             set sep “;”          ; keylget uargs SEP sep

             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
                 set msg [msgget $mh];
             
                 set fieldlist [split $msg $sep]
                 set lengte [llength $fieldlist]
                 lvarpop fieldlist $lengte-1
                 set msgout [join $fieldlist $sep]

                 msgset $mh $msgout
                 lappend dispList “CONTINUE $mh”

                 return $dispList
               }

               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’ orbis_VRL_remove_last_field”
               }
             }

             return $dispList
            }

            Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

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