Blogs

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...
endif;

* 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             
end-pr;                                        

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:

RPG400

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

EndFor;      

 

Reset Drupal password using HASH value

  • Posted on: 6 January 2016
  • By: NickLitten
only an idiot locks out their administrator user

During yesterdays reversion back to Drupal7 and subsequent website resurrection, module updates, database rebuilds and general housekeeping... I got a bit clever with myself and managed to lock up my admin profile and lose the password and disable the "email lost password" mechanism in Drupal. Aaaaargh!!!

But after a little googling I found a need solution. Hope this helps someone else that's as fat-fingered as I am.

 

Problem - Locked up Drupal profile and lost password

I have access to Drubal database but can see the password is stored in a HASh value which is not readable. It looks something like this:

So, to reset the pasword we need to (a) know a password ie: 'sausages' and (b) convert that password the HASH value. Each and every HASH value is unique to your instance of Drupal. I found a few different solutions mostly involving running scripts and updating the SQL database manually. Since I do now have command line access but I do have control panel access so I can (a) update the SQL database and (b) upload files to the server -- this technique was really easy.

 

Upgrading to Drupal8 - Episode 2 The Refusal

  • Posted on: 5 January 2016
  • By: NickLitten
drupal8 just isnt quite ready for the prime time

Episode 2 - AAAAAAARRRRGHGHGHGHGHHH!!!!

After two weeks of swearing, mumbling, installing, deleting, reinstalling, tweaking, swearing some more, leaving to drink a beer, coming back and reinstalling, purging, clearing caches, swearing, going offline for a few days, returning, reinstalling, upgrading, purging, clearing, tweaking, reinstalling, swearing some more... I decided that Drupal8 just isnt quite ready for me.

fuck pigI really, really wanted to upgrade to Drupal8 but some of the features of Drupal that make this blog experience so pleasant just dont exist yet in this early Drupal 8.0.1 version of Droop.

/me cries into my beer

So, reluctantly, i decided to rollback to my Drupal7 backup and am now back online and sighing a big happy sigh of relief.

Things I liked about Drupal 8:

 

  • The admin UI is big improvement
  • The text editing and blogging functions were slick and simple
  • i liked the integration of modules/themes and libraries
  • Web fonting was nice and it had a more modern look and feel compared to D7

 

Things I didnt like:

Too many of the modules I use in D7 just do not work on D8 yet -- and I stress the "YET"

Upgrading to Drupal8 - Episode 1

  • Posted on: 17 December 2015
  • By: NickLitten
up grade from drupla 7 to drupal 8

Episode 1 - Drupal 7 the Ghost of Christmas Past

 

Christmas is coming,

The geese are getting fat,

Please put a penny

In the old man's hat.

If you haven't got a penny,

A ha'penny will do, 

If you haven't got a ha'penny,

Then it's time for a big scarey Drupal update!

 

Drupal8 has been released and even though I like Drupal7, it's time to jump into the next version and see what it's all about.

I'm typing this in droop7 (pre-upgrade) and I'm going to record the upgrade experience here. Hopefully the look and feel of the website will remain the same. I really like this theme but will make an upgrade decision once I've worked my way to the bottom of the list of modules that I use. Once I've checked them all, I will decide wether to pull the trigger. It looks like some things have been ported to Drupal8, some have just been killed off and others have been migrated into core Drupal8:

Modules

I'm guilty of calling old fashioned RPG program code "legacy"

  • Posted on: 15 December 2015
  • By: NickLitten

I've always thought LEGACY it was the correct terminology and I've been focused on refactoring old "legacy" code into new "modern" code. But it seems that I've been guilty of using the wrong words all this time.

I just read an interesting article over at http://www.mcpressonline.com/rpg/stop-saying-legacy.html which is basically saying - Stop using LEGACY to describe programs, because really its simply an earlier version of the current program code. As soon as you promote your program code into production, it's immediately the legacy version of that code. Programs should be living things and should be gently evolving at all times. Calling it legacy promotes a negative image of the program code itself.

/me purses lips and gently nods his head in agreement  

There is another great comment after the article that says:

Web Services for Dummies

  • Posted on: 3 December 2015
  • By: NickLitten

What are webservices?

Broadly speaking "Web Services" are programs that let one computer system talk to another computer system over the internet. For example, you might want to enter customer details into a office computer system and have those customer details be checked on an online 'address checking' website or something similar.

Today, Web Services are self-contained, self-described, component applications that can be published, located, and invoked across the Web. Web Services provide a standard means of interoperating between different software applications running on a variety of platforms. eXtensible Markup Language (XML) provides the extensibility and language neutrality that is the key for standards-based interoperability of Web Services. They perform functions that can include anything from simple query responses to complex business processes. Once a Web Service is deployed, other applications can discover and invoke it. At present, Web Services require human interaction for identification and implementation.

A web service has list of methods and procedures that can be used by any of the applications irrespective of the programming languages, OS, hardware used to develop them. Any type of applications can access the functionality provided by the web service and such functionality is called web methods or web APIs.

RPG example - How to retrieve System21 Background Job status

  • Posted on: 18 November 2015
  • By: NickLitten
L1017 Infor start stop application background jobs.png

"How do I check the status of the System 21 (JBA/GEAC/INFOR) background jobs from an RPG program?"

I was asked to hack together a quick little routine to check the status of the System21 background jobs, for some specific web-service calls that were talking to an IBM i system running INFOR's System21 ERP. Hmmm... That is an awful lot of words in that sentence! Let's try it again. I am trying to say this "a web-service call to JBA SYSTEM21 needs to know if a background job is running before it does something". In this case the background job its checking for is called "WH_CONFDSP" the warehousing confirm dispatch job (or post shipment as Americans call it).

So, we know that System21 ERP does some things interactively and some things in background (aka "batch") mode.

We can easily view the background job status' using the System21 Menus: we can either goto menu /L1S (or L1SUS if American) in both the green screen and Infor Client or simply call the program from the command line:

s21 background

Pages