I am sick of Islamic Terrorists

  • Posted on: 22 March 2016
  • By: NickLitten
look its a medieval bloke with a beard

I'm fuming at the ridiculous mixture of extremism and political correctness that is swamping social media regarding todays incredibly evil killings in Belgium. Killings perpetrated in the name of Islam.

je suis bruxellesThe facts

  • Innocent people have been murdered by this act of planned EVIL.
  • Regular people both secular and religious alike were killed.
  • Religion (ISIS the Islamic State of Iraq and Syria) has claimed responsibility and is gloating about the death and destruction they have caused

How are ISIS Terrorists getting around?

This is a period of unprecedented un-regulated migration of tens of thousands of people from Iran and Syria into Europe. Migrants from the home counries of ISIS are able to move into the heart of Europe without any kind of security inspection.

Do we really believe that there are no islamic terrorists among the throngs of illegal immigrants flooding past European border controls? Come on now!

CPF327E Unable to move file into a new library

  • Posted on: 17 March 2016
  • By: NickLitten

That was a weird error!

I created a work file in my library, by copying an existing file from another library. I tinkered with it, loaded it with data and then wanted to rename it and store it alongside the original file in the original library. Simple enough one would think?

I renamed it in my library (simply by adding a suffix) and then tried to move it back into the original library but  *boom* IBM i gets very upset and will not let me move it reporting an error message: CPF327E Alternative name for file FILENAME not allowed.

What prevents a file moving to another library when it's got a unique name?

The problem here is - it actually hasn't got a unique name. I just thought it had. But it's got a sneaky SQL long name which already exists in the original library (schema).

Disable RPGLE 'live parsing' using Rational Developer (RDi)

  • Posted on: 29 February 2016
  • By: NickLitten

"IBM Rdi" is arguably the best code editor for coding on IBM i. That's pretty much a given. But, it's still filled with little annoyances and things that make me groan. one in particular is the lagginess and freeziing that comes when trying to edit very large programs using less that top-notch computer hardware. I present for the Jury - working at a customer site today tryingto edit a behomoth of a 65k+ line program (way to large for SEU) and RDi on the an HP desktop with 2GB memory. Open RDi... wait... wait... open source member... wait some more.... get into code changes and then it all locks up for 30 seconds while the LIVE PARSING procedures tries to figure out all the variables.

Luckliy we can turn it off!!

Window > Preferences > Remote Systems > Remote Systems LPEX Editor > ILE RPG (or type ILE RPG into the shortcut in the preferences window)

Look near the bottom and you will see 'Update the Outline View when text is changed in the editor'.

Turn it off and RDi way faster and smoother.

sqlrpgle select into extname using freeform

  • Posted on: 17 February 2016
  • By: NickLitten
bloody programers aaargh

Sometimes I find a problem and scratch my head and just cannot figure it out. i swear a lot. Then I discover the solution by climbing out of my little box, turning my head at a funny angle, squinting and thinking a bit differently. Then I swear even more. 



I converted a column based piece of SQLRPGLE from this:

d S21uservalues...                                                     
d               e ds                  qualified                    
d                                     extname('APG05PHY')  

to this:

dcl-ds S21uservalues qualified extname('APG05PHY') end-ds;   

The SQL to read this looks like this:

exec SQL fetch next from cursorAPG05 into :S21uservalues;

and then it just will not compile!

Compile error is: SQL0312  30     798  Position 52 Variable S21STOCKROOMNAME not defined or not usable.                                                   

"But that is completely valid new free format RPG syntax" I scream at the compiler. /me then goes on to waste more time than I am prepared to admit trying every combination of code to figure out whats going on


DSPF function keys in fully free RPGLE

  • Posted on: 1 February 2016
  • By: NickLitten
nothing to do with BOOKS what so ever... but it made me chuckle

Picking up user keyboard interactions in RPG is easy

But as usual there are many ways of doing it. Three main techniques are

(1) Assign a numeric value to the function keys

Probably the most common is to assign an indicator value to a function so that CMD01 sets on *IN01, CMD02 sets on *IN02 and so on.

(2) Leave the internal indicators for function keys

I see this a lot and I still sometimes use it if my program has simple function key handling. Basically, if you do not assign a numeric indicator to the function key, good ole' IBM i will assign a free one for us. Namely CMD01 sets on *INKA, CMD02 sets on *INKB, CMD03 sets on *INKC and so on. But... but... beware of the missing alphabet letters ;)

(3) Indicators smell. Dont use them

Define an information data structre in a /copybook and then you can reuse this simple technique where you like. This is my preferred technique.

Free IBM i system for Developers?

  • Posted on: 29 January 2016
  • By: NickLitten
old as400 and iseries computers are free and very very sexy

Try the machine that replaced the AS400 and iSeries for free!

  • Do you want to try the latest IBM i operating system version for free?
  • Do you want to try out the latest IBM i V7.2 programming styles?
  • Do you want to test an old program to see if it runs on IBM i 7.2 before upgrading?
  • Do you want to upgrade old AS400 RPG programs to IBM i RPGLE?
  • Do you fancy just being a nerd and poking around in the latest IBM i release?

If the answer to any of these questions is "Yes" then check out IBM's Virtual Owner program called IBM POWER DEVELOPMENT CLOUD. You simply signup for the program and get immediate no-charge remote access to IBM Power Systems for Development, Porting and Functional testing.

Get the IBM i System Name using RPGLE or SQLRPGLE

  • Posted on: 26 January 2016
  • By: NickLitten
system names and nicknames are scary in big dark computer rooms

Get Sysname using SQL

The IBM i System Name is not the same thing as the SQL Local DB Server name, although it may be the same by default.  You can retrieve the SQL Local DB Server name using this SQLRPGLE code snippet:

exec sql values current server into :systemName;
If systemName = 'my-ibm-i-system-name';
  do some stuff...

* updated May 2016 Correction from Steve Croy. Thanks!


Get Sysname using CL

The good old tried and tested technique is to write a simple Control Language Program that looks something like this:

dcl &SysName *char
rtvneta sysname( &SysName )

the main drawback with this simple method is that you have another program out there to be called by any/all programs that want to find the system name.


Get Sysname using IBM API

Most RPG programmers would probably choose to call the IBM *API to Retrieve Network Attributes (QWCRNETA). This has the same affect as calling a CL to retrieve the network attributes, but of course you could also call the *API from the CLP program if you wanted to be uber-tricky ;)

Upgrade RPG CALL statement to RPGLE Procedure call

  • Posted on: 7 January 2016
  • By: NickLitten

Continuing my #SNIPPETS series...

It's easy to refactor old CALL STATEMENTS and make them in to modern PROCEDURES. Looks nicer. Easier to read. Lets see how to do it:

Old style program calls might look like this:

C                   Call      'SY7020R01'                 
C                   Parm                    ServiceOrder  
C                   Parm                    ScheduleCode  
C                   Parm                    s@Units       
C                   Parm                    s@AppDate     
C                   Parm                    s@DropDays    
C                   Parm                    s@ResultDate  

So to make this into a PROCEDURE style call we would define the procedure like this:

dcl-pr addWorkDaystoDate extpgm('SY7020R01');  
 *n char(9) const; // ServiceOrder             
 *n char(5) const; // ScheduleCode             
 *n zoned(5);      // s@Units                  
 *n packed(8);     // s@AppDate                
 *n zoned(2);      // s@DropDays               
 *n zoned(8);      // s@ResultDate             

Note that I defined the size of each parameter and added a //comment to tell anyone what that parm is.

Also note that I defined CONST against the first two parameters because in this case, those two are static (non-changing) values and its the S@* values that are being returned from the program that I'm calling.

Upgrade old RPG 'DO' loops to sexy new RPGLE 'FOR' loops

  • Posted on: 7 January 2016
  • By: NickLitten
the fantastic for loop

Upgrading old source code -- aka refactoring -- is a fun past time and there are frequent little code snippets that I refactor over and over again. Some look similar but some look very different in modern language style. It's perhaps worth documenting them in case someone else is trying to figure out alternative ways of refactoring old style RPG3 or RPG400 code.

I just refactored an old RPG program that had a tasty little DO loop that looked like this:


C       @EarlyTmeSve  DO        @LastHr       @HourIdx
... do lots of logic and stuff
C                               ENDDO


This can be refactor to look like this:

RPG4 - also known as RPGLE /FreeFormat

For @HourIdx = @EarlyTmeSve to @LastHr;

  ... do lots of logic and stuff