DFT^P03 Batch File?

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf DFT^P03 Batch File?

  • Creator
    Topic
  • #49425
    Rick Pritchett
    Participant

      My question is how would I translate a batch file?  I know I need to FTP it to the same server as the interface engine.  What I was wondering is how to get the engine to process the messages contained in the file correctly?

      Does cloverleaf already know how the handle the batch file information or does that need to be handled in the xlate (FHS, BHS, BTS and FTS segments)?  

      Here is a samle of the DFT^P03 message:

      FHS|^~&|ANESCHRGS|NW||NW|||||ANES200701311

      BHS|^~&|CGI1|ANESCHRGS|||20070131121835||

      MSH|^~&|CGI1||||20070131121713||DFT^P03|00000025612|P|2.3|||NE|NE||||

      EVN|P03|20070117033900||||

      PID|1||123456||LAST^FIRST|||||||||||||1001166649|||||||||||||

      FT1|1|||20070116|20070131|CHARGE|30001407|||1|5.00|||||||||||5.0|||||

      FT1|2|||20070116|20070131|CHARGE|30003455|||71|355.00|||||||||||5.0|||||

      FT1|3|||20070116|20070131|CHARGE|30000611|||1|5.00|||||||||||5.0|||||

      FT1|4|||20070116|20070131|CHARGE|30001708|||1|5.00|||||||||||5.0|||||

      FT1|5|||20070116|20070131|CHARGE|30000523|||1|25.00|||||||||||25.0|||||

      FT1|6|||20070116|20070131|CHARGE|30001370|||1|5.00|||||||||||5.0|||||

      FT1|7|||20070116|20070131|CHARGE|30001783|||1|40.96|||||||||||40.96|||||

      FT1|8|||20070116|20070131|CHARGE|30001801|||1|53.40|||||||||||53.4|||||

      FT1|9|||20070116|20070131|CHARGE|53353|||1|||||||||||||||||

      FT1|10|||20070116|20070131|CHARGE|53354|||5|||||||||||||||||

      MSH|^~&|CGI1||||20070131121722||DFT^P03|00000025624|P|2.3|||NE|NE||||

      EVN|P03|20070120211700||||

      PID|1||123457||LAST^FIRST|||||||||||||1001168925|||||||||||||

      FT1|1|||20070120|20070131|CHARGE|30003455|||110|550.00|||||||||||5.0|||||

      FT1|2|||20070120|20070131|CHARGE|30000611|||2|10.00|||||||||||5.0|||||

      FT1|3|||20070120|20070131|CHARGE|30000973|||1|5.00|||||||||||5.0|||||

      FT1|4|||20070120|20070131|CHARGE|30001708|||1|5.00|||||||||||5.0|||||

      FT1|5|||20070120|20070131|CHARGE|30000523|||1|25.00|||||||||||25.0|||||

      FT1|6|||20070120|20070131|CHARGE|30001370|||1|5.00|||||||||||5.0|||||

      FT1|7|||20070120|20070131|CHARGE|30001783|||1|40.96|||||||||||40.96|||||

      FT1|8|||20070120|20070131|CHARGE|30001801|||1|53.40|||||||||||53.4|||||

      FT1|9|||20070120|20070131|CHARGE|53353|||1|||||||||||||||||

      FT1|10|||20070120|20070131|CHARGE|53354|||4|||||||||||||||||

      BTS|513|ARI BATCH|3978|

      FTS|1

    Viewing 11 reply threads
    • Author
      Replies
      • #61901
        Mike Grieger
        Participant

          There are a couple ways to approach this, but regardless, the simple answer to your question is that YOU must set it up so that Cloverleaf can process it correctly – that is, Cloverleaf will understand what to do if the variant includes the format for the batch and any translates iterate appropriately.

          So, typically, you have a TPS that strips off header and trailer information, as this info is usually not desired to be forwarded on.  This is also a good place to do any integrity checks, if desired – that is, validate the transaction counts equal what the header/trailer states, or else there is an issue.

          From there, I can suggest a couple different options… either 1) send on the whole transaction batch in one message, making sure your variant is built for repeating structure and your Xlate handles the iterations, or 2) have a TPS built to break the transactions into individual messages and continue them on.

          I personally prefer #2.  The iteration over a large batch message can get tricky where an Xlate is concerned, as you need to remember to initialize your fields on iteration – or you could end up with data from other iterations held over if the subsequent iteration field is empty.  I also saved the individual transactions to a file for other conveniences – if we receive one big batch message, in smat it would be a single message… can get hard to work with if ever needing to find a specific inbound transaction in the whole thing.  Of course, this would also depend on exactly ‘how’ you are receiving your data – I’ve seen anywhere from the single inbound message, to headers, trailers, and transactions already broken down into separate messages – so that will help determine how you handle it.

        • #61902
          Rick Pritchett
          Participant

            How would I remove the uneeded segments and break the messages apart?

          • #61903
            Rick Pritchett
            Participant

              So far i believe this will parse of the unwanted segments.

              What does anyone else think?

              proc batch_file_parser { args } {

               global HciConnName

                 set mode [keylget args MODE]

                 switch -exact — $mode {

              start {

                 return “”

              }

              run {

                 set mh [keylget args MSGID]

                 set dispList

                   set msg [msgget $mh]

                   set fldSep [string index $msg 3]

                   set subSep [string index $msg 4]

                   set segList [split $msg r]

                       

                  lappend newsegments [lindex $segList 2]

                        set VAR “”

                         

                        while {![string equal $VAR BTS]} {

                            foreach seg $newsegments {

                   

                        set VAR [string range  $seg 0 2]

                            echo $VAR

                lappend $seg newsegments

                            echo “hello2”

                            echo $newsegments

                            echo “hello”

                       }

                } }

                }

                #echo $newsegments

                shutdown {

                   return “”

                }

                   }

                }

            • #61904
              Michael Hertel
              Participant

                If you’re certain the file will contain FHS, BHS BTS, FTS then this should be quicker:

                proc batch_file_parser { args } {

                global HciConnName

              • #61905
                Rick Pritchett
                Participant

                  could you explain the lvarpop?  It took care of the first two segments but not the last two.

                • #61906
                  Michael Hertel
                  Participant

                    lvarpop will “pop” a list element out of a list.

                    It’s counter part is lvarpush which will insert into a list.

                    The syntax is tricky in that you are naming the list and not supplying the data within the list.

                    Therefore in the example above, you “pop” from the list named msg instead of the data $msg.

                    Anyhow,

                    lvarpop msg 0 will pop the first element in the list.

                    You could capture what is popped by doing something like:

                    set firstval [lvarpop msg 0]

                    You can also replace data in a list with lvarpop.

                    lvarpop msg 0 XYZ will replace the first element in the list with the letters XYZ.

                    The command is also in the tcl help.

                    Hope this helps,

                    -mh

                  • #61907
                    Rick Pritchett
                    Participant

                      ok i added a third lvarpop to the code and it got rid of the needed segments.

                    • #61908
                      Michael Hertel
                      Participant

                        I agree that it should take 4 not 5 but you can echo to see what you’re popping.

                        It’s possible that there were two carrage returns at the end of your message.

                        It could also be that the split command may create a “last element” when it splits. I haven’t drilled into that much detail.

                        FHSrBHSrBTSrFTSr could end up with a list after split that looks like

                        {FHS} {BHS} {BTS} {FTS} {}

                        I usually get what I need and move on.

                        return $dispList would not make a difference.

                      • #61909
                        Rick Pritchett
                        Participant

                          good point ill leave that type of question for the tcl classes

                        • #61910
                          Rick Pritchett
                          Participant

                            Ok now at the end of the FT1 segment iteration should I use the continue command to break the messages apart for processing?

                          • #61911
                            Michael Hertel
                            Participant

                              I don’t use Xlates.

                              Perhaps someone else can take it from here. Jim?  ðŸ˜€

                            • #61912
                              Jim Kosloskey
                              Participant

                                Rickey,

                                The CONTINUE Action or the SEND Action will cut a message at the point in the Xlate it is executed and then continue with the Xlate until end.

                                I prefer the CONTINUE because it simply moves the message on to the next stage in the engine.

                                Don’t forget to place a SUPPRESS Action in your Xlate. If you do not, you will receive one more message than you want.

                                I usually place my SUPPRESS right at the beginning of the Xlate to ensure the SUPRESS gets executed regardless of imbedded logic (such as IF Actions or ITERATES which have no repetitions).

                                Jim Kosloskey

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

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