OrganizationIsRandom
Programmer
Good evening folks.
This is a real peach....
Consider this problem: an input string from a VSAM file is a packed decimal of one of the following forms:
S9...9V9...9
S9...9V9(#)
S9(#)V9...9
S9(#)V9(#)
where # is 1 to 9 and s9...9 will at most be nine 9's.
What I'm trying to do is unpack this, retaining the sign and the decimal point and then STRING'ing it to a varible before writing it to a file.
I have got this working for the 'easy' packed numbers, i.e. ones without decimal points (e.g. S9...9 and S9(#) ) What I do is firstly inspect the string, if it has no brackets I count up the number of nines and then move it to a Pic X of the correct size, also checking if it's positive or negative and using reference modification to place the + or - and then the unpacked number. If it has a bracket I unstring the value inside the brackets and do the same as before.
I'm stumped with the decimal point though.
Is there a generic way I can efficiently 'move' the packed field to a Pic X that will cover all cases (e.g. PIC X(21) to account for the sign, nine 9's, decimal point, nine 9's)
I have a feeling this could be done by a similar method to the ones I've got unpacked, such as counting up nine's either side of the V, and using some sort of reference modification to move this to the PIC X and then move the appropriate part of the PIC X to my output again by reference modification.
Any guidance on this would be hugely appreciated!
Thanks
Markus
Ireland.
This is a real peach....
Consider this problem: an input string from a VSAM file is a packed decimal of one of the following forms:
S9...9V9...9
S9...9V9(#)
S9(#)V9...9
S9(#)V9(#)
where # is 1 to 9 and s9...9 will at most be nine 9's.
What I'm trying to do is unpack this, retaining the sign and the decimal point and then STRING'ing it to a varible before writing it to a file.
I have got this working for the 'easy' packed numbers, i.e. ones without decimal points (e.g. S9...9 and S9(#) ) What I do is firstly inspect the string, if it has no brackets I count up the number of nines and then move it to a Pic X of the correct size, also checking if it's positive or negative and using reference modification to place the + or - and then the unpacked number. If it has a bracket I unstring the value inside the brackets and do the same as before.
I'm stumped with the decimal point though.
Is there a generic way I can efficiently 'move' the packed field to a Pic X that will cover all cases (e.g. PIC X(21) to account for the sign, nine 9's, decimal point, nine 9's)
I have a feeling this could be done by a similar method to the ones I've got unpacked, such as counting up nine's either side of the V, and using some sort of reference modification to move this to the PIC X and then move the appropriate part of the PIC X to my output again by reference modification.
Any guidance on this would be hugely appreciated!
Thanks
Markus
Ireland.