Blog Archives

Moving to RDMLX: Keeping Your Triggers From Crashing

Part of a series devoted to RDMLX-enabling your LANSA environments.

If you have triggers that test the value of trigger return code before you default the value of trigger return code, those triggers will crash when the I/O comes from an RDMLX function.

You Really Use Triggers?

Today, general wisdom suggests putting your business logic into a callable module so that it can be accessed from a 5250 app, a web app, and a Windows/VL app without modification. Those who created the architecture for our system back in the day believed the correct place for most business logic was in triggers. Because of that decision, triggers are now business critical in our organization.

The Switch That Does Nothing Does Something

Before considering the move to an RDMLX-enabled environment, we performed due diligence to see how well our system works. Most things work so far. However, this decision to RDMLX-enable our environments, that some people have told us “is a no-brainer because it doesn’t change anything,” is not quite so straight-forward in our situation. There ARE things that break.

But You’ve Gotta

LANSA mandates that every trigger default the trigger return code. Every time we’ve asked about this, the answer has been consistent: the examples and templates from LANSA clearly show the correct way to code the trigger return code in templates.

Andersen Software Factory

Our architecture dates back to when the Andersen Software Factory from Andersen Consulting ruled the roost. Raise your hand if you remember the Andersen Software Factory! That PC-based code generator sat on top of LANSA. Yeah, good times. Fortunately, the Software Factory was destined to sleep with the fishes once the Y2K boundary was crossed. In preparation for that glorious event, I was asked to replace it with LANSA templates. The transition went smoothly and a few of the team helped to fully deprecated those PCs… by drilling holes into the hard drives. I wish I had pictures.

That history is important because the Software Factory had a specific way of coding everything. A proper structure is a good thing and the Software Factory had some good stuff. Take conversation control, for example. There were a few places, though, where the structure was broken. Like not defaulting the value of trigger return code in triggers.

RDMLX Blows (Up)

When we began testing our ERP system in an RDMLX environment, we converted some of our RDML functions into RDMLX. We didn’t get one transaction completed because our triggers crashed. It took a couple of hours to figure out the root cause.

The IOM and the OAM are distinct objects that do not communicate with each other and that behave differently. On the iSeries, an IOM is an RPG program which is executed any time an RDML function performs I/O over a file. On the iSeries, an OAM is a C program which is executed any time an RDMLX function performs I/O over a file.  (For you LANSA hackers looking for holes in the logic, I am intentionally ignoring *DBOPTIMISE in this example.)

Now let’s test. We create a trigger function that does not default trigger return code but that does test the value of trigger return code. The trigger is called for every insert, update, and delete. We have an RDML function that maintains the file by updating one particular record that already exists. We have an RDMLX function that contains code identical to the RDML function. Identical.

  • When you maintain the file from the RDML function, the file’s IOM is used. The IOM defaults the trigger return code to ‘OK’ and passes it to the trigger. When the trigger tests the value of the trigger return code, the test succeeds since the value is ‘OK’.
  • When you maintain the file from the RDMLX function, the file’s OAM is used. The OAM defaults the trigger return code to hex X’00′ and passes it to the trigger. When the trigger tests the value of the trigger return code, the function aborts because hex X’00′ is not an alphanumeric value and #TRIG_RETC is an alphanumeric field.

We’ve run this test dozens of times and it appears that although the IOM and the OAM both default the value of trigger return code, the default value in each is different. In the case of the OAM, it appears to be, in our opinion, an invalid value for the field.

To recap, our ERP system seemed to work fine in an RDMLX environment until we introduced RDMLX functions. As soon as they performed I/O, triggers were executed which immediately aborted. Because we have everything under commitment control, this caused the entire transaction to roll back. WAMs would have had the same result.

Resolution

It appears that our only option is to default trigger return code to OK in every trigger function and to update the templates to do that for all new triggers. Unfortunately for us, this task is not only huge, it is risky. We are in the process of automating this process of updating trigger functions in order to reduce that risk.

Moving to RDMLX: Remember the Editor

Straight out of college, I was the new kid on the block and was green; a newbie not realizing the part LANSA would play in my career.  I remember being in the cube of a seasoned developer as he was editing a function.  I remember watching when instead of using the standard insert line command he used “IP” to insert PRIOR to the current line.  To me it was a brilliant Easter egg and I immediately incorporated it into my bag of tricks.

Then it happened. I couldn’t stop myself. I improved on it.

I created a single keystroke macro that inserted prior. Then I created another for the standard insert.  Without realizing what had just happened, I became obsessed with removing friction from my workflow. And it all started inside LANSA’s green screen editor.

Today the tradition continues. Any task that happens more than twice gets automated.  For any word with specific capitalization or that I have mistyped more than twice, I create a word replacement rule.  It is a living utility that I constantly update and improve.  I call it Underflow since its’ power is hidden from view and I have made it freely available to other developers.

I’ve been in the LANSA world for 17 years and so much of that time was spent in that silly editor.

Who can forget having to use the unformatted prompt (“U”) on some of those massive DEF_LINE commands?  Or moving and deleting blocks of code with double Ms and double Ds.  Or jumping to SEU and screwing up those long comment lines? Or freeform typing commands without the parameter names and then using <prompt> and <enter> on each one to make then look pretty.

Did you EVER change “Roll” to something other than 13? I did once.

So, my friend, it is with bittersweet anticipation that I work toward eliminating you as we move toward RDMLX-enabling our environments.  Once we do, you become a read-only viewer for RDML functions.

I wonder what I will remember.  I will remember the now-missing F21 key that was so engrained in my muscle memory that I could press it without thinking.  I will remember that you never locked up or crashed like your upstart younger brother VL; not one crash in all those years.  I will remember the countless hours of poring over code, getting frustrated AGAIN that I had to save (triple enter!) before indenting and coloring.  I mean, really, why can’t I color the code while in edit mode?  I will definitely remember using you to debug one function at a time.  Ah, how quaint.  I remember the excitement I felt when I finally understood how to use your report designer.

I have memorialized you.  RDMLX code is supposed to be viewed only within Visual LANSA but we needed a way to view it on the green screen in production.  So I built a viewer over Frodo (DC@FRD) that looks just like you. It includes indenting and coloring.  They are turned on by default because it makes me feel kinda like a rebel.

LANSA has memorialized you. Whippersnappers these days don’t know what they are missing just using the compile button in VL.  Using Full Function Check shows a window with access to the old screen and report designers.  LANSA cloned them from your keyboard-driven  interface and grafted them into a mouse-driven interface.  They are the Franken-editor.

Over time we will convert more of our vintage functions to RDMLX to get more use out of the language. We will spend the majority of our time in Visual LANSA and you will fade into a fond but distant memory.

Today I am the seasoned developer mentoring the new kids on the block and showing them Easter eggs.  They are straight out of college and green; newbies snickering at the boring but stable green on black and bragging how they’ll never have to use it because they have VL.  I choose to sit quietly and smile knowing they don’t have the experience to understand the part you played.

I remember.

Moving to RDMLX

If you recently began using the LANSA platform, enabling RDMLX was a no-brainer.  In fact, you might not have even know there was an option.  Your LANSA environments likely supported RDMLX right out of the gate.  If this is your situation, feel free to ignore the rest of this article.  It will only serve to invoke a sense of gratitude for the minefield you avoided by showing up to the LANSA party when you did.

For the rest, you probably have LANSA systems on the iSeries that have been around for many years and you are unsure how they will be affected by enabling RDMLX.  Before we go any further, there are two similar but vastly different meanings behind the term “enabling RDMLX” and it is important to understand what we are talking about.

  • RDMLX-enabling a partition.  This prepares one partition in your LANSA instance to accept RDMLX objects.  When you hear someone talk about “throwing the switch,” they are referring to making the partition RDMLX-enabled.
  • RDMLX-enabling a field, a file, or a function.  Once your partition is RDMLX-enabled, you have the option of using RDMLX objects in addition to RDML objects.  You can create them new or you can convert existing.

The benefits of RDMLX are attractive: WAM development, more field types, fewer 3GL limitations, and others.  However, the decision to move to RDMLX can weigh heavy on the decision maker.  I have seen this look in the eyes of many managers.  They hear an incessant whisper from that trusted area of their brain warning them to be safe, to understand what they are about to do, and to mitigate the risk.  There are some in the LANSA community that will tell you with passion to just “Throw the switch. It does NOTHING!”  Let me warn you to do your research before making that leap.  Throwing the RDMLX switch causes some things stop working.  There are additional gotchas and if you want a seamless transition, you will need to take the time to understand what those gotchas are.

My goal is to install caution, not fear.  Moving to RDMLX is straight-forward as long as you have a road map.  In an effort to help, I am writing a series of articles on Moving to RDMLX.  I hope you find them useful.

If I had to pick the most important truth to ponder, it would be that Visual LANSA is now your only method for creating and maintaining LANSA objects.  You might consider spending a few minutes to more fully understand how this will impact your team.  If you already use Visual LANSA extensively, the impact will be small.  If some on your team primarily use the green screen interface, their transition will most likely take longer.

Here are some future topics:

  • What is the impact of only maintaining LANSA objects from within Visual LANSA?
  • All triggers must set the value of #TRIG_RETC since the default value coming from the OAM is different than what comes from the IOM.
  • Functions that create functions (and fields and files) will no longer work on the iSeries.
  • LANSA fails to create an OAM for certain files even though the IOM is created without issue.
  • Debugging RDMLX objects versus RDML objects.