I use a similar routine to color code the buyers workbench for priority. I did some quick copy paste and tossed in the PartSubs loop and the routine below will get on hand, on order and demand for the suggested part and up to three sub parts. You will have to do the math you need from there and then put the buyers message in Character03. I use the Number01 with a row rule to color the part number for them.
HTH
Greg
/* Review codes and Colors for Buyers */
DISABLE TRIGGERS FOR LOAD OF SUGPODTL.
/* define buffer SugPODtl for SugPODtl. */
define variable sEnd_Date as date no-undo.
define variable PartPlant_PrimWhse as character no-undo.
define variable PartSubs_A as character no-undo init ''.
define variable PartSubs_B as character no-undo init ''.
define variable PartSubs_C as character no-undo init ''.
define variable Part_MinOrderQty as decimal no-undo initial 0.
define variable OO as decimal no-undo initial 0.
define variable DQ as decimal no-undo initial 0.
define variable OHQ as decimal no-undo initial 0.
define variable OO_A as decimal no-undo initial 0.
define variable DQ_A as decimal no-undo initial 0.
define variable OHQ_A as decimal no-undo initial 0.
define variable OO_B as decimal no-undo initial 0.
define variable DQ_B as decimal no-undo initial 0.
define variable OHQ_B as decimal no-undo initial 0.
define variable OO_C as decimal no-undo initial 0.
define variable DQ_C as decimal no-undo initial 0.
define variable OHQ_C as decimal no-undo initial 0.
For Each ttSugPODtl EXCLUSIVE-LOCK where cur-comp = ttSugPODtl.Company and
cur-plant = ttSugPODtl.Plant and ttSugPODtl.Sugtype = 'M' by ttSugPODtl.PartNum by ttSugPODtl.DueDate.
if ttSugPODtl.Date01 = ? or Index(whereClauseSugPODtl,ttSugPODtl.BuyerID) = 0 then next.
Message " DEBUG In GetrowsPlant " + string(ttSugPODtl.sugnum) + " pn " + ttSugPODtl.partnum.
For First Part fields (ShortChar01) where Part.Company = ttSugPODtl.Company and Part.partNum = ttSugPODtl.PartNum.
/* MESSAGE " iN FIRST PART ". */
For First PartPlant fields (MinOrderQty PrimWhse) where PartPlant.Company = ttSugPODtl.Company and PartPlant.partNum = ttSugPODtl.PartNum and PartPlant.Plant = ttSugPODtl.Plant.
Part_MinOrderQty = PartPlant.MinOrderQty.
PartPlant_PrimWhse = PartPlant.PrimWhse.
End.
For Each PartSubs fields (PartNum SubPart) where PartSubs.Company = ttSugPODtl.Company and PartSubs.partNum = ttSugPODtl.PartNum.
If PartSubs_A = '' then PartSubs_A = PartSubs.SubPart.
Else
If PartSubs_B = '' then PartSubs_B = PartSubs.SubPart.
Else
If PartSubs_C = '' then PartSubs_C = PartSubs.SubPart.
End.
OO = 0.
DQ = 0.
OHQ = 0.
OO_A = 0.
DQ_A = 0.
OHQ_A = 0.
OO_B = 0.
DQ_B = 0.
OHQ_B = 0.
OO_C = 0.
DQ_C = 0.
OHQ_C = 0.
ttSugPODtl.Character03 = "".
/* BEGIN SUGGESTION PART */
For Each PartWhse where PartWhse.Company = ttSugPODtl.Company and
PartWhse.partNum = ttSugPODtl.PartNum.
For Each PartDtl where PartWhse.Company = ttSugPODtl.Company and PartDtl.partNum = ttSugPODtl.PartNum.
If PartDtl.Sourcefile <> 'PO' then next.
OO = OO + PartDtl.quantity.
End.
DQ = DQ + PartWhse.DemandQty.
OHQ = OHQ + PartWhse.OnHandQty.
&
(Message over 64 KB, truncated)