Data areas, queried with SQL

Almost every IBM i application I have ever touched is full of data areas. The next order number. The current period. The flag that tells a nightly job whether it already ran. Little pieces of control information tucked all over the system, quietly steering how everything behaves. And most people still look at them one at a time with DSPDTAARA, like it is 1995.

You do not have to. Your data areas are queryable:

SELECT DATA_AREA_LIBRARY, DATA_AREA_NAME,
      DATA_AREA_TYPE, LENGTH,
      DATA_AREA_VALUE
 FROM QSYS2.DATA_AREA_INFO
WHERE DATA_AREA_LIBRARY = 'YOURLIB'
ORDER BY DATA_AREA_NAME;

That hands you every data area in the library, its type, and its current value, all in one place. Suddenly you can see the whole control panel of your application at once instead of squinting at it one dial at a time.

Think about what that makes easy. Documenting how an application actually works, by reading the values that drive it. Checking before a month-end run whether the control values are where they should be. Spotting the data area that is still pointing at last year. Even just understanding a system you inherited and nobody can explain, because the data areas are where a lot of the real logic quietly lives.

This is the bigger lesson I keep coming back to, and the one I am building a whole talk around lately: your system wants to tell you about itself, if you know how to ask in SQL. The old command shows you one thing. The service shows you everything, and lets you join it, sort it, and report on it. Once you start seeing the system that way, you do not go back.

Run it against your main application library this week. I would bet you find at least one data area whose value makes you raise an eyebrow.

#IBMi #IBMCHAMPIONS

Originally posted on LinkedIn. Join the conversation there.

Get new posts by email

Practical IBM i tips on SQL services, security and backup, sent when I publish. No spam, unsubscribe anytime.

Leave a Reply