• 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
    FalconStor

    Protect It or Lose It and Pay Ransom for It

    FalconStor StorSafe VTL protects your IBM i data on-premise and brings the IBM PowerVS Cloud to you

    FalconStor powers secure and encrypted IBM i backups on-premise and now, working with IBM, powers migration to the IBM PowerVS cloud and on-going backup to IBM cloud object storage.

    Now you can use the IBM PowerVS Cloud as your secure offsite copy and take advantage of a hybrid cloud architecture or you can migrate workloads – test & development or even production apps – to the Power VS Cloud with secure cloud-native backup, powered by FalconStor and proven IBM partners.

    Learn How FalconStor Protects the IBM Cloud

    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

  • LANSA Developing Business Intelligence Tool
  • Blazing The Trail For VTL In The Cloud
  • Data De-Dupe Gives VTL Customers More Options
  • Four Hundred Monitor, March 29
  • The Big Spending On IT Security Is Only Going To Get Bigger
  • IBM Tweaks Some Power Systems Prices Down, Others Up
  • Disaster Recovery: From OS/400 V5R3 To IBM i 7.4 In 36 Hours
  • The Disconnect In Modernization Planning And Execution
  • Superior Support: One Of The Reasons You Pay The Power Systems Premium
  • IBM i PTF Guide, Volume 25, Number 13

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 © 2023 IT Jungle