[U2] Cumulative Trouble in paradise

2008-02-25 Thread Allen E. Elwood
Hello,

I was just wondering if anyone else had run into this and knew *why* Unidata
version 6.1 was doing it...

I was requested to add a cumulative total to a Uniquery report.  So after
editing a subroutine to do so, and running it I found some odd quirk.  If I
make one pass with a sort and breaks, Unidata calls the subroutine during
the sort of the data, and does not call it during the display.

If I do a select first on the non-subroutine data, and then output the data
using a list, it calls the subroutine during output.

I found this out by just putting PRINT 'SUBROUTINE' into the SUBR and
running it both ways to see if I was loosing my mind or what???!!!  And I
know it's calling it during the sort because when I added the frame color to
the output it was in unsorted order.

The dict item that calls the SUBR is Frame_Color_Cum_Qty.  I can sort of
understand that Unidata might be calling the subroutine during sorting, IF
the dict item was involved in the sort.  But it's not!

And just in case someone thinks it might be just a display oddity, when I
process the entire file it prints SUBROUTINE 136 times before any of the
Uniquery display occurs, and never prints it even once during the output.
Where as with the SELECT/LIST combo it displays it during output all the way
through the output.

I know what to do to get the report running now, but was just curious if
anyone else had run into this?  I also included the SUBR in case someone
wants to see that.  It's at the bottom of the message after the two samples
of output.  (Oh, and this is already so long, please remember to snip any
responses so the low bandwidth people won't hate me!)

First example where the result is not correct due to the calling of the SUBR
during sort, and not during output:

SUBROUTINE
SUBROUTINE
SUBROUTINE
SORT FLAT.SHD BY Frame_Color BREAK.ON Frame_Color TOTAL Qty
Frame_Color_Cum_Qty
14:00:15 Feb 25 2008 1
   Cumulative
FLAT.SHD.. Frame Qty.. Quantity..

810R*1 0641120120
811F*2 0641100100
975A1*10641   1950   1950
   * -
   0641   2170

Second example where the result is correct:

SELECT FLAT.SHD BY Frame_Color BY Ship_Date

LIST FLAT.SHD Frame_Color BREAK.ON Frame_Color TOTAL Qty Frame_Color_Cum_Qty
 Cumulative
FLAT.SHD.. Frame Frame Qty.. Quantity..

810R*1 0641  0641120120
SUBROUTINE
811F*2 0641  0641100220
SUBROUTINE
975A1*10641  0641   1950   2170
SUBROUTINE
 * -
 0641   2170


  SUBROUTINE FRAME.QTY.CUM(RETURN.VALUE, FRAME.COLOR, QUANTITY)
* CLIENT.NAME.WITHHELD - Release 7.1
* FRAME.QTY.CUM - Cumulative Tot for QTY by FRAME by COLOR on
SHADE.TALLY.BY.DIECUT
  Version=~Ver=~7.1.18~50079977~
* Written Allen E. Elwood 02/02/08
*#* COPY COPY.TOOLS.BP STANDARD.COMMON ;*#* Copied Source Follows (02-21-08)
 $INCLUDE STANDARD.COMMON.VARIABLES FROM COPY.TOOLS.BP
 $INCLUDE STANDARD.COMMON.APP.PROGRAMS FROM COPY.TOOLS.BP
*#*
  COMMON /FRAMEQ/COMMON.ARRAY(3)
*
* Prime common vars
  IF 0 THEN
EQU FIRST.TIME   TO COMMON.ARRAY(1)
EQU PREV.FRAME.COLOR TO COMMON.ARRAY(2)
EQU RUNNING.TOTALTO COMMON.ARRAY(3)
  END
PRINT 'SUBROUTINE'
*
* Init this run
  IF FIRST.TIME # @DATE:@TIME:@WHO THEN
FIRST.TIME   = @DATE:@TIME:@WHO
PREV.FRAME.COLOR = 
RUNNING.TOTAL= 0
  END
*
* Logic and addition
  BEGIN CASE
CASE PREV.FRAME.COLOR = ''
  RUNNING.TOTAL = QUANTITY
CASE PREV.FRAME.COLOR # FRAME.COLOR
  RUNNING.TOTAL = QUANTITY
CASE PREV.FRAME.COLOR = FRAME.COLOR
  RUNNING.TOTAL+= QUANTITY
CASE 1
  RUNNING.TOTAL = 0
  END CASE
  RETURN.VALUE = RUNNING.TOTAL
  PREV.FRAME.COLOR = FRAME.COLOR
RETURN


Allen E. Elwood from Warm and Sunny Southern California
www.tortillafc.com
Quality Code Since 1978
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Cumulative Trouble in paradise

2008-02-25 Thread Womack, Adrian
Not sure if this solution will work in UniData (but it does in
Universe):

Try writing an iType using this code: @2;Qty+@

eg: SORT FLAT.SHD BY Frame_Color BREAK.ON Frame_Color TOTAL Qty EVAL
@2;Qty+@

The @2 means use the 2nd value defined in the iType, but because the
2nd value hasn't been evaluated yet, it uses the 2nd value from the
previous iteration (ie. The running total).

Adrian
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Allen E. Elwood
Sent: Tuesday, 26 February 2008 7:38 AM
To: U2-Users
Subject: [U2] Cumulative Trouble in paradise






DISCLAIMER:
Disclaimer.  This e-mail is private and confidential. If you are not the 
intended recipient, please advise us by return e-mail immediately, and delete 
the e-mail and any attachments without using or disclosing the contents in any 
way. The views expressed in this e-mail are those of the author, and do not 
represent those of this company unless this is clearly indicated. You should 
scan this e-mail and any attachments for viruses. This company accepts no 
liability for any direct or indirect damage or loss resulting from the use of 
any attachments to this e-mail.
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/


RE: [U2] Cumulative Trouble in paradise

2008-02-25 Thread Allen E. Elwood
Hi Adrian,

Guess it just works in Universe!

I have no problem with using the select then the list.  I had to move the
code from a report generator source to hand written 'cus the report
generator tries to do it all in one pass.

But that's ok, since I had to do that anyway 'cus the standard report was
doing the BY.EXP thang, and I had to write a small program to flatten it
first so the cumulative thing would work.  So I had to remove it from the
report generator anyway so I could add the program to the proc and it won't
disappear if someone rebuilds the library.

Man, all this work for one little field.

Allen

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Womack, Adrian
Sent: Monday, February 25, 2008 15:37
To: u2-users@listserver.u2ug.org
Subject: RE: [U2] Cumulative Trouble in paradise


Not sure if this solution will work in UniData (but it does in
Universe):

Try writing an iType using this code: @2;Qty+@

eg: SORT FLAT.SHD BY Frame_Color BREAK.ON Frame_Color TOTAL Qty EVAL
@2;Qty+@

The @2 means use the 2nd value defined in the iType, but because the
2nd value hasn't been evaluated yet, it uses the 2nd value from the
previous iteration (ie. The running total).

Adrian
---
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/