Blogs

RPGLE and SQLRPGLE - The dreaded USRPRF(*OWNER) conundrum

  • Posted on: 15 December 2016
  • By: NickLitten
never enough time to program in RPG

How does USER(*OWNER) work with RPGLE Programs?

If you compile IBM i programs using USRPRF(*OWNER) then they will adopt the security setting for the program owner at runtime. #sometimes

If you are calling an IBM i SQL program, that has been compiled with USRPRF(*OWNER) you may find that it does NOT adopt the security setting. This is because SQL is a special beast that has it's own compile time settings that override this authority elevation. Luckily it's easy to fix -- the SQL setting can (a) be set by changing a parameter at Compile time or (b) be set in the code itself by defining how you want this SQL program to be created.

RPGLE "ON-EXIT" is housekeeping or *PSSR for Subprocedures

  • Posted on: 15 December 2016
  • By: NickLitten

IBM is adding all kinds of new tweaks to RPG with each new release of IBM i

I just noticed a rather neat new function called "ON-EXIT" over at the IBM Developerworks. This is available if you are running IBM i V7.2 or higher:

The ILE RPG compiler is enhanced with a new ON-EXIT opcode which egins the "ON-EXIT" section containing code to be run whenever a procedure ends, either normally or abnormally.

So, if you have code that you always want to run at the end of a procedure you can just put that in the ON-EXIT section. A nice structured way of storing procedure house keeping and/or error catching.

The ON-EXIT operation code begins the ON-EXIT section. The ON-EXIT section contains code that runs every time that the procedure ends, whether it ends normally or abnormally. The ON-EXIT section runs under the following conditions:

The procedure reaches the end of the main part of the procedure.

The procedure reaches a RETURN operation.

The procedure ends with an unhandled exception.

The procedure is canceled, due to the end of the job or subsystem, or due to an exception message being sent to a procedure higher in the call stack.

Batch Job changes RUNPTY to make it faster

  • Posted on: 15 December 2016
  • By: NickLitten

Some Batch jobs take a long time to run. If you have a batch job with the words "trial balance" in the title then its going to take hours... That is a "hashtag internet fact" ;)

A common technique to try to give these jobs a little boost is the jobs outer control program to try ti change itself to run a little faster. This is commonly done by reducing the ru priority (so it gets into run state more often than other batch jobs that are waiting to be processed, one bite at a time) or to increase timeslice (so the job stays in the processing state for longer once its being run).

What security setting does IBM i, AS400 or iSeries user need to chgjob

Only a user with job control (*JOBCTL) special authority can change the RUNPTY, TIMESLICE, PURGE, or DFTWAIT values.

If you dont have *JOBCTL then the user that is running the "trial balance" will see an error message:

Securely connecting your IBM i System to the Internet

  • Posted on: 14 December 2016
  • By: NickLitten
secure iseries as400 and ibm i system cloud internet

Over recent years I've become increasingly focused on connecting IBM i Systems to the Internet - aka cloud for you trendy peeps.  We live in an internet connected world and the requirements for business to plug their back office Power Servers into this big cloud is rapidly becoming a standard.

With the huge increase in mobile development and webservice focused business even IT Departments that have never thought about internet connection are now considering the consequences.

This leads to many of my customers asking me the same question:

HOW SECURE IS IBM I (AS400/iSERIES) INTERNET CONNECTION?

Well, the simple answer is "IBM i has world class security levels, a great firewall and terrific authority auditing tools. It's tried and tested. But you must assume that it will never be 100% secure"

There are just too many bad guys out there in the murky corners of the internet. Bad guys who like to try and break into companies servers to steal, to prove they could do it and sometimes just for fun. 

There are squillions of website resources so I'm going to list a few to use as library I can easily point people at:

 

Adopting Authority - Problems with SQL RPG Programs

  • Posted on: 14 December 2016
  • By: NickLitten
SQLRPGLE does not adopt user authority

RPG PROGRAM USER(*OWNER) - Adopts the object owner level of Authority

Most IBM i Programmers are aware of the USER(*OWNER) compile setting -- anyone calling this program will adopt the authority level of the program. So if a program is compiled by user QSECOFR and USER(*OWNER) then anyone calling that program will automatically be elevated to QSECOFR level rights for the duration of that program execution.

This is a simple trick that's sometimes used to create utilities that need specific authority settings.

It's also used to allow users to adopt an authority setting for access to a specific application (without needing to grant authority levels to all the users in question).

Adopting USER(*OWNER) rights lets a user access a database that he/she might usually not be authorised to.... but only when calling that program. You may be able to see that if a user initial program is *OWNER, this can be used to automatically grants specific users rights to an application and its database when they wouldnt normally have that access just from a command line.

How to change all lines on turnover form to add, delete or replace

  • Posted on: 8 December 2016
  • By: NickLitten
change softlanding turnover form easily with projex4i

LMS7.3 - IBM i Lodging Management Systemthis week i will be mostly usig unicom softlanding turnover

In the words of Jesse from the Fast Show (showing my age there) -- This week I will be mostly preparing to upgrade LMS 7.1 to LMS 7.3.3

So, this Las Vegas Casino uses Turnover V100 to manage software change management across its IBM i Systems. I actually helped them setup and run their huge customized Hotel System upgrade to LMS7.1 a few years ago and was delighted to be asked to come back and help them do it all over again, but this time going to LMS 7.3.3

The difference with this upgrade is that many of the Casino's bespoke customizations have now found their way down into the Agilysys LMS base product. This is great news for the software development team, reducing the scope of their software support.

Replace IBM i Native File Access with SQL

  • Posted on: 29 November 2016
  • By: NickLitten

I found this excellent article by Birgitta Hauser (BHA@Toolmaker.de), Software and Database Engineer, Toolmaker Advanced Efficiency GmbH

Just in case it vanishes I'm going to reproduce it here and have also attached it as a PDF. If you are considering SQL and investigating how using SQL Indexes can benefit the business then this makes some excellent coffee time reading. 

 

Save a Library to a SAVF, ZIP it and FTP to another IBM i Server

  • Posted on: 22 November 2016
  • By: NickLitten
Save a Library to a SAVF and ZIP it up

Fastest way to transfer SAVE FILES from IBM i Server to Another over the network

We save a library to a SAVF, Squish that save file down into a smaller format. Send that little squishy packet over the network (quicker because its smaller). Then we un-squish it on the other end and restore it. #simples.

Squish it up

SAVLIB LIB('Library-to-be-saved') DEV(*SAVF) SAVF(MYLIB/MYSAVF) DTACPR(*YES)

This uses IBM i's built-in compression and will make any save file a few percent smaller than standard.

Now we have the *SAVF in the smallest possible size... let's squish it smaller.

We are going to use JAVA to squish that *SAVF into a *ZIP file. Of course this assumes Java installed on your IBM i Server as a licensed program.

Remember we can access that *SAVF using the IFS naming formats. ie: LIB(MYLIB/MYSAVF) can also be referenced as /QSYS.LIB/MYLIB.LIB/MYSAVF.FILE/MYSAVF.SAVF 

Start the JAVA shell on the green screen command line to zip it up:

STRQSH
CD /QSYS.LIB/MYLIB.LIB/MYSAVF.SAVF
JAR -cf MYZIP.ZIP MYSAVF.SAVF

The Java "Jar" command basically creates a Java Jar file which is nothing more than a zip file. It's trnsparent and real time compression is quick.

So, now you have a smaller ZPI file called MYZIP.ZIP that you can FTP, email, copy/paste or send by snail mail.

Hope it useful :)

 

How to archive redundant objects using Turnover for IBM i Series

  • Posted on: 2 November 2016
  • By: NickLitten
How to archive redundant objects using Turnover for IBM i Series

Steps to remove code from scheduled Releases

 

TO - Turnover Menu

Option 9 - Work with Projects and Tasks

Create a Worklist and then Checkout program at top level (presumably your production level)

Option 46 - Add to form (on object library you want to remove objects)

This will create a new form and make sure you add recompiles

Resequence the form  . . . . . . . . . . . . . . . . . N      
Check for logical files and add them to the form . . . Y   
Check cross-reference file for related objects . . . . Y       
Check for objects changed by other programmers . . . . N      

F21 - Select all Recompiles

Note - Always select application you are using on - Cross Reference application Selection screen

Now we have a form created and ready to do something to all those checked out objects. We can just go and update the form to DELETE

Option 42 - Edit form

Change each object on form to mark it as a DELETE request (dont worry because Turnover will archive the object to its archive library before it *deletes* the real one)

F7 - Update Top

Change Code to 'D=Delete'

Repeat for each object on form

How to extract the NUMBERS from an alphanumeric string

  • Posted on: 12 October 2016
  • By: NickLitten
bite chunks of data out of big fat data

Also known as - how to select only the number from an address in a field, or file data

A little while ago, I wanted to extract out the numerics from a string of data:

For example - if I feed in "111 High Street, 5th District, Charleston, SC 29466" then I want to get "111529466" returned.

Obviously there are several ways of doing this. But a few techniques sprang to mind so lets do some timings using common variable names. These code examples are using values of (a) $address = long varying variable with an Address in it and (b) $number variable defined as 15,0 containing returned numeric value. To do some timings on this, I read 10,000 address fields from a customre master file and fed this data into the following routines. This gave me a sensible execution time that i could do a rought timing with:

 

METHOD 1 - Read through the address string, position by position to find the numeric values:

 

For X = 1 to %len($address);

  StringChar = %subst($address : X : 1);

  If StringChar >= '0' and StringChar <= '9';

    Eval $number = %Trim($number) + StringChar;

  Endif;

EndFor;

 

10k results each saying "111529466" Correctly

Runtime - 2.15 seconds   

 

METHOD 2 - Use %XLATE to remove all non-numerics then use %DEC to convert to numeric

 

Pages