Page 1 of 1
COBOL unstring question for packed decimal.
Posted: Sat Jan 27, 2024 11:32 am
by Kannan P
Hello,
I have a requirement to unstring the fields based on semicolon. I have a packed decimal in the record which throws compilation error because of this unstring, however.
Is there any other option to separate fields in jcl or is it correct to use unstring for packed decimal. TIA
Re: COBOL unstring question for packed decimal.
Posted: Sun Jan 28, 2024 1:46 am
by zum13
Hello.
The clue is pretty much in the name; UNSTRING is intended for use with strings rather than binary data. Using it against binary data can result in false positives if something in the data happens to match your delimiter character, for instance, if you're searching for spaces and your binary data happens to include X'40'. The same thing can happen if you're just looping through the data a character at a time.
It sounds like you have a CSV-style file with a semi-colon delimiter. Is there a particular reason why there's binary data present? Having binary data in there doesn't really fit with that standard, plus it's the kind of thing that's capable of really screwing up the parsing of the file. If there's any way of getting your input file written with the packed data converted to displayable characters, I'd suggest taking it as it will make things a whole lot easier.
Re: COBOL unstring question for packed decimal.
Posted: Mon Jan 29, 2024 11:44 am
by Kannan P
Thanks for the suggestion zum13. Let me work on this:
If there's any way of getting your input file written with the packed data converted to displayable characters, I'd suggest taking it as it will make things a whole lot easier.