My Blog

Query Management Queries are Queer

nowt as queer as queries

So, I was emailed the following hints and tips document discussing the ubiquitous Query Management Qeuery object type on the IBM Power Server (the artist formerly known as AS400). It's useful to refer to so, here it is:

QMQRY - QUery Management Query

A SOURCE FILE FOR YOUR QUERY

The key to making a query dynamic is converting it into a form that can accept variables. The easiest way to do that is to convert your query to a Query Management Query (QMQRY). A QMQRY is simply an SQL statement stored in a source member. Once the SQL statement has been placed into a source member, you can replace hard-coded values from your original query with variables that can be replaced at execution time. If you've never worked with SQL before, you needn't worry; we will make use of an IBM command that will construct SQL statements for you.

We'll begin by creating the source file used to store your QMQRYs: QQMQRYSRC. To create this source file, use command Create Source Physical File:

Camp Bow Wow Las Vegas - Pet Hotel with a difference

Bailey during an evening walkies in Vegas

My hound, Bailey Version Two, is staying with the wonderful chaps at Camp Bow Wow Las Vegas this week.  I'm Hurricane dodging on the East Coast, and didnt want to risk flying him over here with all the potential air travel problems. So, he's shacked up for ten days with his buddies at Camp. I did laugh this morning, when I discovered that Bailey had taken time from his busy canine-play schedule to email me:

using %REPLACE to Scan Replace in RPG4

replace my head with a younger more handsoe one please

So, I want to do a SCAN and REPLACE in RPG - What's the easiest way?

Using the %REPLACE built in Function is easy and efficient allthough code wise its a little cumbersome:

// Update email address                                  
Dow %Scan('L#EMAIL': %TRIMR(SrcDta )) > *Zeros;          
    SrcDta  = %Replace(%trimr(ParmEmail) 
              :SrcDta 
              :%Scan('L#EMAIL' : %TRIMR(SrcDta ))
              :7);    
EndDo;                                                   

In this example, I am scanning a program variable (SRCDTA) looking for any occurence  of the word "L#EMAIL" and replacing it with the contents of "PARMEMAIL". The email value is %TRIM'ed which means that any blanks at the end of the email address are ignored.

I use a similar process in the PROJEX Service Program and then you can easily run a SCAN/REPLACE on a single line of RPG code.

So lets say I wanted to scan for the word 'bob' and change it for the word 'Fred' within a string i could do it like this using this Prototype:

$ResultVariable = #Scanreplace ( $OriginalVariable : 'bob' : 'Fred' )

Much simpler than using the complex %REPLACE BIF I'm sure you will agree. 

Here's the Prototype:

CL Outfiles are like totally last year, Dude!

ibmi cross reference files

Using the internal cross reference files mean that us lowly IBMi Programmers can access heap of system information just by reading a file... the days of DSPFFD to an outfile then reading the outfile are long gone - we can just read the file field information direct from QADBIFLD instead...

There are eight cross-reference physical files, each containing a different type of information.

How do I right adjust a numeric into an alpha field using RPG4?

Dont throw those lovely boxes out Mummy!

I have a NUMERIC in an RPG program that I want to move RIGHT into an Alpha field. In the old days of RPG3 I would use MOVE but in the new days of RPG4 I have a couple of more flexible solutions.  So, lets say we have a numeric field containing the number 1234, defined as an signed numeric 10 long it would be stored as - 0000000123. And a Result field which is a big long alpha field:

d $Numeric          s             10s 0 inz(1234)

d $Result           s             10a   inz(*BLANKS)

Some programmers will forget that $variable = $something else is actually eval $variable = $something because the eval is silent  :)
 
We have two easy ways of transforming using RPG4:

With Zero Suppression

If we want to be  tranformed right justified  as  '          1234'' then:

Eval(r) ResultVariable = %char($Numeric);

Droid Razr HD - Coming to Verizon Oct 18th?

I remember my Nan and Grandads bakelite phone

I've rarely been as excited to get my hands on a new phone as I have been since the announcement of the Motorola Droid Razr HD model.

According to Droid-Life, whispering points to Motorola and Verizon targeting October 18th as a release date for both the Droid RAZR HD and the Droid RAZR MAXX HD.

...the RAZR HD and RAZR MAXX HD both tout a 4.7-inch 720p Super AMOLED HD display and 1.3-megapixel camera on their faces, as well as an 8-megapixel shooter around back. The two phones also feature 1.5GHz dual-core processors, 1GB RAM, Verizon 4G LTE connectivity, Motorola's Smart Actions software and Android 4.0.4 Ice Cream Sandwich, with an upgrade to Android 4.1 Jelly Bean coming before the end of 2012. The differences between the two phones involve battery size and storage. The RAZR HD features 16GB of memory while the RAZR MAXX HD packs 32GB of storage space (both have microSD slots), and the RAZR HD has a 2,530mAh battery while the RAZR MAXX HD's battery is 3,300mAh...

Doing Loop the Loops in RPG3 and RPG /Free

rpg do loops

So, whenever possible, if I'm editing some old RPG3 or RPG400 code I spend a coffee* cleaning the code up to a more readable form:

  • Use CVTRPGSRC if its old RPG3 stuff
  • Change '1' to *ON
  • Change '0' to *OFF
  • Change Z-ADD to EVAL
  • Insert comments where applicable
  • put some spaces between subroutines and blocks of functionally similar code
  • Then its into WDSC7 and convert to /FREE

Websphere is old technology but I'm not going to spend over $800 on IBM's Rational Developer for i version... c'mon IBM come up with a sensible price for a source code editor. Obviously, the most sensible is FREE.

DO LOOPS are something that sometimes make me scratch my head when uplifting to RPG4. So just for my reference here is an example of the exact same code in RPG3, RPG400 and RPG4 (or RPG ILE as its sometimes called).

 

RPG3

Whats better - Hard work, Knowledge or Attitude?

number jokes are funny for mathematicians

Here is a little something someone sent me that is indisputable mathematical logic. It also made me Laugh Out Loud.
This is a strictly mathematical viewpoint...it goes like this:

What Makes 100%? What does it mean to give MORE than 100%? Ever wonder about those people who say they are giving more than 100%? We have all been to those meetings where someone wants you to give over 100%. How about achieving 103%? What makes up 100% in life?

Here's a little mathematical formula that might help you answer these questions:

If:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

is represented as:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

Then:

H-A-R-D-W-O-R-K = 8+1+18+4+23+15+18+11 = 98%

and

K-N-O-W-L-E-D-G- E = 11+14+15+23+12+5+4+7+5 = 96%

But ,

The new NICKLITTEN dot com is gonna be whacky for a few days

Fear no Eval for RPG Programmers

I've been busy doing real work the last few evenings and seeing my wonderful kids (but HEY I'm biased) so the time I had planned for this website revamp has just kind of drifted away like smoke through my fingers. I managed to grab a few hours this evening and have just completed the Drupal migration from my old domain, upgraded all kinds of bits, SQL'd other stuff and broken all kinds of rules, utterly destroyed the Drupal Database integrity but luckily with some massaging and praying to Shiva (as I understand it he's the God of Destruction and Reinvention, so is the top man for this website gig) I think I've got NickLitten.com closer to a working website condition.

some dodgy redneck bed - all squished

I could leave it in Maintenance mode but then its difficult to track the effects of my Google/Bing/Blekko SEO effects....

Anyway... decided to turn the website on just a few minutes ago. So here I am in a redneck (Hmm, maybe I had better be careful what i say around here. If I listen careful I can hear the plaintive 'sproing' of Banjo strings blowing in the wind) Country (ahhh, thats safer) Motel in Virginia at 1.15am on a Friday night, or Saturday morning depending on how you look at it.

I'm tinkering with my laptop when I should be curled up in that wobbly bed behind me...

*yawn*

Theres a good idea...

How to update Turnover for Windows

update turnover change management

Turnover (from Soft Landings Inc) is a pretty cool Software Change Management system running on IBMi.

Arguably its best in class and certainly my preferred SCM tool. Saying that, the old 5250 (green screen) functions are frustratingly lacking in some areas where the company has obviously decided to only focus continued development on its Windows client - Turnover for iSeries.

when does iseries become IBMi

[quote]It's not Turnover for iSeries, its Turnover for IBM-i! Would you sell a Windows package and sell it as Turnover for DOS or maybe Turnover/XP?[/quote]

But, the Windows client is based on the Eclipse IDE and its pretty neat. It's regularly updated, but you need to know how to grab the very lastest updates. So here you go.

I recorded this little screen cast with the excellent freebie JING from Techsmith but didnt record any sound... because I am huddled in a super quiet littel Dilbert cubicle and it may have awoken my fellow programmers.

The important piece is this URL - http://support.softlanding.com/t100client/2012Q2/

Projex4i New Version - The Community Edition is coming

Projex4i is a free premium IBMi AS400 application for developers

So, I've decided its time for me to step up to the plate (to use a strange Americanism) and get ready to take Projex to the next level...

*Deep Breath* 

I'm at the final part of a major product re-write for PROJEX4I and a new version should ready to be released within two weeks. Projex4i has had over 500 downloads and some great feedback, ranging from critical reviews to glowing ones. Even the odd offer of a beer or two  :)   This has got me to thinking about how to find the time to create some of the funkier utilities I have floating around in my head. So, I think its time to monetize the application and offer Developers Tools that are comprehensively packaged in one easy to access application. Ultimately, the focus is on making tasks easier, therefore timesaving and giving something back to the IBMi community as a whole.

New Discovery on Mars: Positive Evidence of IBMi Life!

Positive Evidence of IBMi Life on Mars!

HOUSTON, TX - Scientists rejoiced on Friday after learning NASA’s Phoenix Lander photographed what appeared to be evidence of life on Mars. At first inspection of the photo there seemed to be nothing remarkable about it.

However, when magnified several times, it became clear there was something more than just rocks and sand on the Martian surface.

Peter Smith, the University of Arizona researcher who leads the Phoenix mission’s science team, announced late Saturday that colleagues were convinced that the apparent life forms were trying to communicate with the Phoenix Lander, although at this time it is only speculation.

“To me personally, it was such a thrill to find such strong evidence of life. I was disappointed at the references to the IBM i, since I am a Unix man myself. Still, I’m just sitting on the edge of my chair waiting to see what the Phoenix Lander will reveal to us next.”

In the weeks ahead, the spacecraft will attempt an unprecedented examination of the apparent life forms. Those findings may reveal evidence of extensive Martian life and even the possibility of intelligence.

The Tale of the IBM vs. Microsoft Programmers

The Tale of the IBM vs. Microsoft Programmers

Three Microsoft software engineers and three IBM software engineers are traveling by train to a conference. At the station, the three IBM software engineers each buy tickets and watch as the three Microsoft software engineers buy only a single ticket.

“How are three people going to travel on only one ticket?” asks one of the IBM programmers.

“Watch and you’ll see,” answers the Microsoft programmer.

They all board the train. The IBM software engineers take their respective seats but all three Microsoft software engineers cram into a restroom and close the door behind them.

Shortly after the train has departed, the conductor comes around collecting tickets. He knocks on the restroom door and says, “ticket, please.” The door opens just a crack and a single arm emerges with a ticket in hand. The conductor takes it and moves on.

The IBM software engineers witness all this and agreed it was quite a clever idea. So after the conference, the IBMers decide to copy the Microsofties on the return trip and save some money.

When they get to the station, they buy a single ticket for the return trip. To their astonishment, the Microsoft programmers don’t buy a ticket at all.

“How are you going to travel without a ticket?” asks one of the perplexed IBM employees.

“Watch and you’ll see,” answers one of the Microsoft programmers.

How to use Smileys correctly

smile youre on camera

:-) Smile

(-: User is left handed. 

%-) User has been staring at a green screen for 15 hours straight. 

:*) User is drunk.

[:] User is a robot.

8-) User is wearing sunglasses.

B:-) Sunglasses on head.

::-) User wears normal glasses.

B-) User wears horn-rimmed glasses.

8:-) User is a little girl.

:-)-8 User is a Big girl.

:-{) User has a mustache.

:-{} User wears lipstick.

{:-) User wears a toupee.

}:-( Toupee in an updraft.

:-[ User is a vampire.

:-E Bucktoothed vampire.

:-F Bucktoothed vampire with one tooth missing.

:-7 User juust made a wry statement.

:-* User just ate something sour.

:-)~ User drools.

:-~) User has a cold.

:'-( User is crying.

:'-) User is so happy, s/he is crying.

:-@ User is screaming.

:-# User wears braces.

:^) User has a broken nose.

:v) User has a broken nose, but it's the other way.

:_) User's nose is sliding off of his face.

:<) User is from an Ivy League School.

:-& User is tongue tied.

=:-) User is a hosehead.

-:-) User is a punk rocker.

-:-( Real punk rockers don't smile.

:=) User has two noses.

+-:-) User is the Pope or holds some other religious office.

Recycle Your Old AS400

recycle your old as400

 

Rochester, MN - As you know, IBM is a politically correct and an environmentally conscious company.

Because of the success of the new System i and i on Power systems there has been a growing surplus of the old model AS/400s. With the concerns of overburdened landfills and in this age of recycling and protecting our environment, IBM has announced a new program for recycling these older AS/400s. The program is called RECYCLE/400.

For a minimal fee IBM will take your old AS/400 and convert it to a useful product.

You can choose from the following list:

  • metal rhino
  • clothes hanger
  • cutlery
  • rabbit cage
  • fishing hooks
  • tanning booth
  • landrover bonnet
  • highway crash barrier

Convert RPG %DATE into a signed numeric

To convert a DATEFIELD to this 8s0 field with no ‘/’ or ‘-‘ do this:

 

 

D  USADate                    8s 0

USADate = %dec(%char(DateField:*iso0):8:0);

 

Or another even neater function is this:

 

USADate = %uns(%char(DateField:*USA0));

 

I prefer this %UNS built in function, since it does not require me to specify length and decimal position parameters. 

 

What is %UNS?


%UNSH (Convert to Unsigned Format with Half Adjust)

 

%UNSH(numeric expression)

%UNSH is like %UNS except that if the numeric expression is a decimal or a float value, half adjust is applied to the value of the numeric expression when converting to unsigned type. No message is issued if half adjust cannot be performed.

 

*..1....+....2....+....3....+....4....+....5....+....6....+....7...+....

Can I upgrade JBA SYSTEM21 from IBM-i v5r4 to V6 or V7?

upgrade JBA to newer version of IBMi OS

Just what is JBA anyway?

JBA Softwre Company from BirminghamThe JBA ERP system is a 30 year old Enterprise Resource Planning system running on IBMi operating system (an on the earlier i5/OS and OS400 versions). I can sense your eyebrow raising when you read "30 years", but think of it as a system that has evolved for thirty years and grown incredibly. Originally developed and distributed by UK based company JBA (from in-house developed system called Olympic and also by blending in field developed products from many client sources). The entire product line was later bought and distributed by GEAC in the USA. Following the demise of GEAC the latest and greatest version is (at the time of writing) provided and supported by Infor.

  • The older JBA/GEAC versions of System21 and all related apps will run on any system upto and including V5R4.
  • The current version of System21 is called Aurora, supplied by Infor and runs on all the latest version of IBMi (currently IBMi Version6 but Version7 is in beta so watch this space)
I think that the last version of JBA System21 was V3.5.2 and this was the basis for the new improved Infor version. From what I understand, the Infor version is a total conversion of all the old System21 OPM RPG source Code to ILE RPG and recompilation. Infor has also added lots of new web-friendly components and modernised the entire package for the new millenium.

infor system looks good

 
What OS versions will JBA run on
  • JBA System 21 will run on all versions upto and including v5.4
  • Infor Aurora will run on all version upto and including the current version.
Upgrading to V6 is as big an upgrade as the old Cisc-Risc upgrade in the mid-nineties and requires programs to have their observability included in the object description to process each object as part of the upgrade. 

add days to 100 Year date from EXCEL using RPG

vintage computing

So, we had a file coming in from an external partner today – containing a date in Julian Format. Or what I initially thought to be Julian format. 

[quote=Some Website Out There]Many applications (especially mainframe systems) store dates in the Julian format, which is a 5 digit number, consisting of a 2 digit year and a 3 digit day-of-year number.   For example, 24-August-1999 is stored as 99236, since 24-August is the 236th day of the year...[/quote]

Then when I looked at the date in question I realised the value was 42345 but this was representing an actual date of December 8th 2015! So, this clearly isnt a Julian date... Hmmm...

Cutting to the chase, it turns out that this date is stored in what the customer refers to as '100 year date format' which is basically the number of days since the last day of 1899. Which just goes to show that those crazy Victorian's where utter whackjobs. 

Luckily its simple to figure out programmatically using RPG4:

 

Another big list of as400 technical, practical questions and just plain brain teasers

old computers are cool

So, last night I was nosing around in the dim dark corners of an old network share on my homeserver. I stumbled across an old TXT document from the late 90's, I think. It was sitting in a text file called "AS400 brainteasers" -it's obviously old (look at the as400 model numbers question).

It was fun to scan through these questions and answers. I got a about 98% right... there were a couple where I dropped the ball and I blame that on the vintage questions and my fading senility... 

Test yourself and see if you can be classed as an AS400 specialist:

AS400 Questions

a vintage as400 server

What is the Configuration of the AS/400 system on which you have worked?
System E35(Model 9406), 24MB main memory, 3.2GB of HD and supports 49 terminals (7 Port).

How many terminals can be connected to a port?
7 terminals

free rpg code editor for windows - Visual RPG Express

free rpg3 and rpg4 code editor

I'm a big fan of WDSC7 (Websphere Development Studio Client for Windows) for my RPG/CL/DDS/SQL/whatever coding when I'm using windows.. but there are a few others out there. I would love to use IBM's RDi (Rational Developer for IBM i) but while IBM insist on charging around $900 for the program it puts it firmly out of my wallet range. Quite frankly, its such an utterly ridiculous price for a piece of software I cant ever see myself championing it.

I found this article over at Midrange News:

[quote]Visual RPG (aka "CodeStudio") is a PC Windows XP-based editor for RPG IV, DDS, and other languages. It was original sold to AS/400 developers as a "CODE/400 for Windows" product when there was no Windows-based "CODE/400" (they only did an OS/2 version). Later it was renamed to "CodeStudio" and that trademark was purchased by a multi-national corporation and the product name was changed back to its original "VisualRPG" and provided at no-charge with no support. It uses FTP to pull down the source from the host and save it back up to the host, hence the source statement change dates are lost.[/quote]

Here are the instructions (over a decade old but if they help someone out then TADA!)

Pages