On the Add the typecode will be M or P and the PartPlant record won’t exist yet. I have the same Part defaults on Part.Update with a condition of the TypeCode changed from M to P and vis versa. For PartPlant I use a data directive. The one below should be close. The fields limits the data returned to speed the read up.
The if rowmod then end at the top doesn’t do anything so it can be removed. The top section is one assign with a period at the end. That is the fastest rather than multiple assigns. I don’t think with four values it would matter, but wanted to show you what I meant.
You are updating so you don’t want no-lock, but I think the assign will override that anyway.
I don’t think the numerics need quotes and again I would assign the buyer at the partclass rather than the part.
I’ll be offline till after lunch.
Greg
For each ttPart where ttPart.Rowmod = ‘A’ no-lock.
If ttPart.TypeCode = ‘M’ Then Do:
/* Set Manufactured part Defaults */
Assign ttPart.UsePartRev = true.
ttPart.Constrained = true
ttPart.ProdCode = ‘Spare’
ttPart.ClassID = “WIPG”.
End.
If ttPart.TypeCode = ‘P’ Then Do:
/* Set Purchased part Defaults */
Assign ttPart.ProdCode = ‘Spare’.
Assign ttPart.ClassID = “RAWM”.
Assign ttPart.UsePartRev = false.
Assign ttPart.PartConstrained = true.
End.
End.
/* partplant data directive */
For each ttPartplant where ttpartPlant.RowMod =’A’,
Each Part fields ( TypeCode ) no-lock where ttPartPlant.PartNum = Part.PartNum and ttPartPlant.Company = Part.Company.
If ttPart.TypeCode = 'M' Then Do:
/* Set Manufactured part Defaults */
Assign ttPartPlant.MfgLotSize = ‘1.00’.
Assign ttPartPlant.MinOrderQty = ‘0’.
Assign ttPartPlant.RawMaterial = false.
Assign ttPartPlant.AutoConsumeStock = true.
End.
If ttPart.TypeCode = 'P' Then Do:
/* Set Purchased part Defaults */
Assign ttPartPlant.MfgLotSize = ‘1.00’.
Assign ttPartPlant.BuyerID = ‘Sam F’.
Assign ttPartPlant.MinOrderQty = ‘1’.
Assign ttPartPlant.RawMaterial = true.
Assign ttPartPlant.AutoConsumeStock = true.
End.
End.