Wednesday, March 26, 2014

Creating PDF files from spool files

ovrprtf cpysplf pdf transform services

I have times when a user will request that a report be emailed to them, rather than printed and sent to them via the inter company mail. The easiest way would be to create a PDF file from the spool file and then email it to the requestor.

There are many third party tools that allow you to be able to convert a spool file to PDF, but how can I do it just using native IBM i features?

The method I am going to describe can only be used IBM i servers with either version 6.1 or 7.1 installed.

Wednesday, March 19, 2014

Run SQL statements in your CL

cl clp sql runsql clle

IBM i 7.1 brought us the RUNSQL command. This allows me to run SQL statements within the CL.

Prior to IBM i 7.1 I would have to use the RUNSQLSTM command. To use this command I need to have the SQL statement in a source member. The way I knew to run build a SQL statement in CL program was to write it to a source member that could then be used by the RUNSQLSTM command. I always considered it too much work and either used a SQLRPGLE, RPGLE with embedded SQL, or a QMQRY, Query Management Query.

While I do not see the RUNSQL command replacing my use of SQLRPGLE, I do see it eliminating most of my use of QMQRYs.

Monday, March 17, 2014

New RedPaper: Reorganize Physical File Member

rgzpfm reorganize phtsical file member

I have Ralf Petter to thank for bringing to my attention a RedPaper, published this month, describing the changes to the RGZPFM, Reorganize Physical File Member, command.

It includes the changes made to the command with the release of TR7 (Technical Release 7), including the new From Record parameter, and how you can determine the status of the file's reorganization.

You can download/view the RedPaper, in PDF format, here.

Wednesday, March 12, 2014

Mixing it up with RPG all free

ctl-opt dcl-f dcl-s dcl-ds

With the new RPG all free we have been liberated from using the fixed format specifications. With the new definition operations we can intermingle “specifications”, within reason. I decided to see what I could do with a simple program that has one input file and a display file, which contains a subfile. In this post I will explain what I have found, some of it may be obvious to some but not to others.

Before our liberation specifications have had to be entered in a specific order. For example in RPGLE:

  • Control/Header (H)
  • File (F)
  • Definition (D)
  • Input (I), if needed
  • Calculation (C)
  • Output (O), if needed
  • Procedure (P)

Friday, March 7, 2014

The Lost AS/400 video

I thank Marco Drost for bringing this video to my attention.

Even if this is an urban legends it is still a funny story.

Wednesday, March 5, 2014

Defining Procedures in RPG all free

procedure subprocedure dcl-pr end-pr dcl-pi end-pi rpg dcl-proc end-proc

Having discussed how to define files and variables/fields in the new RPG all free, in this post I am going to give examples of how I have code Procedures using the new definitions.

I am going to assume that you know what Procedures and Subprocedures are. If you do not, no worries, you can read IBM’s definition in the RPG manual here.

The RPG all free brings us the following changes to the way we code Procedures and Subprocedures:

  • Procedure specification replaced by DCL-PROC and END-PROC.
  • Procedure prototype, coded in the Definition specification (D-spec) with ‘PR" in the declaration types, replaced by DCL-PR and END-PR.
  • Procedure interface, coded in the D-spec with “PI" in the declaration type, replaced by DCL-PI and END-PI.
  • Procedure parameter, coded in the D-spec, replaced by the optional DCL-PARM.

Below I am going to give the three most common ways I use Procedures and Subprocedures. They are many other ways they can be used, but I don’t use them or use them infrequently.

Wednesday, February 26, 2014

PDM user defined options

pdm user defined options defaults wrkmbrpdm wrkobjpdm wrklibpdm

When using PDM have you ever wanted to have your option do something different from the default way of doing it. For example if you want to use your own values in certain parameters for creating a RPGLE program. You can do so using without changing the command by using PDM’s user defined options.

IBM announced when IBM i 7.1 6.1 was launched that PDM and SEU would no longer be updated, they are still very popular (for more details see here). Over the years I have found that many developers do not use the options within PDM. In this post I am going to describe how to change the defaults for your PDM and how to configure user-defined options.

Wednesday, February 19, 2014

Defining variables in RPG all free

 rpg free tr7 dcl-s dcl-c dcl-ds end-ds dcl-subf

Prior to the new all free RPG variables (fields) would have been coded in the Definition specification, D-spec. With the new version of RPG the fixed format D-spec has gone. It has been replaced by new free form definition statements. At the time I am writing this post I have not found any other articles giving examples of how to code these new definition statements, therefore, I am going to give examples of how I have used them as I am starting to become this new version of the language.

The definitions I am going to discuss here are:

Monday, February 17, 2014

Technology Refresh Redbook now available

tr6 tr7 redbook

The draft Redbook for what is new in Technology Release 6 and 7, TR6 and TR7, update is just now available for download from IBM’s website.

The abstract for this manual is:

This IBM Redbooks publication introduces a technical overview of the new features, functions, and enhancements available in IBM i 7.1. It provides a summary and brief explanation of new capabilities and what changed in the operating system. This publication also describes many of the licensed programs and application development tools that are associated with IBM i. This publication includes all the enhancements that were delivered with the Technology Refresh 6 and 7 that were made available in 2013.

Wednesday, February 12, 2014

File definition in RPG all free

rpg free file sepecification dcl-f tr7

While I have been working with the new RPG all free (released in November 2013) I have unable to find examples comparing the pre-change to the post-change RPG code. Therefore, I thought I would give some examples of how to define files here.

When I first heard that RPG had gone completely free I was concerned that we could now intermix everything. This scared me as I had vision of people intermixing file definitions with the equivalent of calculations, etc. Fortunately what I have found is while you can intermix the new definition statements, you cannot insert them into the equivalent of the "calculation specifications".

Monday, February 10, 2014

How to tell if you have the PTF for RPG all free

dspptf rpg tr7 ptf si51094

I have been asked by several people how they can check if their IBM i has the necessary PTFs loaded to use the new RPG all free.

I thought it would be useful to create a quick post showing how I would check for the PTF.

Your server must be running IBM i version 7.1. If your server is running 6.1 then the RPG enhancements may be introduced with a future CUM PTF. If you are running on V5R4 or earlier you will not be able to use these enhancements.

Wednesday, February 5, 2014

Soft coding parameters used by Query

query qryfile output printer

In the environment I work there are many programs that produce "download reports". There are not paper reports, but extracts of file(s) that are sent, via email, to the requestor. Most of these use a Query to gather information together.

Many are coded like this:

   RUNQRY  QRY(QUERY1)

Which means that when the Query is run it will use the files that are hard coded in the Query’s definition. Therefore, if I want to perform a test and use files in a testing library I have to change the Query.

Or if I want to change which file or library the output file is in I have to change the Query.

Fortunately, there is an easy way to overcome these issues by using the parameters in the RUNQRY command.