The CALC.TURNS routine does not use @record. However, when I create the
following subroutine call I type in DICT GM.GMF it returns all zeros.
>ED DICT GM.GMF TURNS
This is a Type "I" Descriptor last compiled on 07/14/09 at 14:21.
20 lines long.
----: P7
0001: I
0002: SUBR("CALC.TURNS",SMF.LINK)
0003:
0004: TURNS
0005: 7R
0006: S
0007:
So I thought well, maybe SMF.LINK is not creating the correct keys for
the GM.SHF so I tried:
>LIST GM.GMF SMF.LINK
LIST GM.GMF SMF.LINK 02:24:22pm 14 Jul 2009 PAGE 1
GM.GMF........................ SMF LINK.......
5614862 5614862.1
5269563 5269563.1
6110292 6110292.1
5164474 5164474.1
5599851 5599851.1
5840059 5840059.1
5990189 5990189.1
4894240 4894240.1
6095281 6095281.1
OK, those are the right keys. Heres the program code:
0006: OPEN 'GM.SHF' TO GM.SHF.FILE ELSE
0007: TURNS = 0
0008: RETURN
0009: END
0010: READ REC FROM GM.SHF.FILE,GM.SHF.ID ELSE
0011: TURNS = 0
0012: RETURN
0013: END
0014:
0015: BEGIN.ON.HAND = REC<61>
0016: SALES = REC<63>
0017: END.ON.HAND = REC<64>
0018: RETURNS = REC<67>
0019: NUM.PERIODS = DCOUNT(REC<63>,@VM)
0020:
0021: AVG.INV = (BEGIN.ON.HAND<1,1> + SUM(END.ON.HAND)) / (NUM.PERIODS +
1)
0022: IF NUM.PERIODS # "0" THEN
0023: TOT.SALES = ((SUM(SALES) - SUM(RETURNS)) * (52 / NUM.PERIODS))
0024: END ELSE
0025: TURNS = 0
0026: RETURN
0027: END
0028: IF AVG.INV # "0" AND NUM.PERIODS # "0" THEN
0029: TURNS = OCONV(ICONV(100*(TOT.SALES/AVG.INV),'MD0'),'MD2')
0030: END ELSE
0031: TURNS = 0
0032: END
0033:
0034: RETURN
Anyone have any ideas?
Charles Stevenson wrote:
DAVID WADEMAN wrote: > Is there the ID of GM.SHF in GM.GMF file? If so
then you could used:
> >> ED DICT GM.GMF TURNS > 0001: I > 0002:
SUBR('*CALC.TURNS',GMF.SHF.ID)
Jeff's originally attempted
TRANS(GM.SHF,SMF.LINK,TURNS,'X')
implies that DICT GM.GMF SMF.LINK is the foreign key to the
corresponding GM.SHF record.
That's why I said that the proper I descriptor will be
DICT GM.GMF TURNS
01: I
02: CALL( '*CALC.TURNS', SMF.LINK )
That assumes that CALC.TURNS doesn't do something like assume @RECORD
contains the current GM.SHF record.
If it does, it will need to be altered to pass the record as an
argument, instead/
Then you'd use it in 2 I-descriptors as:
DICT GM.SHF TURNS
01: I
02: SUBR( '*CALC.TURNS', @ID, @RECORD )
DICT GM.GMF TURNS
01: I
02: SUBR( '*CALC.TURNS', SMF.LINK, RAISE(TRANS( GM.SHF, SMF.LINK,
-1,'X')))
The "-1" trans arg means return the whole record.
The RAISE() is because TRANS() automatically lowers all delimiters a
notch. (Why that is, is for another thread.)
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users
--
------------------------------------------------------------------------
Jeff Schasny - Denver, Co, USA
jschasny at gmail dot com
------------------------------------------------------------------------
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users