Tuesday, December 23, 2014

Getting field definitions using SYSCOLUMNS

Use SYSCOLUMNS to get list of fields in file

In several previous posts where I have used the DSPFFD command, see here and here, or the QUSLFLD API, see here, to retrieve the Column Heading of fields in a file someone has commented that I should retrieve the column headings using the SYSCOLUMNS file. In the scenarios described in those post using SYSCOLUMNS would not have worked as it only contains data for files not in QTEMP.

SYSCOLUMNS resides in the library QSYS2, and is a SQL view built over the physical file QABDIFLD. It contains the field/column information for all the files and tables in every library on your IBM i, except those in QTEMP. I am not going to list all the columns in SYSCOLUMNS as the IBM documentation does a good job doing it here.

I am going to show two scenarios how I could use SYSCOLUMNS:

  1. List all of the fields in a file.
  2. List all the occurrences of a field name in all the files in a library.

Wednesday, December 17, 2014

Using aliases can be simple

using alias in rpg

The discussion of whether to use the alias names for files’ fields has become a lengthy here amongst the programming staff. The major argument against has been that there does not appear to be an easy way to perform input or output to record formats in display and printer files. I needed to find a simpler way to define the alias and its uses.

Fortunately IBM came to my aid with PTFs to make the using of alias simple in IBM i 7.1 and 7.2. In my opinion this is the way alias handling should have been from the start.

Tuesday, December 16, 2014

Node.js now available

node.js released for ibm i

Node.js was promised as part of Technical Refresh 9 for IBM i 7.1 and TR1 for 7.2. It was released yesterday, December 15 2014, as a new License Program Option.

Node.js is an open source runtime environment for server side and network applications. Its applications are written in JavaScript using Google's V8 JavaScript engine to execute code. Its runtime can execute on OS X, Microsoft, Free BSD, Linux (which can be hosted on a PowerSystems server along with IBM i) and now IBM i.

Monday, December 15, 2014

User Group: COMMON Luxembourg

common luxembourg user group

I have added a link to COMMON Luxembourg’s website to this site's IBM i user groups page.

Their site is at www.common.lu (you do need the www)

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

Thursday, December 11, 2014

IBM i 7.2 Redbook is out

ibm i 7.2 redbook

After being teased last week with a video of Steve Will, Chief Architect for the IBM i, talking about IBM i 7.2 and TR1 the first Redbook for 7.2 was been released yesterday afternoon.

It can be download from IBM's Redbook website here (17.3 MB).

It has chapters covering the following subjects:

  1. Introduction to IBM i 7.2
  2. Systems management
  3. Cloud and virtualization
  4. Security
  5. Networking
  6. High availability
  7. Backup and recovery
  8. IBM DB2 for i
  9. Application development
  10. IBM i server functionality

At 416 pages it is going to take a lot of bedtime reading to get through it.

Wednesday, December 10, 2014

Quick way to find if PTF present and applied

look up ptf using ptf_info rather than dspptf

I often need to find out if a particular PTF has been applied to the IBM i I work upon. Most of the time I can use the DSPPTF command to display the PTFs, but there is one instance of IBM i I am not authorized to that command. I think the head IBM i operator is tired of receiving emails from me asking him to check if a certain PTF has been loaded and applied. I needed to find another way I could display a PTF and whether it had been applied on my own.

Fortunately there is a SQL view I can search for this information. According to the IBM documentation this view has been available since IBM i 6.1. The only servers I have access to are running 7.1 and 7.2, so I cannot vouch for whether this will work in 6.1.

Wednesday, December 3, 2014

Replacing text in a string

%scanrpl sql replace

I received a request from the engineers: One solvent they use has been place on the "restricted list" by the state and could no longer be used. Could I create a program to replace the solvent's code in their files with the replacement solvent's code?

It gave me a reason to use the %SCANRPL, 'Scan and replace character', built in function that was introduced in IBM i 7.1, and made me think how this could be accomplished with earlier releases too.

Wednesday, November 26, 2014

Using Alias for longer field names

 

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

 

Wednesday, November 19, 2014

Data Areas in the all free RPG

rpg all free data areas and lda

I have a couple of communications asking about how to "correctly" code a data structure to receive the data from and update a data area in the latest, all free, RPG. One of person even sent me their code, which I will be using for the basis for my examples.

While I am not sure if there is just one "correct" way to do this I will be giving my version of the following three scenarios:

  1. Receive data from a data area into a data structure
  2. Update the data area with data from a data structure
  3. Equivalent of UDS

I am not going to describe the basics of how to code Data Structures in free format in this post, as I covered this in Defining variables in RPG all free.

Wednesday, November 12, 2014

Getting a list of files in IFS directory

 

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

 

Wednesday, November 5, 2014

More about subprocedures

subprocedures in modules

In my earlier post Subroutines versus Subprocedures I described some of the advantages of using subprocedures rather than subroutines. In it showed how you could use, what I call "open" subprocedures. An "open" subprocedure does not have a procedure interface specifications, therefore all of the variables defined in the main line/body are available in the subprocedures, and if you change the contents of one of those variables the changed value is seen in the main line/body.

The other type of subprocedure I call "closed". The subprocedure can be passed parameters and can return a single variable, which can be data structure with multiple subfields. A "closed" subprocedure is should be placed in a separate module, therefore, they are now available for multiple program to use. As the main line/body can only change the variables they pass to the subprocedure and the subprocedure can only return one pre-defined variable there is no accidentally changing to the values of the variables.

Many people commented on that post explaining the advantages of the "closed" subprocedure. I do agree and below I will describe how I code them and their advantages, including one potential gotcha.

Monday, November 3, 2014

Two user groups from France

I was recently browsing a French IBM i website when I found links to two User Groups in France:

They share at forum at www.volubis.fr/forum/

I have added these links to this site's IBM i user groups page. You will find a link to the user groups page at the top of every page of this website.

Are there other user groups/clubs in France or anywhere else in the world? If you know of any not on the user groups page please use the Contact form to send me their details.