Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Build something to handle similar reports
Message
From
19/12/2008 09:32:52
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
19/12/2008 09:23:31
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01368780
Message ID:
01368816
Views:
7
>>>>>We want to have a single report form handle a variety of similar reports. They are all somewhat related in functionality, but differ as to the tables. The table structures are also similar, but not always exactly the same. Any ideas on how to handle this best?
>>>>
>>>>I created a generic report handler many years ago, which has saved me many hours later. It takes two parameters, namely the name of the FRX and the output (screen, printer, email, file). The second parameter is analyzed by the program,. If it's empty, output goes to the screen. If it's a legal URL, output goes to a file and is converted into the format which matches the file extension. If the URL does not have any extension, it must be a printer, and is sent to it. The same happens if the second parameter is a single word, like LPT1 or Myprinter. And last, if it's a legal email address, it's sent to this address as a PDF attachment. If all fails, the program reports -1 to indicate a failure.
>>>>
>>>>Needless to say, the report takes its data from the currently selected table or cursor.
>>>
>>>I'm not sure that is what I was looking for. I'm looking for ideas on how to handle the different, but similar, data prior to printing the report. Your stuff seems interesting, but maybe I missed something as it doesn't seem to address what I asked.
>>
>>First of all, I don't do much reporting. But one lesson I learnt many years ago was to do all the data munching first, and not in the report itself. I know this is not usable in all scenarios, but for me it has always been the best way. If more than one data source/table are involved, I use SQL and/or cursors to create one single cursor wihich contains all the data for the report engine. This makes me able to use browse to see pretty much how the resulting report will look like.
>
>Ok, I think that is exactly what I was asking. How to do the "data munging" for different, yet similar, tables prior to using a single report form. I'm really not trying to be annoying, and maybe it's how I worded my original post, but your response does not seem to address what I'm trying to ask. I know I need to do the munging, but what is the best way to do that? Anyone?

For example, you might get some base fields from certain tables. Then, depending on options specified by the user, you can have conditional commands that fetch additional fields from alternate tables. The fields may even have different names, but for purposes of the report, in your cursor they end up having the same name.

The reporting commands can also have different alternatives for ORDER BY. Once again, depending on options by the user.

Macro expansion is great for these alternative reports. Here is an example:
...
if ThisForm.OpgOrderBy = 1 && by code
  lcOrderBy = "code, names"
else && by name
  lcOrderBy = "names, code"
endif
select * from TmpCursor;
  order by &lcOrderBy;
  into cursor TmpCursor
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform