• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Guru: When Attention Turns To You – Writing Your Own ATTN Program

    September 22, 2025 Gregory Simmons

    Most IBM i users press the Attention key without much thought. They’re used to the familiar system-supplied menu popping up, or maybe a command line depending on how their profile is configured. But buried in the system is a powerful customization point: you can assign your own ATTN program. Doing so gives you the ability to intercept that key and provide functionality tailored exactly to your shop’s needs. There are three main ways to establish an attention program, each with its own strengths and tradeoffs.

    The most obvious method is at the user profile level. Within the profile’s attributes is a slot for the ATTNPGM parameter. Set it there, and every time that user presses Attention, the designated program runs. This is often the cleanest approach because it follows the user wherever they sign on. The downside is that many developers and operators don’t have the authority to update their own profiles, which means an administrator has to make the change on their behalf.

    The second method is at the job level. Using the CHGJOB command, you can alter the ATTNPGM setting for your current job. That means you don’t need to touch the profile itself, and the change vanishes as soon as the job ends. It’s a good approach for testing or temporary overrides. Developers who don’t have profile-change authority but do have authority to change their job often find this to be the most practical route.

    The third method is at the system level. By setting the system values QATNPGM and QATNPGMLIB, you can assign a default Attention program that applies to everyone on the system. If you specify QATNPGM(*MENU), the system calls an Attention menu instead of a program, and you can control its contents just like any other menu object. This method is sweeping in its scope: the moment you change those system values, the new Attention behavior is in place for every user. Because of that, you will need *SECADM authority (or higher, such as *SECOFR) to change them.

    A casual developer won’t be able to make this adjustment – and that’s a good thing. Misusing it can confuse or even lock out users if the program is buggy or if the menu doesn’t provide a safe exit path.

    Once you understand how to assign an ATTN program, the fun begins in deciding what it should do. For a first experiment, let’s keep it simple. You can write a CL program that just issues a command and then returns the user to where they started. If you have the authority, set it as your ATTN program on your user profile. If not, you can still test it by prompting the CHGJOB command and setting the ATTNPGM parameter to point to your program.

    Here’s a minimal example you can try today. Create a source member called MYATTN in QCLSRC with the following code:

    PGM
       DCL VAR(&MSG) TYPE(*CHAR) LEN(50)
    
       CHGVAR &MSG '*** Attention Key Pressed ***'
       SNDPGMMSG MSG(&MSG)
    
       RETURN
    ENDPGM
    

    Compile it with CRTCLPGM, and then either change your profile with CHGUSRPRF USRPRF(YOURUSER) ATTNPGM(MYLIB/MYATTN) or just run CHGJOB ATTNPGM(MYLIB/MYATTN) in your current session. Now, whenever you hit the Attention key, your little program will fire, display its message, and hand you back control.

    That’s just the beginning. Once you get comfortable with the mechanics, you can extend this in countless directions: logging where and when the Attention key was pressed, providing a utility menu for quick commands, or even intercepting attention in applications to guide users back to safety. The ATTN program is a small feature that opens up big opportunities for customization.

    Until next time, happy coding.

    Gregory Simmons is a Project Manager with PC Richard & Son. He started on the IBM i platform in 1994, graduated with a degree in Computer Information Systems in 1997 and has been working on the OS/400 and IBM i platform ever since. He has been a registered instructor with the IBM Academic Initiative since 2007, an IBM Champion and holds a COMMON Application Developer certification. When he’s not trying to figure out how to speed up legacy programs, he enjoys speaking at technical conferences, running, backpacking, hunting, and fishing.

    RELATED STORIES

    Guru: WCA4i And Granite – Because You’ve Got Bigger Things To Build

    Guru: When Procedure Driven RPG Really Works

    Guru: Unlocking The Power Of %CONCAT And %CONCATARR In RPG

    Guru: AI Pair Programming In RPG With Continue

    Guru: AI Pair Programming In RPG With GitHub Copilot

    Guru: RPG Receives Enumerator Operator

    Guru: RPG Select Operation Gets Some Sweet Upgrades

    Guru: Growing A More Productive Team With Procedure Driven RPG

    Guru: With Procedure Driven RPG, Be Precise With Options(*Exact)

    Guru: Testing URLs With HTTP_GET_VERBOSE

    Guru: Fooling Around With SQL And RPG

    Guru: Procedure Driven RPG And Adopting The Pillars Of Object-Oriented Programming

    Guru: Getting Started With The Code 4 i Extension Within VS Code

    Guru: Procedure Driven RPG Means Keeping Your Variables Local

    Guru: Procedure Driven RPG With Linear-Main Programs

    Guru: Speeding Up RPG By Reducing I/O Operations, Part 2

    Guru: Speeding Up RPG By Reducing I/O Operations, Part 1

    Guru: Watch Out For This Pitfall When Working With Integer Columns

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags: Tags: 400guru, IBM i

    Sponsored by
    ARCAD Software

    Embrace VS Code for IBM i Development

    The IBM i development landscape is evolving with modern tools that enhance efficiency and collaboration. Ready to make the move to VS Code for IBM i?

    Join us for this webinar where we’ll showcase how VS Code can serve as a powerful editor for native IBM i code and explore the essential extensions that make it possible.

    In this session, you’ll discover:

    • How ARCAD’s integration with VS Code provides deep metadata insights, allowing developers to assess the impact of their changes upfront.
    • The role of Git in enabling seamless collaboration between developers using tools like SEU, RDi, and VS Code.
    • Powerful extensions for code quality, security, impact analysis, smart build, and automated RPG conversion to Free Form.
    • How non-IBM i developers can now contribute to IBM i projects without prior knowledge of its specifics, while ensuring full control over their changes.

    The future of IBM i development is here. Let ARCAD be your guide!

    Watch Now

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Rocket Taps IDC To Assess The Benefits Of Full Scope IT Modernization Crossroads RMC Shows Off New AI Dashboard at inPOWER 2025

    Leave a Reply Cancel reply

TFH Volume: 35 Issue: 34

This Issue Sponsored By

  • New Generation Software
  • DRV Tech
  • ARCAD Software
  • WorksRight Software
  • Raz-Lee Security

Table of Contents

  • And Then There Were Two: Big Blue Withdraws IBM i 7.4
  • Crossroads RMC Shows Off New AI Dashboard at inPOWER 2025
  • Guru: When Attention Turns To You – Writing Your Own ATTN Program
  • Rocket Taps IDC To Assess The Benefits Of Full Scope IT Modernization
  • IBM i PTF Guide, Volume 27, Number 38

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • And Then There Were Two: Big Blue Withdraws IBM i 7.4
  • Crossroads RMC Shows Off New AI Dashboard at inPOWER 2025
  • Guru: When Attention Turns To You – Writing Your Own ATTN Program
  • Rocket Taps IDC To Assess The Benefits Of Full Scope IT Modernization
  • IBM i PTF Guide, Volume 27, Number 38
  • Positive News From The Kyndryl Mainframe Modernization Report
  • NAViGATE, inPower 2025 On Tap for September 2025
  • Guru: WCA4i And Granite – Because You’ve Got Bigger Things To Build
  • As I See It: Digital Coup
  • IBM i PTF Guide, Volume 27, Number 37

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle