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.