How to serialize properly 追蹤

Juan Carrasco

My problem is that I know how to serialize, but not as I'd like. I want to serialize depending on the product I'm printing the batch for, and the way I know to do it builds a common serialization for every product, or starts the count from 0. I give you an example:

I have product A and product B. The thing I'd want is for example to print 4 batches of prod A (so the serialization would be 00000, 00001, 00002 and 00003), then 2 of prod B (and the serialization would be 00000, 00001) and lastly 3 of product A (and continue the initial serialization like 00004, 00005, 00006). The problem is that I don't know how to save the last number I printed of the selected product. I know how to change the numeration when I change the product, but the problem is that each time I change the product, the count starts from 00000, instead continuing the last number I used.