Conversion from QUIZ to QTP, Part II
Ohmes, Matt
Matt.Ohmes@COGNOS.com
Fri, 9 Jul 1999 10:53:36 -0400
Hi Rich,
Well, I think Michael Lee and Charlie Maloney explained the timing situation
pretty well, so I won't dwell on that too much. Although, if you'd like, I
do have a paper I wrote ages ago (and which I am still huckstering for all
it's worth)called "The Care and Feeding of QTP". If you'd like me to e-mail
you a copy, just drop me a line.
However I do want to add a few other comments which may help in your
transition from Quiz to QTP.
You naturally want to use Defined items a lot, after all, that's all Quiz
had, so you're comfortable with them. The Temporary item in QTP however, is
much more flexible and usually much more efficient. There are also a few
advantages to using summary functions (like COUNT) in QTP, especially with
temporary items.
In QTP, defined items are simply names for expressions. By that I mean,
when you reference the name, QTP evaluates the expression and returns the
result. If you reference a name 10 times (and that is easier than it sounds
in QTP), it gets evaluated 10 times, even if you haven't changed anything.
You cannot STORE a value in a defined item.
A temporary item, on the other hand, is a storage location. You load a
value into it with an Item statement. It will retain that value until that
Item statement is reprocessed (say on the next transaction) or some other
Item statement changes it.
The main advantage is performance. The main disadvantage is that Temporary
items don't contain values until the output phase of processing so you can't
use them very well for Select or Sort statements.
Your code seems to be pretty clean in it's use of Defines, but it can be a
little tricky. For example:
DEFINE D_TODAYS_DATE DATE = SYSDATE
...
ITEM TODAYS_DATE FINAL D_TODAYS_DATE
In the first place, I'm not sure why you didn't simply say:
ITEM TODAYS_DATE FINAL SYSDATE
but assuming there was some good reason, this code would be more efficient.
Temporary T_TODAYS_DATE DATE
Item T_TODAYS_DATE INITIAL SYSDATE
...
ITEM TODAYS_DATE FINAL T_TODAYS_DATE
The Define would cause QTP to check on every single transaction to see what
day it was. The Temporary would be assigned a value at the beginning of
output processing and then simply load that value into TODAYS_DATE on each
transaction.
Now, as for the matter of summary functions in QTP.
In Quiz you can only report the summary function COUNT. You can't assign it
to another item or COUNT conditionally. You can do both of those things in
QTP!
Here is your code:
DEFINE D_GROUP_COUNT NUM*5 = 1 IF (1 = MY_CRITERIA) ELSE 0
TEMPORARY T_GROUP_COUNT NUM*5
ITEM T_GROUP_COUNT SUBTOTAL D_GROUP_COUNT AT SORT_STUFF
Instead, try this:
TEMPORARY T_GROUP_COUNT NUM*5
ITEM T_GROUP_COUNT COUNT &
IF (1 = MY_CRITERIA) &
AT SORT_STUFF
NOTE: I am NOT addressing your timing problems, just showing other
interesting tidbits from QTP.
I hope that helped some, and I hope you have lots of fun!
Matt
Matt.Ohmes@Cognos.Com
Cognos Corporation
909 E. Las Colinas Blvd.
Suite 1900
Irving, TX 75039
214-259-6200
-----Original Message-----
From: Rich `Lego-Man' Jesse - 7633 [mailto:RJESSE@QTIWORLD.COM]
Sent: Thursday, July 08, 1999 4:19 PM
To: powerh-l@lists.swau.edu
Subject: Conversion from QUIZ to QTP, Part II
Hey again,
I've got everything in my QUIZ report converted to QTP (733d3 on HP 10.20
accessing an Oracle 7.3.4.3.0 db), except for a counter that's giving me
some
trouble. I've looked in the manuals, looked at examples, and tried a bunch
of
variations on the counter with no luck.
Here's the closest I've come to obtaining the correct results (just a
working
fragment of the actual code):
RUN QT123
REQUEST QT123
SET PROCESS NOLIMIT
SET LOCK FILE UPDATE
ACCESS DB_FILE01 &
LINK MY_KEY OF DB_FILE01 VIAINDEX F02_MY_KEY TO DB_FILE02
DEFINE COMPARE_TODAYS_DATE NUM = DAYS(SYSDATE)
DEFINE D_TODAYS_DATE DATE = SYSDATE
DEFINE D_FILE_TEST_DATE NUM = DAYS(FILE_TEST_DATE OF
DB_FILE02)
DEFINE D_MASTER_LABEL_COUNT NUM*5 = 1
DEFINE D_TOT_QTY FLOAT SIZE 8 = (QTY01 OF DB_FILE01 + QTY02 OF DB_FILE01)
DEFINE SORT_STUFF CHAR*34 = ORDERNO OF DB_FILE01 + &
OTHERNO OF DB_FILE01 + PARTNO OF DB_FILE01
DEFINE MY_CRITERIA NUM*1 = 1 IF (D_FILE_TEST_DATE >= COMPARE_TODAYS_DATE)
OR &
(RSTATUS OF DB_FILE02 = "R" AND CFLAG OF DB_FILE02 = "Y" AND &
LFLAG OF DB_FILE02 = " ") ELSE 0
SELECT IF 0 <> D_TOT_QTY
SORT &
ON MY_CRITERIA &
ON FILE_TEST_DATE OF DB_FILE02 &
ON SORT_STUFF
DEFINE D_GROUP_COUNT NUM*5 = 1 IF (1 = MY_CRITERIA) ELSE 0
TEMPORARY T_GROUP_COUNT NUM*5
ITEM T_GROUP_COUNT SUBTOTAL D_GROUP_COUNT AT SORT_STUFF
OUTPUT QT123_FILE ADD
ITEM ORDERNO FINAL ORDERNO OF DB_FILE01
ITEM FILE_TEST_DATE FINAL FILE_TEST_DATE OF DB_FILE02
ITEM TOT_QTY FINAL D_TOT_QTY
ITEM TODAYS_DATE FINAL D_TODAYS_DATE
ITEM GROUP_COUNT FINAL T_GROUP_COUNT
GO
EXIT
My problem is the item GROUP_COUNT. The count is short by one. It's
missing
the first group. Maybe it's a problem with the way I'm doing the
subtotaling?
Or maybe a problem of timing between the AT SORT_STUFF and when the DEFINEs
and
TEMPORARYs get evaluated?
I've checked thru the QTP Reference manual, the "Using QTP" manual, and the
Cognos website. I figured I'd stop here first before logging a call.
Any info is appreciated! TIA!
Rich Jesse Programmer/Analyst
(/DBA/SysAdmin/etc.)
rjesse@qtiworld.com Quad/Tech International, Sussex, WI
USA
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Subscribe: "subscribe powerh-l" in message body to majordomo@lists.swau.edu
Unsubscribe: "unsubscribe powerh-l" in message to majordomo@lists.swau.edu
powerh-l@lists.swau.edu is gatewayed one-way to bit.listserv.powerh-l
This list is closed, thus to post to the list, you must be a subscriber.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Subscribe: "subscribe powerh-l" in message body to majordomo@lists.swau.edu
Unsubscribe: "unsubscribe powerh-l" in message to majordomo@lists.swau.edu
powerh-l@lists.swau.edu is gatewayed one-way to bit.listserv.powerh-l
This list is closed, thus to post to the list, you must be a subscriber.