Wednesday, August 28, 2013

Validation: CHAIN versus SETLL

I recently received a message about the post No More Number Indicators. The person asked why I had used a SETLL operation code instead of a CHAIN to check for a record on a file in one of the examples.

12   setll Z1DEPT DPTMAST ;
13   if not(%equal) ;
14     ErrDept = *on ;
15   endif ;

I have to credit to my wife for this. Years ago she attended an IBM conference in San Diego, California, and she went to a presentation by John Sears about improving your code's performance. This was one of his suggestions

Friday, August 23, 2013

Changing name of Query/400 print file

I was asked a question about how to change the name of the spool file created by running Query/400.

The default print file for Query/400 output is QPQUPRFIL. The inquisitor wanted to change the name of the spool file to another which would allow the users to be able to identify it.

This can be achieved by using the OVRPRTF command.

Tuesday, August 20, 2013

Getting the SQL statement out of Query/400

I first learned about embedding SQL into RPG programs at a user group meeting many years ago. I could see it as a tool that would increase my productivity, but all I had was a paper copy of the slideshow that had been presented. The company I was working with had SQL loaded on their AS400 (IBM i), but none of their programmers used it. This was the time before Google, and I struggled to find resources about SQL especially about the different types of joins, etc.

Fortunately I stumbled across a way to retrieve the SQL statement from a Query/400 into a source member. Now I could build a Query close to what I want, then view the SQL to get an idea of how to make my own statement.

Sunday, August 18, 2013

IBM i goes bungee jumping

I thank Ben Clift from Maxava for bringing this video to my attention.

Thursday, August 15, 2013

No More Number Indicators

I can remember in my first programming job being introduced to RPG III programs with a list of all the indicators used in the comments at the top of the program. While I admired the throughness of the documentation, I never did like that an indicator would only be used for one purpose. I prefered to use a few indicators for file Input/Output and check immediately afterwards if the indicator was *ON, for example:

01  * 99=End of file, 98=Error (record lock)
02 C                     READ FILE1                  9899
03 C           *IN99     IFEQ *ON
04  *
05  * 99=Not found, 98=Error (record lock)
06 C           KEY1      CHAINFILE1                9998
07 C           *IN99     IFEQ *ON

RPGLE/RPG IV introduced the "Operation Code Extender" which could replace the need for indicators for all of the operation codes. If I code the equivalent in RPG/free it could look like:

01 read FILE1 ;
02 if %eof ;

03 chain key1 FILE1 ;
04 if not(%found) ;

But when RPGLE/RPG IV was first introduced you still had to use numbered indicators to communicate with display and printer files. Fortunately this is no longer the case as you can use the Indicator Data Structure, INDDS, to give the numbered indicators in these types of files meaningful names.

Tuesday, August 13, 2013

The man who washed an AS400 with water

I found this story in Facebook, liked it, and wanted to share it. I thank Vincent Lin for giving me permission to publish it on this blog.

Vincent Lin

I was an IBM CSR in Taiwan. Here’s my story why I fixed an AS/400 with water...

One day in 2000, there's a powerful typhoon hit the area, one of my clients had an AS/400 (9402-200) was totally flooded in the company basement. They sent the machine back to headquarter and called IBM at the next day.

Friday, August 9, 2013

Calculating end of month part II

After publishing the post Calculating end of month on how I would do it in RPG/free, yesterday, I received a number of messages on how the same can be achieved in SQL.

I want to thank everyone who sent me a message, I really do appreciate the feedback.

Having tried every snippet I was sent I did find one that I appreciate its simplicity.

Thursday, August 8, 2013

Calculating end of month

Although the subject matter of this post may seem simple to the more experienced RPG black belts, I am creating this post in response to questions I have receieved recently from two collegues. I was asked if there was an "easy" way to determine the date of the end of the month entered. They both had examples in RPG III and were sure that there must be simpler way.

In RPG III I could determine the date of the last day of the month like this:

Tuesday, August 6, 2013

IMHO: Source files – one or many?

This will be what I hope will be the first of many posts where I express my humble opinion (IMHO) about something, and you let me know what you think. This will only work if I get feedback from you, the readers of this blog.

I would like to start with source files.

My opinion is that you should keep the source members for all object types (RPGLE, DSPF, CLLE, PF, LF, etc.) in one source file in each library.

Some of my colleagues disagree with this, and keep the various types of source in their own source file.