COBOL unstring question for packed decimal.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Kannan P
Registered Member
Posts: 11
Joined: Sun Jan 03, 2016 8:08 am

COBOL unstring question for packed decimal.

Post 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
User avatar
zum13
Registered Member
Posts: 85
Joined: Thu May 04, 2023 12:58 am

Re: COBOL unstring question for packed decimal.

Post 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.
Kannan P
Registered Member
Posts: 11
Joined: Sun Jan 03, 2016 8:08 am

Re: COBOL unstring question for packed decimal.

Post 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.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”