7 Replies Latest reply: May 15, 2014 10:12 AM by Olly Bond RSS

    Guru Trap?

    Bowlzy101 _

      Hi All,

       

      I have been reading about the guru trap and I am finding it difficult to get an answer to my query so I have turned to 'The Forum'

       

      My data is laid out in rows like below and forms my Detail row:

       

                     

       

      Now (ignoring the legality of how silly it sounds) sometimes VAT is charged and sometimes it isnt but the VAT, if applicable, is on a second row like this:

       

                     

      VAT                                               

       

      where the word VAT is typed just under but there is no consistent approach on the Detail row so I dont believe I can use a string. I tried trapping the word VAT as a footer but it does not seem to work as items are duplicated. I have tested so many of the Advanced Settings and scenarios.

       

      Can somebody help me please?

       

      Thanks, Ian

        • Guru Trap?
          KeyserSoze _

          Hello Ian,

           

          First you need to have a detail template built that is accurately capturing your data on these rows:

                         

           

          Next, you must build an append /Itemplate using exactly the same trap characters[/I] as were used in your detail template.

           

          Finally, when painting the VAT amount field, go to the Advanced field properties and specify that the word VAT is the preceding string that appears in the same line as this field.

           

          That should do it for you. Does your model now capture the data that you want?

            • Guru Trap?
              Bowlzy101 _

              I have managed to make it work, thats excellent, but now I am not sure how it works if it is an append template. Will practice doing this.

               

              Thanks for your help

                • Guru Trap?
                  elginreigner _

                  What version are you one, with the release of 10 the guru trap was no longer needed.

                    • Guru Trap?
                      Grant Perkins

                      What version are you one, with the release of 10 the guru trap was no longer needed.[/QUOTE]

                       

                      Yep, sort of. But the more complex uses of the GT may not always be addressed.

                       

                      Plus the preceding string part of this solution (which is nothing to do with the trap as such but very often the aspect that makes it useful) is unchanged for some versions as far as I can recall so it's really a 'system' more than something that can always be replaced by a feature.

                       

                      IMO.

                       

                       

                      Grant

                        • Guru Trap?
                          elginreigner _

                          Yep, sort of. But the more complex uses of the GT may not always be addressed.

                           

                          Plus the preceding string part of this solution (which is nothing to do with the trap as such but very often the aspect that makes it useful) is unchanged for some versions as far as I can recall so it's really a 'system' more than something that can always be replaced by a feature.

                           

                          IMO.

                           

                           

                          Grant[/QUOTE]

                           

                          I can agree with that. Everyone uses the GT for their specific reports, for me, the cleared by feature has removed my need for it. But if I think about it, I could still see a use for it.

                            • Guru Trap?
                              Olly Bond

                              Hello Elgin, hello Grant,

                               

                              I'm not sure that there is a report layout where the guru trap is strictly necessary, since the Cleared By feature arrived in v10. Prior to that, any layout where there was intermittent footer data needed this approach, or a multi-pass solution. There might be some reports where preceding string won't do, as you might need to trap different data based on which column the preceding string appears in, which isn't captured. Generally, where you have lots of possible footers, and limited space between two sample detail lines, the guru trap technique can help, but you might get clearer results by manually created a sample record with all the possible footers in Notepad, and building the model on this, before switching to the real report.

                               

                              My concern is that the guru trap relies on "odd" behaviour by Monarch - why should a Append template that shares trap characters with the Detail act like a Footer that's cleared by the next Detail? Apart from the concern that one day a version of Monarch might not support this non-standard behaviour, it strikes me also that using the guru trap makes it harder for other users to understand and edit models. One of the great advantages of Monarch is that anyone, not just a programmer, can open a model and, generally, understand pretty quickly what's going on, but we should try to keep our models as intuitive as we can.

                               

                              If someone out there cares to send me a sample report where the guru trap is strictly necessary, I'd be happy to stand corrected

                               

                              Best wishes,

                               

                              Olly

                        • Guru Trap?
                          Grant Perkins

                          I have managed to make it work, thats excellent, but now I am not sure how it works if it is an append template. Will practice doing this.

                           

                          Thanks for your help[/QUOTE]

                           

                          Bowlzy101,

                           

                          Nice to see a new member form the UK, welcome to the forum!

                           

                          Yep, the GT is a bit counterintuitive although potentially very adaptable for awkward reports.

                           

                          For your purposes here there are two aspects that form the basis of the approach.

                           

                          The first is that making the Append trap the same as the detail trap means that normal Append template behaviour (apply the results to all FOLLOWING records until the next occurence of the append template is found) is simply limited to a single record. Therefore the append is always reset (and may be empty) for each DETAIL record. The key thing is that the trap does not have any part of it's definition that would fall AFTER the last defining character of the DETAIL trap.

                           

                          Secondly an Append, although it will have a know number of lines in the sample can overlap a detail section of the report and you can still extract data from that section. I have rarely found a use for that but it is possible.  As an extension of that ....

                           

                          Thirdly the entirely independent 'Preceding String' approach to selecting a data row (be sure to find unique text strings to use in the case of several similarly names fields) is avalable for detail templates as well and I think for Footers too unless anything has changed since I last experimented with footers, but not for Page Headers as far as I know.

                           

                          Basically it allows you to look for data that may be 'floating' (vertically in this case) within the body of the report and so cannot be pinned down to a line position in the template. So long as you can define a unique preceding string of characters, that always appear (before the field and on the same row) when the field data exists, you can identify the data field if it occurs anywhere between (and including) the first line of the template as defined by the trap and the last line immediately before the next occurrence of the same template. (Except for the special case of the Page Header template which should be 'invisible' to other templates.)

                           

                          There are a few limits to work within and some ways to get beyond them.

                           

                          The number of lines for a record in a report may vary a lot. Whatever the shortest detail record is (ie the number of lines you can use in the sample) is also the maximum number of lines you can have in the append template. If your append needs to find more fields than will fit on the number of lines you can use .... simply create another append template until you have enough lines for all the fields (there are some constraints on how many templates you can create in a single model but it would a rare to hit that limit.)

                           

                          Providing no fields overlap you can have several fields across a row and can mix fixed position and 'vertically floating' fields in a template is necessary. The floating fields can be on any line of the sample block where there is free space where you need it to be - only the field position across the line and the uniqueness of the preceding string are important for correct extraction.

                           

                          And that's about it. Within those basic guidlines it may well be possible to come up with some extremely neat solutions to difficult challenges presented by some reports. Fortunately most of the time things stay relatively simple it seems ... but you neve know when something especially challenging is about to land on your desk!

                           

                          Have fun.

                           

                           

                          Grant