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

 

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

 

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.

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

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

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.