Hello All.
Trying to figure out how to split a large string of delimited data in to a data structure where I can then address it via field names to make it a bit easier to work with the data.
My input data is tilde delimited layout looks something like this:
Customer~InvoiceNumber~InvoiceDate~InvoiceAmount
There is more to it, but that's enough to paint the picture.
I am using Scott's GETTOK tool to split the data in to an array so I end up with:
InputArr(1) = Customer
InputArr(2) = InvoiceNumber
InputArr(3) = InvoiceDate
InputArr(4) = InvoiceAmount
The downside is then throughout the program, I end up needing to refer back to see "oh, what element is such and such data in?".
Ideally what I would like to do is create an external file and then in the RPG program create a data structure that's patterned after that file (extname keyword).
Then in my program, I'd have fields like this:
INVRCD.CUST = Customer
INVRCD.INVNO = InvoiceNumber
INVRCD.INVDT = InvoiceDate
INVRCD.INVAMT = InvoiceAmount
That's much easier to read and manage in the program.
But, what I can't seem to figure out is how to split the incoming data up and elegantly drop it in to the data structure.
I am fine if the InputArr is defined as a bunch of alpha fields and likewise my PF (and ultimately data structure) is defined in the same way too so I can plunk the array data in to the DS, I just can't seem to figure out how to pull that off.
Any help to shed some light on this is appreciated.
Thank you.
Trying to figure out how to split a large string of delimited data in to a data structure where I can then address it via field names to make it a bit easier to work with the data.
My input data is tilde delimited layout looks something like this:
Customer~InvoiceNumber~InvoiceDate~InvoiceAmount
There is more to it, but that's enough to paint the picture.
I am using Scott's GETTOK tool to split the data in to an array so I end up with:
InputArr(1) = Customer
InputArr(2) = InvoiceNumber
InputArr(3) = InvoiceDate
InputArr(4) = InvoiceAmount
The downside is then throughout the program, I end up needing to refer back to see "oh, what element is such and such data in?".
Ideally what I would like to do is create an external file and then in the RPG program create a data structure that's patterned after that file (extname keyword).
Then in my program, I'd have fields like this:
INVRCD.CUST = Customer
INVRCD.INVNO = InvoiceNumber
INVRCD.INVDT = InvoiceDate
INVRCD.INVAMT = InvoiceAmount
That's much easier to read and manage in the program.
But, what I can't seem to figure out is how to split the incoming data up and elegantly drop it in to the data structure.
I am fine if the InputArr is defined as a bunch of alpha fields and likewise my PF (and ultimately data structure) is defined in the same way too so I can plunk the array data in to the DS, I just can't seem to figure out how to pull that off.
Any help to shed some light on this is appreciated.
Thank you.
Comment