Connect With Us

Peter Levy

Peter
Levy

Peter Levy graduated with a computer science degree from Rutgers in 1982 and has been working on the System/38, AS/400, IBM i platform since 1984. He has worked for companies in printing, consumer electronics, chemicals, apparel, transportation, and computer consulting.

Articles
Recover Those Spooled Files You're Saving
Recover Those Spooled Files You're Saving 
After he figured out a way to save new spooled files on IBM i, Peter Levy learned that users also need a special command to restore those files. Here, he delivers.
Get the SBMJOB Command's CMD Parameter to Cooperate 
Peter Levy provides two simple solutions to overcome hiccups in the CMD parameter's handling of numeric and character parameters. First, he shows an easy way to get the CMD parameter to output hex constants. Then, he provides three scenarios that allow for varying-length character fields.
Put the SBMJOBALT Command to Work, Part 2 
You may recall that in Part 1 of this article, we discussed how to use the SBMJOBALT command to tie large amounts of data to batch jobs so that if they fail, no cruft is left lying around. Part 2 continues this theme and examines how to use SBMJOBALT to do many useful things, such as scheduling FTP download jobs and compiling program and SQL source on remote systems.
Put the SBMJOBALT Command to Work, Part 1  2
Sleuthing to find the culprit behind the disappearance of disk storage on your systems can prove difficult as well as frustrating. But with SBMJOBALT as your sidekick, you can prevent the accumulation of data left by jobs that end abnormally or are canceled off of job queues. The command can duplicate any object into the batch job's QTEMP library, allows queuing of batch jobs for transmission to remote systems for execution, provides a prompt override program to fill in parameters during prompting, and more.
CHGVAR . . . Undocumented 
About a month and a half ago now, I was writing a module in CL to convert from base-10 to base-41. (Why I was doing this arcane exercise, in CL no less, might itself make a good tip someday, but I digress.) At a certain point in the calculations, it required lopping off any decimal digits from a numeric expression, like the RPG %INT() function would do. Of course, there's no such function in CL, but the CHGVAR command has an innate ability to lop off the fractional digits of a numeric expression when the result is moved to a field with no decimal positions, so that's what I was doing. I was also using a CEE API to perform a modulus calculation. Those math functions don't support packed decimal, so every numeric variable in the module was an integer (*INT or *UINT). During testing, I wrote a program to run through the numbers one at a time to see what it would do, and at this one spot it jumped past an entire swath of digits to the next level. This behavior occurred no matter the starting point; it always jumped at the same relative spot. Debugging revealed that when the decimal portion of the expression's result was 0.5 or greater, it was rounding the result up to the next higher digit. "Wow," I thought, "that's different." (Well, actually, my very first thought was a popular three-letter Internet acronym that also starts with "W.") I did a little testing and confirmed that when the field in the VAR parameter was an integer (*INT or *UINT), it was performing mathematical rounding. If the field was a decimal (*DEC) with zero positions, it would simply lop off the decimal portion no matter what its value was. For example, on the one hand, if you divide 121 by 33, the result is 3.6666666. . . . When this value is moved into an integer field, it's rounded up to 4. When it's moved to the decimal field, it's lopped off to 3. On the other hand, if you divide 121 by35, the result is 3.4571428. . . . When this value is moved into an integer or packed decimal field
Convert Your Dates with APIs, Part 2 
Don't get mired in the limitations of the RPG built-in functions for converting dates and timestamps; there are many, many more options from which to choose, including the IBM i system APIs. APIs can handle a myriad of formats for outputting dates and provide an enormous amount of flexibility. This article, the second of a two-part series, explores how to output dates for email and RSS and touches on a couple of MI instructions.
Convert Your Dates with APIs, Part 1  2
Don't get mired in the limitations of the RPG built-in functions for converting dates and time stamps. APIs can handle a myriad of formats for outputting dates, providing an enormous amount of flexibility. This article, the first of a two-part series, explores CEE APIs.
Save New IBM i Spooled Files 
Are you annoyed by the fact that IBM doesn't support the SPLFDTA parameter on the SAVCHGxxx commands in IBM i 5.4 and beyond? This author sure is, and he knows a way to save new spooled files using the Save Object List (QSRSAVO) API.
Dynamic Array Service Program Prevents Memory Misuse, Part 2  1
In Part 2 of Peter Levy's series on dynamic arrays, he shares advanced uses for his Dynamic Array service program, which lets him add features that would have been impossible to do with RPG array constructs alone. He discusses stacks, queues, linked lists, and how the program can be used in any ILE language, including CL—a language that has never had array support of any kind.
Dynamic Array Service Program Prevents Memory Misuse  2
If you think it isn't necessary to go outside a language's array structure, think again. Peter Levy has created a Dynamic Array service program that lets him add features that would have been impossible to do with RPG array constructs alone. Sorting and searching using POSIX APIs have become natural extensions, along with the ability to delete a set of elements from an array. And then there's memory management: the size of array elements don't have to be fixed at compile time, making them as dynamic as the array dimension itself.
iPro Forums

Get answers to questions, share tips, and engage with the iPro Community in our Forums.

From the Blogs
Application Modernization Redbook Unleashed
Mar 27, 2014
blog

Application Modernization Redbook Unleashed  

The Application Modernization Redbook draft version has been released! Tim Rowe has the details....More
Free-Form RPG Transformation, Part 2
Mar 19, 2014
blog

Free-Form RPG Transformation, Part 2  

Tim Rowe continues his series on ISV tools for free-form RPG with a look at Linoma Software's free-format transformation tool, RPG Toolbox....More

Sponsored Introduction Continue on to (or wait seconds) ×