BPM defaulted field - best practise

Epicor 9.05.701

Example…i want to default Part.ProdCode to “Raw Material” for every part created…but I want the user to still be able to change it if needed.

The best way is probably the use of a BPM…but what is the best approach for the example given?

Data or method directive?
which condition?
which action?

Many thanks in advance.

In your example I would probably do it as a post process on the Part.GetNewPart. Then you know it will only be called when creating a new part and not making a new part in a different way (I think a different method is called when duplicating a part). In general I think about method directives first then move to data directives. Method directives are much more confined. For example if you did a data directive to default something on the PartPlant table, that directive would check the condition for every PartPlant record when MRP ran.

Carson

1 Like

Thank you for this…what condition and action would you write?

Probably no condition and the action would be Set the Part.ProdCode field of the added row to x.

Did a bit of testing on this and i found that if the field i am trying to default is a dropdown box it doesn’t seem to like it.

So, …Part.Prodcode didn’t work as its a dropdown box.
However when i wrote the same bpm and changed the field to a non dropdown box… Part.PartDescription it worked first time.

Not sure how to get around this!

Just to follow up my last comment…

i just did Part.TypeCode (which is a dropdown box)…and it let me do it!..so, not sure why it doesn’t let me with the Part.ProdCode

Sometime with combo values you also have to to set the description. I do my defaults in abl on the data directive and I set prodcode there.

My routine is attached.

Greg

Part Defaults.p (1.0 KB)

That ABL will be really useful … I’ll test it next week - thank you.

Does the ABL script only work for NEW parts?..(that’s basically what I need)
Or does it change existing data too?

Thanks again

The rowmod of A runs it only for Added parts. I have other routines that run if the Type is changed from Purchased to Manufactured or vis versa.

Greg

1 Like

Sorry for the late reply on this thread i’ve been on site most of last week.

I got a list that needs defaults!..i think the best approach will probably be to tweak ABL from Greg

Purchased

IF part.type = “P” (Purchased) then default Part.ProdCode = Spare Components
IF part.type = “P” (Purchased) then default Part.ClassId = Raw Material
IF part.type = “P” (Purchased) then default Part.UsePartRev = no
IF part.type = “P” (Purchased) then default Part.Constrained = yes
IF part.type = “P” (Purchased) then default PartPlant.MfgLotSize = 1
IF part.type = “P” (Purchased) then default PartPlant.BuyerID = Sam F
IF part.type = “P” (Purchased) then default PartPlant.MinOrderQty = 1
IF part.type = “P” (Purchased) then default PartPlant.RawMaterial = yes
IF part.type = “P” (Purchased) then default PartPlant.AutoConsumeStock = Yes

Manufactured

If part.type = “M” (Manufactured) then default Part.ProdCode = Spare Components
If part.type = “M” (Manufactured) then default Part.ClassId = Work in progress
If part.type = “M” (Manufactured) then default Part.UsePartRev = yes
If part.type = “M” (Manufactured) then default Part.Constrained = yes
If part.type = “M” (Manufactured) then default PartPlant.MfgLotSize = 1
If part.type = “M” (Manufactured) then default PartPlant.BuyerID = NONE
If part.type = “M” (Manufactured) then default PartPlant.MinOrderQty = 0
If part.type = “M” (Manufactured) then default PartPlant.RawMaterial = no
If part.type = “M” (Manufactured) then default PartPlant.AutoConsumeStock = Yes

Make sure to use the row mod=’a’. You can set the buyer on the part class rather than the part if Sam F is the buyer for the part class. Makes it easier if Sam gets reassigned.

Use an If Then Do: End and the Assign is fastest if you start with Assign and then list all assignments and end with a period.

Assign Part.ProdCode = ‘Spare Component’

Part.AutoConsume = yes.

I’ll re-edit your code to fit my requirements and then run it past you tomorrow if that’s ok.
I haven’t written ABL so I’d appreciate a second look😁

No worries. We can do that.

1 Like

Hi Greg, how does this look for a first draft!?

/Set default values/

For each ttPart where ttPart.Rowmod = ‘A’ no-lock.

If ttpart.RowMod = 'A' Then Do:   	

End.

	If ttPart.TypeCode = 'M' Then Do:
/* Set Manufactured part Defaults */

Assign ttPart.UsePartRev = true.
Assign ttPart.Constrained = true.
Assign ttPart.ProdCode = ‘Spare’.
Assign ttPart.ClassID = “WIPG”.
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 ttPart.ProdCode = ‘Spare’.
Assign ttPart.ClassID = “RAWM”.
Assign ttPart.UsePartRev = false.
Assign ttPart.Constrained = true.
Assign ttPartPlant.MfgLotSize = ‘1.00’.
Assign ttPartPlant.BuyerID = ‘Sam F’.
Assign ttPartPlant.MinOrderQty = ‘1’.
Assign ttPartPlant.RawMaterial = true.
Assign ttPartPlant.AutoConsumeStock = true.

End.
End.

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.

Thanks Greg,
Here is where i’m at…
So, in method directives, i’m doing a Post-Processing bpm on Part.GetNewPart, using the below ABL…

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.ProdCodeDescription = “Spare Components”.
ttPart.ClassID = “WIPG”.
ttPart.ClassDescription = “Work In Progress”.

End.

If ttPart.TypeCode = ‘P’ Then Do:

/* Set Purchased part Defaults */

Assign ttPart.UsePartRev = false.
Assign ttPart.Constrained = true.
Assign ttPart.ProdCode = “Spare”.
Assign ttPart.ProdCodeDescription = “Spare Components”.
Assign ttPart.ClassID = “RAWM”.
Assign ttPart.ClassDescription = “Raw Material”.

End.
End.

The results for purchased parts seem to work…(it defaults to purchased when new part is created)…so am i correct i now put the same ABL code into a method bpm called PART.UPDATE and when i flip from typecode P to M it changes the tickboxes etc?

So, the ABL seems to work under PART.GETNEWPART and defaults the specific fields for purchased parts.
I’m getting stuck on defaulting the fields when the part.type is swapped to M

i have tried applying the same abl code to the method bpm PART.UPDATE and changing the abl to U - that didnt work
i’ve also tried applying the same abl code to the method bpm PART.GETNEWPART but changing the abl from A to U…- that didn’t work either.

stuck for the time being.

Ok, i’ve moved onto the PartPlant side of things…that seems to work for Purchased parts too. But doesn’t work for flipping over to manufactured…so same as the PART abl.
so, to summarise i think it just needs either a tweak to the ABL or i need to maybe do something with PART.UPDATE and PARTPLANT.UPDATE?

/* partplant data directive */

For each ttPartplant where ttpartPlant.RowMod = ‘A’.
For each Part fields ( TypeCode ) no-lock where ttPartPlant.PartNum = Part.PartNum and ttPartPlant.Company = Part.Company.

If Part.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 Part.TypeCode = 'P' Then Do:

/* Set Purchased part Defaults */

Assign ttPartPlant.MfgLotSize = 1.00.
Assign ttPartPlant.BuyerID = “Joe B”.
Assign ttPartPlant.MinOrderQty = 1.
Assign ttPartPlant.RawMaterial = true.
Assign ttPartPlant.AutoConsumeStock = true.
End.

End.

End.

That code on pre-processing, since you want to be between the client and the database Part.Update checking for a Rowmod of ‘U’ .

Condition of ttPart.TypeCode has been changed from Any to Any.