on 01-01-2018 8:20 AM
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
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
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:
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.