Using the Floating Trap

In many reports particular fields of data, such as names and addresses, occur in consistent locations (i.e., they begin at the same horizontal position throughout the report). For example, in the illustration below, note how all of the customer names begin at the same horizontal position in the report, as do all of the account numbers and street names.

A report showing consistent data placement, as is typical of many reports.

 

Due to the consistent placement of data within the report, defining a trap to capture each occurrence of any one of these fields would be quite easy. With some reports, however, a standard trap won't work because data placement within them is irregular rather than consistent. In the report below, for example, note how the date/time fields (e.g., 23/Aug/2008:...) begin at different horizontal positions.

 

A report showing inconsistent placement of the date/time data.

 

In reports such as this, a standard trap will not work. Fortunately, Monarch Classic includes a special trap called the floating trap, which can successfully extract data from many log files, reports and HTML files in which the data placement is not rigidly fixed.

When using the floating trap, the following may affect the size of extracted fields:

  • A template's width serves as the maximum field length that can be extracted.

  • The occurrence of the next trap character will truncate a field.

  • The beginning of a new field will truncate a field.

When you switch from a standard trap to a floating trap, you may no longer do the following:

  • Use variable (i.e., multiple line) fields: Variable fields are not allowed on a trap line that contains a floating trap. The Advanced tab is disabled in the dialog.

When you change from a floating to a fixed trap, the following may happen:

  • The template width of some fields will be shortened.

  • The Postal trap button becomes enabled.

Note: If you are not already familiar with the template creation process, we recommend you read Creating a Template before going any further.

 

  1. Select a sample line and then go to Report Design.

  2. On the Report  Design ribbon, select New Template. You are asked to select a template role:

     

  3. Select the appropriate template role from the role drop-down.

  4. Click in the Trap box to position the cursor above a letter, number, space or punctuation character that you want to include in the trap, then type the character or click the trap button that represents the character. If necessary, use the cursor keys or the horizontal scroll bar at the bottom of the Report window to scroll the trap line and the template sample left or right.

  5. Using the sample line as an example, highlight the field(s) you want to extract. Each field highlight should be long enough to allow for long field values but not so long that you extend the highlight into another field's data. For numeric fields, which are right-aligned, the highlight should extend to the left to account for the largest number that is likely to exist in the field.

  6. Select Floating Trap on the Template Editor action bar then scroll down the report.

  7. View enough of the report to satisfy yourself that the floating trap captured all instances of the detail lines. If the floating trap missed any lines, inspect those lines to determine what modifications you need to make to the trap in order to capture them. After making the modifications preview the template once again.

  8. Select a highlighted field in the Sample Edit box and then select Edit Field on the Template Editor action bar to display the Field Properties window.

  9. In the Name field, specify a name for the field.

    If the field has a fixed-length, and the floating trap has successfully captured all instances of it, you can click the Accept button to close the Field Properties window.

    If the field has a variable length, and some instances of it are wider than the highlighting, you need to manually specify a length for it.

  10. To specify a length for the field, in the Display Width and Template Width boxes, enter a number that is large enough to accommodate the longest instance of the field.

  11. Specify the desired advanced field options on the Advanced tab of the Field Properties window. Note: The start line is restricted to the default option of Start Field on Line Number n.

  12. Select Accept to close the Field Properties window, then scroll down through the report to make sure the floating trap has successfully extracted every instance of the field, paying particular attention to the longest instance of it.

  13. If you are happy with the result, enter a name for the template in the Name box, then click the Accept button to save it.

 

 

 

© 2024 Altair Engineering Inc. All Rights Reserved.

Intellectual Property Rights Notice | Technical Support