• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Make a CL Program or Module Retrieve Its Name

    April 21, 2004 Hey, Ted

    As if I didn’t have enough to do, I wasted an hour on a wild goose chase. A user contacted me when a program cancelled. The message she received told her that program XYZ had ended abnormally. It took me a while to determine that program ABC had cancelled instead. It turned out that ABC was a clone of XYZ and still included the following, misleading CL command.

    SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Program +
                  XYZ ended abnormally') MSGTYPE(*ESCAPE)     
    

    I would like to make CL programs determine their own names, so that I can make sure each program reports the correct name in error messages, even when cloned. I have not found a CL command or an API to make a program retrieve its own name. Is this possible?

    –Chuck

    Yes. The trick is to make a program send a message to itself and retrieve the program name from the message about the sender. The following code works in OPM CL programs, ILE CL programs, and ILE CL modules.

    dcl   &MsgKey        *char      4                               
    dcl   &PgmName       *char     10                               
    dcl   &Sender        *char     80                               
                                                                    
    sndpgmmsg msg(' ') topgmq(*same) msgtype(*info) keyvar(&msgkey) 
    rcvmsg    pgmq(*same) msgtype(*info) sender(&sender) rmv(*yes)     
    chgvar    &PgmName   %sst(&Sender 56 10)                        
    

    In the case of CL modules, you should know that this routine returns the name of the program in which this module is bound, not the name of the module. In ILE modules, try the following code to retrieve both program name and module name.

    dcl   &MsgKey        *char      4                             
    dcl   &PgmName       *char     10                             
    dcl   &ModName       *char     10                             
    dcl   &Sender        *char    720                             
                                                                  
    sndpgmmsg msg(' ') topgmq(*same) msgtype(*info) keyvar(&msgkey
    rcvmsg    pgmq(*same) msgtype(*info) rmv(*yes) +              
                 sender(&sender) senderfmt(*long)                 
    chgvar    &PgmName   %sst(&Sender 42 10)                      
    chgvar    &ModName   %sst(&Sender 54 10)                      
    

    –Ted

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    DRV Tech

    Get More Out of Your IBM i

    With soaring costs, operational data is more critical than ever. IBM shops need faster, easier ways to distribute IBM applications-based data to users more efficiently, no matter where they are.

    The Problem:

    For Users, IBM Data Can Be Difficult to Get To

    IBM Applications generate reports as spooled files, originally designed to be printed. Often those reports are packed together with so much data it makes them difficult to read. Add to that hardcopy is a pain to distribute. User-friendly formats like Excel and PDF are better, offering sorting, searching, and easy portability but getting IBM reports into these formats can be tricky without the right tools.

    The Solution:

    IBM i Reports can easily be converted to easy to read and share formats like Excel and PDF and Delivered by Email

    Converting IBM i, iSeries, and AS400 reports into Excel and PDF is now a lot easier with SpoolFlex software by DRV Tech.  If you or your users are still doing this manually, think how much time is wasted dragging and reformatting to make a report readable. How much time would be saved if they were automatically formatted correctly and delivered to one or multiple recipients.

    SpoolFlex converts spooled files to Excel and PDF, automatically emailing them, and saving copies to network shared folders. SpoolFlex converts complex reports to Excel, removing unwanted headers, splitting large reports out for individual recipients, and delivering to users whether they are at the office or working from home.

    Watch our 2-minute video and see DRV’s powerful SpoolFlex software can solve your file conversion challenges.

    Watch Video

    DRV Tech

    www.drvtech.com

    866.378.3366

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Cleo Enhances Automation with AS2 Software for OS/400 IBM Cuts iSeries Prices Ahead of Power5 Launch

    Leave a Reply Cancel reply

Content archive

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

Recent Posts

  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24
  • Big Blue Raises IBM i License Transfer Fees, Other Prices
  • Keep The IBM i Youth Movement Going With More Training, Better Tools
  • Remain Begins Migrating DevOps Tools To VS Code
  • IBM Readies LTO-10 Tape Drives And Libraries
  • IBM i PTF Guide, Volume 27, Number 23

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