Wednesday, December 18, 2013

QCAPCMD another alternative to QCMDEXC

Several of you commented on Capturing QCMDEXC error codes that you preferred to use the C library function SYSTEM( ) or the API QCAPCMD.

I have to confess that I had not used the QCAPCMD API prior to writing this post. So after some playing around with it this is what I found out about using it:

Friday, December 13, 2013

IBM i VUG December presentation replay

VUG presentation db2 enhancement

The presentation given by IBM's IBM i Virtural User Group last Wednesday (December 11, 2013), called IBM i 7.1 TR7 DB2 Enhancements, can either viewed or downloaded below. I have to admit I was a bit disappointed there was not more on the conversion from DDS to SQL DDL.

The next VUG meeting is on Tuesday January 14, 2014, at 9:30 - 11:00 AM US Central Time, and is entitled Introduction to the IBM i Performance Data Investigator.

IBM Navigator for i has Performance tasks that includes many traditional i performance capabilities. It also has the ability to manage your performance data collections. The most exciting feature is the Investigate Data task, which provides the ability to graphically view your i performance data through a browser interface; Collection Services, Disk Watcher, Job Watcher, and Performance Explorer data can all be investigated through this interface. This session will go through all the capabilities of the Performance Data Investigator. You will learn how to look at your performance data through PDI, discover various IBM-supplied views of your performance data, and how you can use PDI for performance reporting.

To register for the GotoMeeting here.

You can convert this time to your time zone here.

Thursday, December 12, 2013

Easiest way to read all the members in a multiple member file

The idea for this post came from a discussion I saw on Facebook. Someone asked:

  1. In your RPG how can you read from a particular member of a file?
  2. By default which member is read?
  3. How can you read all the members of your PF in your RPG program?
  4. How can you find out which member is being read?

The answer for the first question is to use the EXTMBR in the File specifications. I will not go into details about this as it is covered in Useful keywords for your F-specs.

The answer for the second question is that when a program opens a file with more than one member, by default, it opens the first member, which is the oldest member as that was the one created first.

The third and fourth questions I combined into my own scenario: I want to have a program that reads all the members in a multi member file to find a particular record and identify which member this record is in.

Tuesday, December 10, 2013

SYSTEM( ) as an alternative to QCMDEXC

system qcmdexc error codes

After my post about Capturing QCMDEXC error codes Markus During sent me an alternative method to execute CL commands and retrieve any error message id that might occur.

system() is a runtime C library function that performs the same purpose as the QCMDEXC API. With system() you pass a pointer to the command string and it is executed, no need for the for the command string length.

Tuesday, December 3, 2013

Email IFS files

send ibmi as400 email sndsmtpemm

The subject matter of this post compliments the previous post Zipping files in the IFS, which describes how to copy a file to the IFS and zip it in preparation for sending it via email.

Until recently it was not possible to email a file from the IFS without using a third party tool or an API. There is the command SNDDST that I have used to send emails from an IBM i (AS400) with the contents of files or files located in the QDLS file system as attachments. But it cannot access the IFS.

A new command SNDSMTPEMM has been introduced, via PTF, to IBM i 6.1 and 7.1 that allows you to email a file from the IFS as an attachment.

Tuesday, November 26, 2013

Zipping files in the IFS

zip file ifs

The information that went into creating this post was provided by Al Bernard. Al is an experienced IBM i (AS400) developer and colleague. In a recent conversation he mentioned to me something he had done that I have not.

He was asked to create a download file that would be emailed to a group of people. The file was so large that the Administrator of the email servers asked if the file could be zipped, to reduce its size, and then sent. My present employer uses a third party tool to send email from the IBM i, and I will not be discussing that here. What I will be discussing is the way he copied the file to the IFS and zipped it. Then I will describe how to do the reverse, taking the zipped file and putting the data into a DDS file.

Wednesday, November 20, 2013

Position record to top of subfile

position subfile sflrcdnbr

I recently received a message asking about subfiles:

I know this is a stupid question and I have done this a million times before, but I'm just blocked now and can't figure out what is wrong. My subfile is fully loaded, it is a few pages long. Enter was pressed on a second page, so I need the same page displayed when control is passed back to the subfile. For some reason it goes back to the first page.

The questioner must be asking about a "expanding" or a "load all" type of subfile, as this would not be an issue in the "page a time" subfile.

Fortunately there is a quick, and easy, solution for this problem by the addition of one line of code to the display file's source and a just two lines to the RPGLE/RPG IV's source.

Monday, November 18, 2013

IBM i VUG presentation replay and December meeting

ibm technical release 7 presentation

The presentation given by IBM's IBM i Virtural User Group last Wednesday (November 13, 2013), called Modern RPG - a look at the new and improved free form and other modernization, can either view or download the presentation below.

VUG's next meeting is on Wednesday December 11, 2013 at 10:00 - 11 AM US Central Time, and is called IBM i 7.1 TR7 DB2 Enhancements.

Friday, November 15, 2013

TR7 available today

If like me you have been patiently waiting like a child waits for Santa Claus, today is the day Technical Refresh 7 (TR7) for IBM i 7.1 officially becomes available.

You can see what is included in this Technical Refresh in an earlier post I wrote called IBM i Technical Refresh 7.

It is available as a group PTF, MF99007, you can view the PTF Cover Letter here.

In my opinion the most anticipated part of TR7 is the changes made to RPG/free. Now the Control (H), File (F), Data Definition (D), and Procedure (P) specifications are all in free format. Input (I) and Output (O) specifications remain in fixed format.

Thursday, November 14, 2013

IBM i Virtual User Group TR7 presentation

I thoroughly enjoyed yesterday's presentation by the IBM i (AS400) Virtual User Group called Modern RPG - a look at the new and improved free form and other modernization thoughts which is available for download as a PDF here.

And tomorrow is release date for IBM i 7.1 Technical Refresh 7!

Wednesday, November 13, 2013

Generating random numbers using a C function

Having discussed in previous posts about how to generate pseudo-random numbers using the CEERAN0 API in RPG and the SQL RAND function I received an email showing me a third way to do it, using a C function.

I would like to thank Bob Schmalandt for sending me the example program upon which this post is based upon.

There are two C functions that generate a pseudo-random number, and they both work in the same way.

  • rand, is not threadsafe.
  • rand_r, is.

In my examples below I will be using rand.

Monday, November 11, 2013

A Short History of Free-Form RPG

I found an interesting post written by Hans Boldt, who was part of the team that developed RPG/free at IBM in Toronto, Canada. In it he gives us a brief glimpse into some of the decisions and processes involved in creating RPG/free.

It all started more than twenty years ago, back when RPG IV was being designed. At the time, there were two distinct schools of thought. On one side, there were people who insisted RPG should have a fully free-form syntax. On the other, were those who strongly believed that RPG should remain in its traditional fixed-form layout.

He reminds us that RPG/free is no longer new as it was released 12 years ago in V5R1, and ILE RPG/RPGLE/RPG IV 18 years ago in V3R1.

You can read it here: A Short History of Free-Form RPG

Friday, November 8, 2013

User Group: IBM's Virtual User Group

IBM has their own User Group for the IBM i community the IBM i Virtual User Group. Being "virtual" means that we can all be members.

Its home page here.

You can join its mailing list by emailing ibmivug@us.ibm.com.

They are offering a webinar on Wednesday November 13th at 10:00 AM - 11:00 US central time called "Modern RPG - a look at the NEW and Improved Free From and other Modernization thoughts".

Thursday, November 7, 2013

Renaming one field in a file using EXTFLD

In September I wrote about a problem I had encountered where I had to rename one field in a file, and not rename the other fields, in Renaming one field in a file in RPG. I achieved this using RPG's Input specification, I-spec. BlueBull posted a comment on the post explaining that I could have used the EXTFLD keyword in the Data Definition specification, D-spec, to do the same.

In this post I will show how I would use the EXTFLD to rename a field, and determine if it would fit the scenario I used in my previous post.

Tuesday, November 5, 2013

Validating numbers without TESTN

I have received an email asking me the following question:

How can I validate numbers in RPGLE /free without using testn?

I have spent a considerable amount of time dealing with data from Microsoft Excel spreadsheets that has been uploaded to the IBM i (AS400). It is easy to use the TESTN operation code to test ideally formatted "00123456", but what about "123456  " or "1,234.56  "?

Friday, November 1, 2013

User Groups: Others agree

It is always good to find others who agree with one of your opinions. This week I felt really good to find that two eminent IBM i (AS400) folks share my opinion on the importance of User Groups.

Jon Paris and Susan Gantner wrote a post on the IBMSystems Magazine blog called "Kindred Spirits in the IBM i Community".

There's a lot to be said for kindred spirits getting together. It will be no surprise to readers of our blog that we're big believers in local IBM i user groups.

I have nothing further to say except to give you the link to this post: Kindred Spirits in the IBM i Community

Wednesday, October 30, 2013

Generating random numbers part II

In Generating random numbers part I I discussed what a pseudorandom numbers are and how to generate them using the CEERAN0 API. In this post I will discuss how to generate pseudorandom numbers using SQL.

I will be using the same scenario I did in part I. I need to generate 1 million random numbers, and write them to a DDS file, RANDOM_F.

Thursday, October 24, 2013

Addition to user group list: MMSA

I received an email from Mark Watts to introduce the Metro Midrange Systems Association (MMSA) from Texas.

"The Metro Midrange Systems Association is a community of IBM midrange users serving Dallas/Ft. Worth and the surrounding North Central Texas Area," Mark explained.

You can check their website at www.metromidrange.org

I have also added this link to the IBM i user groups page. You will find a link to the user groups page at the top of every page of this website, or you can click here.

Feel free to check out which user group is closest to you.

If you know of a group which is not on the user groups page use the Contact form, on right, to send me its details.

Tuesday, October 22, 2013

Generating random numbers part I

There are times for statistical or testing reasons you need a random number. Computers have always struggled to generate truly random numbers, therefore, they use a process called psuedorandomness. Which is defined by Wikipedia as:

A pseudorandom process is a process that appears to be random but it is not. Pseudorandom sequences typically exhibit statistical randomness while being generated by an entirely deterministic causal process.

But how generate one on an IBM i (AS400)?

Wednesday, October 16, 2013

Capturing QCMDEXC error codes

QCMDEXC is a useful API, that has been around since the launch of the AS400 (IBM i), that is called to execute a single command. It is one of the simpler APIs to call with just two parameters:

  • Command string
  • Command string length

I have seen many examples of RPGLE/RPG IV source code that looks something like this:

01 D CmdString       S            132
02 D CmdLen          S             15  5
03  /free
04     CmdString = 'CLRPFM TESTFILE' ;
05     CmdLength = 15 ;
06  /end-free
07 C                   call(e)    'QCMDEXC'
08 C                   parm                    CmdString
09 C                   parm                    CmdLength
10  /free
11     if (%error) ;

The programmer has gone "out" of RPG/free, line 6, to be able to CALL QCMDEXC, as the CALL operation is not supported in RPG/free.

On line 7 the programmer has used the 'E' operation extender to stop the program erroring if an error was encountered by QCMDEXC, such as TESTFILE not being in the library list or the file is in use by another job. Then they have gone back "into" RPG/free, line 10, before performing a test to see if there is an error, line 11. But what was the error?

Thursday, October 10, 2013

MONITOR for errors in RPG

I am sure all IBM i (AS400) programmers are familiar with the MONMSG command in CL to capture exceptions (errors) and stop an error message from interrupting the program. You can do the same in your RPG code using what IBM calls the "monitor group".

The "monitor group" consists of the MONITOR, ON-ERROR, and ENDMON operation codes. When an error occurs within the "monitor group" it can be handled by using specific status codes, or by the use of one of the following special values *PROGRAM, *FILE, *ALL. *PROGRAM handles all of the program related status codes, 100 - 999. *FILE handles all of the file related errors, 1000 - 9999. *ALL, as it suggests, handles all errors, and is the default for the the ON-ERROR operation.

Wednesday, October 9, 2013

Added to the user group list: LUG

I am sure many of you know how I feel about user groups. I believe they are a valuable resource to help IBM i folks to come together, learn from one another, and help spread the joy of IBM i.

I was pleased to receive an email today from Lynne Benedict to introduce me to the Large User Group.

Tuesday, October 8, 2013

IBM Technical Refresh 7 continued

Today was the official announcement date for IBM i Technical Refresh 7, or TR7.

I covered a lot of it in yesterday's post IBM i Technical Refresh 7, and here are some more IBM links I have found today:

Monday, October 7, 2013

IBM i Technical Refresh 7

IBM has announced the anticipated Technology Refresh 7, commonly called IBM i TR 7.

It includes what IBM describes as a "major enhancement to RPG IV" with the introduction of free format F- and D-Specs. Having worked with the current RPG/free the new /free operations for the F- & D-Specs does look a bit strange:

Wednesday, October 2, 2013

Condition display fields without indicators

I received a message after publishing the No More Number Indicators story about an alternate method of conditioning fields in a Display file without using indicators. As the person who sent me this did so as Anonymous I cannot thank them by name, but you know who you are.

I did use this method once, many years ago. I had create a program and display file for the editing of UB82 and UB92, universal billing forms used by hospital and doctors to submit to Medicare and other insurance companies. To put all of the fields on screens made it look too confusing and complicated. Therefore, I tried to make it easier to understand by only displaying the field relevant to the type of claim, highlighted the fields in error, etc. Before long I found I was using just about all of the indicators, *IN01 - 99, on the first couple of record formats. What was I going to do for the rest?

A look in the IBM manual for programming with displays introduced me to Program to Systems fields. By passing a hexadecimal value to a field in the display file I could eliminate most of the indicators I had been using.

Wednesday, September 25, 2013

Alternative to SELECT is IF-ELSEIF

The RPG operation code SELECT as been with us for many years. It is also found in many other languages, including CL (see the post SELECT in CL).

An alternative was introduced in one of the IBM i V5 releases, the IF-ELSEIF operation codes. If the first IF is not true then the first of the ELSEIF is executed, just like the WHEN in the SELECT group.

Friday, September 20, 2013

Validating dates in RPGLE

I received an email asking me the following question:

What about date validation?

Dates on a screen are usually displayed as MMDDYY. I don't need to add days or months to it, I need to ensure that the date itself is valid.

I can think of two approaches of displaying and validating dates on a display file.

  • Use a date field.
  • Use a 6,0 numberic field.

Wednesday, September 18, 2013

More SQL and dates part II

This post is a continuation of a previous posting More SQL and dates part I, and is based on an email I received from Scott Damery.

"We can all become SQL black belts with knowledge and practice," he reassured me.

In this post I am going to compare SQL to RPGLE/RPG IV.

Thursday, September 12, 2013

More SQL and dates part I

After my post on calculating the last day of the month using SQL, Calculating end of month part II, I received an email from Scott Damery.

"Take advantage of the many date functions in SQL instead of programming code to provide the information needed," he said in his email.

I am a great believer in: if there is a function to do a process use it, rather than code your own.

Below are the SQL functions he mentioned with a couple of others I found:

Tuesday, September 10, 2013

Renaming one field in a file in RPG

I was asked to quickly modify a program. The program currently uses a file, I'll call it FILE1, and the modification was to add a second file, FILE2 to it. If the user selects to search for a certain type of information the the program would uses FILE1, if they want to search for a different type of information the program would need to use FILE2.

All of the fields in FILE1 and FILE2 have the same names and attributes, except for the Part number field. The Part number field, PART, in FILE1 is 20 long, in FILE2 it is 15.

I cannot change FILE2 to make PART be the same length as it is in the other file. I must make the minimum amount of changes to the program to negate the need for it to be audited by the SOX auditors. What can I do?

The changes I would need to make would be:

  • Create a 'which file' field to be used to determine which file the search is for.
  • Add USROPN to the File specifications, F-spec, for FILE1 and FILE2. This means that the file will only be opened if I use the OPEN operation code to open it.
  • Use the value in the 'which file' field to condition which file is opened.
  • Decide which file to read by using the 'which file' field.
  • Close the file opened.

But that still leaves the problem of what to do with the two PART fields.

But how do I cope with the difference between the two PART fields with the minimum of code changes?

Using the PREFIX keyword in the F-spec would not do, as that would rename all the fields in FILE2.

Then it struck me, I could use a way I had used before in RPG III.

Thursday, September 5, 2013

Externally described Data Structures

I have been racking my brain to try to remember when I first came across Externally Described Data Structures in RPG. I think it must have been when I transitioned from being a RPG II programmer on the IBM System/36 to a RPG III programmer on an AS400 (yes, I am that old). The others I was working with at the time were all former IBM System/38 programmers and were "fluent" in RPG III. They did not use Externally Described Data Structures. and I was the "newbie" learning RPG III from them, so neither did I.

It was while I was working on a project programming in Synon/2E, and later modifing Synon generated RPG code, did I find them used everywhere. Synon uses Externally Described DS for passing parameters, saving the values of fields in files, and for the Program Status DS (PSDS).

What do I use Externally described Data Structures for?

Tuesday, September 3, 2013

Equivalent of SETLL using SQL

I received several messages and comments in response to my post Validation: CHAIN versus SETLL informing me that I can do the same in SQL.

Alas, no-one sent me any examples of how they would do it. Therefore, after some Googling I found a way.

Sunday, September 1, 2013

CHAIN versus SETLL the results

Having started the debate on which is faster in my post Validation: CHAIN versus SETLL I decided to put the theory to the test.

I created a DDS file with a single key:

  A                                      UNIQUE
  A          R TESTFILER
  A            KEY            7P 0
  A            F1             3
  A            F2             5P 0
  A            F3            30
  A            F4             3P 2
  A            F5            50
  A          K KEY

And filled the file with a million records, the field KEY contained the values of 1 to 1 million.

I created two almost identical programs. Each one would perform their operation 1 million times, and write a record to an output file with the Start time, End time, and the number of milliseconds it took to perform the 1 million operations. Those programs are listed below:

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.

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

I was working within earshot of a colleague who had to recompile several programs he had built, over six months ago, that an user finally wanted to test. The objects had been deleted as part of a software refresh of our development IBM i (AS400), therefore, he would have to compile all of the program objects. He was going through all of the programs’ source code and recreating the work files he needed for the compiles, while grumbling that there must be an easier way to do this. That is when I offered to show him something that would make it easier in the future.

There are several File specification, F-specs, keywords that I use especially with “work” files:

  • EXTFILE
  • EXTDESC
  • EXTMBR
  • RENAME

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.

Saturday, June 29, 2013

Ocean400 2013 Tech Conference in July

I want to take this opportunity to promote my local IBM i User Group's, OCEAN, annual technical conference on Friday July 19, at the National University in Costa Mesa, CA.

"The OCEAN User Group is celebrating its 25th year in 2014 and on July 19th, is holding the 20th Annual Technical Conference and Vendor Expo. We could not sustain this level of activity without the support and continued participation of our members and dedicated board members. There is still time to register for the best package of education in the west. Go to www.ocean400.org. Become a member and enjoy member pricing and the opportunity to attend all regular meetings at no cost."

Carole Comeau, OCEAN Conference Co-Chair

I am really kicking myself that I will not be able to attend this event.

If you are in So Cal on July 19 this would be an excellent way to spend a day to learn a lot and enhance your skills with the IBM i.