Midrange News for the IBM i Community

Posted by: Chris Proctor
Programmer Analyst
Columbia Sports Company
Portland, OR
Slick way of handling numeric fields in a flat file?
has no ratings.
Published: 02 Dec 2011
Revised: 23 Jan 2013 - 1978 days ago
Last viewed on: 24 Jun 2018 (4975 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Slick way of handling numeric fields in a flat file? Published by: Chris Proctor on 02 Dec 2011 view comments(9)

Happy Friday, everyone! I have a couple of new flat files coming in with numeric data, comma delimited, that I need to parse out and write to an externally defined file.

I've been coding the usual %scan() for the next comma, determine which field it has to be placed into, and if it's numeric, figure out how long it is, move it with %subst() to a char field with the same length then convert it to decimal with %dec().

I thought this seems pretty clunky and I was wondering if anyone has come up with a slick way of handling this type of conversion. The numeric field can be anywhere from 1 to 15 in length. I tried the following, but the compiler doesn't like it. Too bad!

 sohunt = %dec(%subst(bulkdata:s:length):length:0); 

Any suggestions would be greatly appreciated! Have a good weekend, y'all!

Return to midrangenews.com home page.
Sort Ascend | Descend