Wednesday, July 31, 2013

Subroutines in CL

IBM has been adding commands to CL that have been operations in other languages for many years. IBM i V5R4 saw the introduction of the Subroutine group of commands. There are five commands in this group, but I only use four:

  • SUBR - marks the start of the subroutine.
  • ENDSUBR - marks the end of the subroutine.
  • RTNSUBR - Return from subroutine.
  • CALLSUBR - calls the subroutine given.

I am not going to describe what a subroutine is, as I am assuming that all the readers of this blog have at least a basic knowledge of programming principals.

Friday, July 26, 2013

Query Engines: CQE versus SQE

I received an interesting message regarding the Passing parms to a Query post that I consider worth sharing.

Before I share the message I need to explain that there are two query engines on the IBM i (AS400): the Classic Query Engine (CQE) and the SQL Query Engine Engine (SQE). What runs through each engine is shown below:

Wednesday, July 24, 2013

Passing parms to a Query

Query/400 has always provides a quick and easy way to generate a report or create an output file. I have found that once they are built they never go away, as a programmer never has time, with all the demands on their time, to replace it with a RPG program.

If a Query joins several large files it can become a resource hog, taking away CPU power from normal daily interactive processing. The solution has always been to run Queries in batch.

Most people find that if they need to change the Query’s run parameters they use the Record Select parameter, RCDSLT(*YES), in the Run Query command, RUNQRY.

  RUNQRY QRY(QUERY_NAME) RCDSLT(*YES)

Of course this cannot be run in batch. Therefore, this Query, with its large joins, runs interactively, and the other users complain that the system is running slow.

But there is another way using the Start Query Management Query, STRQMQRY, command.

Thursday, July 18, 2013

When divine help is needed

Saint Isidore of Seville

We have all had those times when what you thought was a quick fix has turned out not to be, you have managed to corrupt a database, the quick software upgrade is entering its 24th hour, the back up of your file cannot be restored, or some other disaster. In those late dark hours don't you feel that you might be in need of some divine help.

You are in luck! In 1997 Pope John Paul II decided that computers, computer users, computer programmers, students studying computers, and the internet in general needed a patron saint to guide Catholics. He chose Saint Isidore of Seville (circa 560- April 4, 636), known in Spanish as San Isidoro de Sevilla, who served as Archbishop of Seville for 30 years and is regarded by many as the "last scholar of the ancient world".

Tuesday, July 16, 2013

Adding to the System Directory

I find that having my user profile in the IBM i (AS400) system directory is useful so that I can perform the following:

  • Send network files.
  • Use the QDLS file system on the IBM i (AS400)

I will not discuss either of them in this post as each deserves a post in their own right.

To add user profiles to the System Directory you need to have Security Administrator (*SECADM). To see whether you have that level of security use the Display User Profile (DSPUSRPRF) command. On a command line type: DSPUSRPRF your-user-profile and press Enter.

On the second screen is the ‘Special authority’ section, this lists the types of authority you have. This user has *SECADM authority.

                          Display User Profile - Basic

 User profile . . . . . . . . . . . . . . . :   SECUSR 
 User expiration interval . . . . . . . . . :   *NONE 
 User expiration action . . . . . . . . . . :   *NONE 
 Special authority  . . . . . . . . . . . . :   *ALLOBJ 
                                                *AUDIT 
                                                *IOSYSCFG 
                                                *JOBCTL 
                                                *SAVSYS 
                                                *SECADM
                                                *SERVICE 
                                                *SPLCTL 
 Group profile  . . . . . . . . . . . . . . :   QSECOFR

If your profile does not have *SECADM authority you will need to see your IBM i (AS400) System Administrator and have them add you to the System Directory.

Wednesday, July 10, 2013

Useful keywords for your F-specs

 

The original contents of this page have become obsolete, go to this page for up-to-date information.

 

Thursday, July 4, 2013

SELECT in CL

IBM i (OS400) V5R3 brought what I like to call the Select group of commands, SELECT, WHEN, OTHERWISE, and ENDSELECT. If you are familiar with the Select operation codes in RPG/RPGLE you need little or no introduction to their equivalent in CL. Their introduction has allowed me to write, what I consider to be, better looking and structured code.

Before the Select group of commands I would write some ugly thing like this:

01         IF         COND(&FLAG = 'A') THEN(DO)
02               CHGVAR VAR(&STS) VALUE('ACTIVE')
03               GOTO CMDLBL(ENDTEST)
04         ENDDO
05         IF         COND(&FLAG = 'I') THEN(DO)
06               CHGVAR VAR(&STS) VALUE('INACTIVE')
07               GOTO CMDLBL(ENDTEST)
08         ENDDO
09         CHGVAR     VAR(&STS) VALUE('ERROR')
10         CHGVAR     VAR(&ERROR) VALUE('1')
11  ENDTEST:

Line 1 tests if the field &FLAG is ‘A’, if it is then line 2 is executed, and line 3 goes to the label ENDTEST. I have the GOTO as if &FLAG was equal to ‘A’ it does need to execute any of the code before the ENDTEST label. If I did not have the GOTO it would execute the IF at line 5, and I would have had to put another IF statement between lines 8 and 9 too.

Lines 9 and 10 are only executed if &FLAG is not equal or ‘A’ or ‘I’.

Messy? Yes.

Tuesday, July 2, 2013

FOR replaces DO in RPGLE

In the post CL does DO I said that the DOFOR was similar to the FOR operation code in RPGLE. I use the FOR operation in RPGLE, but having looked at the code created by my colleagues I appear to the only one who does. The FOR operation allows us to "loop", perform the same section of code a specified number of times.

When programming in fixed format RPGLE if I needed to perform a section of code ten times many of us would code:

01 C     1             do        10
02
03 C                   enddo

Why do I do that?   I always code RPGLE in lower case.

In RPG/free it comes more complicated as the DO operation not supported. Therefore, I would need to do something like this:

01       Count = 1 ;
02
03       dou (Count = 10) ;
04
05          Count += 1 ;  // Increment Count by 1
06       enddo ;

IBM introduced the FOR operation, to replace the DO, in IBM i (OS400) V5R3.

Thursday, June 27, 2013

CL does DO

Two of the Command Language, CL, commands added to IBM i (AS400) release V5R3 were the DOWHILE and DOUNTIL, and IBM i 6.1 brought us the DOFOR. I have always wanted DO commands as I have resented not being able to write "structure code" in CL as I had to use the GOTO command to create a loop.

I quickly adopted the DOWHILE into my programming, but I have been surprised that, despite bringing it to their attention, that only one of my colleagues uses it. Which is one of the reasons I wanted to create this post to make sure others are aware of them.

Wednesday, June 26, 2013

IBM i User Group update

I had a mostly positive response to my request for details of IBM i User Groups.

A big "Thank you" goes to all of you who sent me details of User Groups.

I have updated the page with the info you all sent. You can go there either via the link at the top of this page, to IBM i user groups, or by this link IBM i User Groups links (both links go to same page).

So far I have details of 22 23 groups in 8 countries.

Please keep sending user group info. Please use the Contact Form (on right).


Thursday June 27: Seven more added, now we have 30.

Tuesday, June 25, 2013

IBM i (AS400) user groups

On Tuesday night I did something I have not done for almost fourteen years, I attended an IBM i (AS400) user group meeting.

Before moving to Southern California I lived in Tucson, Arizona, and attended many of the AS400 user group, BARMUG, meetings.

I find that interacting with just your work colleagues, who just do the same thing day-in-day-out and having the same arguments, makes you myopic. Interacting with your peers brings width of vision as, I find, most are willing to share ideas of what and how they are working.

There once was an AS400 user group in the San Fernando Valley, SMUG, but it closed down years before I moved here. This made OCEAN, in Orange county, the closest.

Friday, June 21, 2013

25th anniversary of IBM i (AS400)

Today, June 21, marks the 25th anniversary of the launch of the AS400.

I don't want to repeat what others, more eloquent than I, have said on other websites. All I will do is give links to what I consider the best: