Dynamically create list based on variables

My application is receiveing data from a barcode scanned from a document. This barcode contains the documentno and a value that indicates a qty (eg. PS12288PQ2 - PS is documenttype, docno, PQ is used as a separator and indicates a qty).
In a flow, I’m separating this string to 2 page variables “docno” and “qty”, both int.
I now want to create a dynamic list based on these values these list items represent packages the value of each item in case of the doc mentioned is:
(PL indicating the docno, PK indicating package 1/2 and 2/2)

How can I create the list with the items? Should i use a flow with a loop? Use a formula in a list variable? Javascript?

The items in the list need to be scanned and marked as scanned. Any idea?