cancel
Showing results for 
Search instead for 
Did you mean: 

How can I skip the Simulate event of aftermodify?

former_member200995
Contributor
0 Kudos

Hi experts,

My objective is replace the material ID according to the Product Category when run the "Migration of Materials" , for example:

when category is 4041, the material ID is first 404101, and 404102...

when category is 4042, the material ID is first 404201, and 404202...

so the user just give a temp id at the material ID template, and the script get the max ID of category and offer the new material ID.

I use the aftermodirfy event of BO material, and use the NumberRange.DrawNumber() to get next number.

Now the issue is the import has two steps:Simulate and Execute.

so the NumberRange.DrawNumber() will run twice, and lose a number.

Any idea to skip the Simulate event of aftermodify?

Best Regards,

Benny

former_member200995
Contributor
0 Kudos

Hi experts,

Or maybe someone can tell me when run the aftermodify event of material, how can check it is Simulate or Execute? Thanks.

Best Regards,

Benny Huang

Accepted Solutions (1)

Accepted Solutions (1)

rohanarthur
Participant
0 Kudos

Not a beautiful solution, but one workaround could be to run until the simulation step the first time around, to find and fix errors, and then to close the migration and run a second time, this time directly by using the button 'Execute data migration immediately'. Doing this might 'refresh' your number range logic so that the actual max number is picked up again for the second run. (Not sure if this works, but you might like to try).

former_member200995
Contributor

Hi Rohan,

It is a beautiful solution, I am thinking of the solution too, just 1 step to finish the migration.

Now I use the solution:

at aftermodify, retrieve the max number of the material, and then add the NumberRange.DrawNumber().

at beforesave, NumberRange.ResetRange(), all the Range number to 0.

when running, it is aftermodify -> beforesave, aftermodify -> beforesave.

This is a circular operation, NumberRange is always begin 0, and the new number is max + NumberRange.

Thanks.

Best Regards,

Benny Huang

rohanarthur
Participant
0 Kudos

Hi Benny,

Nice! Please let me know if it works... you might want to keep an eye on how this works with parallel processing. Another thing to test would be to create two migration files, then run the first one until just finish simulation, then run the second migration file right through to import, and then come back to the first file to complete the last step.

My guess is that your logic should hold up to this test, because you are doing a reset each time, so the IDs generated during simulation are discarded.

Regards,
Rohan

former_member200995
Contributor

Hi Rohan,

Thanks for your help.

Yes, the IDs generated during simulation are discarded, So the parallel processing is OK. And I test the migration again and again, it runs as the requirement.

Best Regards,

Benny Huang

Answers (1)

Answers (1)

Former Member
0 Kudos

There are multiple ways to archive your goal ;-).

Idea 1: Disable the numbering on demand

You could implement an Script behavior based on the current user or some UI switch assigned to the user to enable/ disable your numbering so that the numbering is disabled while the simulation.

Process with this code extension:

  • User with disabled numbering simulates
  • User with normal numbering behavior imports

The Pro on this way is that this method works also if other users are already "normaly" using the system and they need the numbering

Idea 2: Reset the numbering on demand

Create an simple numbering management so that you can reset the NumberRanges as you want.

former_member200995
Contributor
0 Kudos

Hi Tobias,
Thanks for your help.
Very good idea.
About the idea 1, it is very good, I'll test it.
Idea 2, simple numbering management is not easy, because PDI can only write script in aftermodify and beforesave event, and I need global variables to store Number, now I can't catch any way to implement global variables.

Best Regards,
Benny Huang

Former Member
0 Kudos

Hi Benny,

For the Number Management I would use an own BO and than you can create actions (with scripts) to do what you want ;-).

Best regards

Tobias Kuhn