# RE: Looking for associated multi-value algorithm...

```All Righty, then!  Just for grins, here's an alternative:

SPECIAL.PARTS = SPECIAL.REC<12>
POS = 0
SPECIAL.FROM.QTY.TEMP = 0
REMOVE SPECIAL.PART.NBR FROM SPECIAL.PARTS SETTING MORE.PARTS
POS += 1
IF SPECIAL.PART.NBR = PART.NBR THEN
SPECIAL.FROM.QTY = SPECIAL.REC<14, POS>
IF SPECIAL.FROM.QTY < QTY.REQUESTED AND SPECIAL.FROM.QTY >=
SPECIAL.FROM.QTY.TEMP THEN
TEMP.POS = POS
SPECIAL.FROM.QTY.TEMP = SPECIAL.FROM.QTY
END
END
WHILE MORE.PARTS DO
REPEAT
DATA.OUT = OCONV(SPECIAL.REC<16, TEMP.POS>, MDP) "R#12"
RETURN```
```
Have fun!

Jeff Fitzgerald
Fitzgerald & Long, Inc.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, March 16, 2004 3:59 PM
To: [EMAIL PROTECTED]
Subject: RE: Looking for associated multi-value algorithm...

There can, and usually are, multiple instances of the same part number.
What makes a "row" unique is part number + from qty.  Thanks for pointing
out the doubling up of the SPECIAL.FROM.QTY assignment though.

-----Original Message-----
From: Jeff Fitzgerald [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 16, 2004 4:28 PM
To: 'U2 Users Discussion List'
Subject: RE: Looking for associated multi-value algorithm...

Well, the first thing I notice is that your for/next counter, SPECIALPART,
isn't used anywhere...  Using LOCATE will search for the PART.NBR in the
whole SPECIAL.PARTS field, so the for/next isn't needed.

Next, I notice that this assignment:
SPECIAL.FROM.QTY=SPECIAL.REC<14,SPECIAL> is duplicated, once just before the
IF and once just after the THEN.  One of them can probably be dropped.

Hope this helps some....

Jeff Fitzgerald
Fitzgerald & Long, Inc.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, March 16, 2004 3:18 PM
To: [EMAIL PROTECTED]
Subject: Looking for associated multi-value algorithm...

I'm looking for an algorithm for searching through a group of associated
multi-value fields.  The fields are F12 (PartsList), F14 (From Qty) and F16
(Unit Price).  I can't depend on these being in any certain order, just that
the associated fields will be in identical order.  What I want to return is
the Unit Price (F16) given PART.NBR and QTY.REQUESTED.  I've got a code
snippet of what I think will work, but I'd like to get some feedback on
it...it won't work because, there's a better way of doing this, etc.
Thanks.

SPECIAL.PARTS = SPECIAL.REC<12>
SPECIALCOUNT = DCOUNT(SPECIAL.PARTS,VM)
SPECIAL.FROM.QTY.TEMP = 0
FOR SPECIALPART = 1 TO SPECIALCOUNT
LOCATE PART.NBR IN SPECIAL.PARTS<1,STARTPOS> SETTING SPECIAL ELSE EXIT
SPECIAL.FROM.QTY=SPECIAL.REC<14,SPECIAL>
IF SPECIAL.FROM.QTY<QTY.REQUESTED AND
SPECIAL.FROM.QTY>=SPECIAL.FROM.QTY.TEMP THEN
SPECIAL.FROM.QTY = SPECIAL.REC<14,SPECIAL>
SPECIAL.PART.PRICE = SPECIAL.REC<16,SPECIAL>
TEMP.OUT = OCONV(SPECIAL.PART.PRICE,MDP) "R#12"
SPECIAL.FROM.QTY.TEMP = SPECIAL.FROM.QTY
END
STARTPOS = SPECIAL + 1
FIRST = 0
NEXT SPECIALPART
DATA.OUT=TEMP.OUT
RETURN
--
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users
--
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users
```
```--
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users
```