• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Retrieve the System Name

    January 28, 2004 Hey, Ted

    At the end of reports, I print a special line that indicates that the report is complete. In addition to the message “end of report,” I print the qualified job name, qualified program name, and in the case of SQL programs, the last value of the SQL status variable. These values help me to debug and troubleshoot problems. I’d like to add one more bit of information.

    We recently got a new machine with logical partitioning, and we have set up a partition to use as a test environment. I would like to add the system name to the end-of-report line to help me distinguish between reports generated on the two systems.

    –Andrew

    There are several ways to retrieve the system name.

    One method is to create a small CL program that runs the Retrieve Network Attributes (RTVNETA) command and passes the system back to the caller through a parameter.

    pgm       parm(&SysName)         
    
    dcl       &SysName    *char     8
    
    rtvneta   sysname(&SysName)  
    
    endpgm                       
    

    Assuming the CL program has the name GETSYSNAME, an RPG caller would look something like this:

    Fqsysprt   o    f  132        printer oflind(*inof)             
                                                                    
    D PrtLine         ds           132                              
    D SysName         s              8                              
                                                                    
    D GetSysName      pr                  extpgm('GETSYSNAME')      
    D  SysName                       8a                             
                                                                    
    D psds           sds                                            
    D  psdsProcName           1     10                              
    D  psdsLibName           81     90                              
    D  psdsJobName          244    253                              
    D  psdsUserName         254    263                              
    D  psdsJobNbr           264    269                              
                                                                    
    C                   callp     GetSysName (SysName)              
    C                   eval      PrtLine = '* End of report *  ' 
    C                             + 'Job(' + psdsJobNbr + '/'       
    C                             + %trim(psdsUserName) + '/'    
    C                             + %trim(psdsJobName)           
    C                             + ')  Program('                
    C                             + %trim(psdsLibName) + '/'     
    C                             + %trim(psdsProcName)          
    C                             + ')  System(' + %trim(SysName)
    C                             + ')'                          
    C                   write     qsysprt       PrtLine          
    C                   eval      *inlr = *on                    
    

    The output of the program shows the system name, as you requested:

    * End of report * Job(877501/THOLT/S9) Program(THOLT/E1) System(TS400)
    

    A second method is to use a SQL special register. You may spell the special register CURRENT SERVER or CURRENT_SERVER.

    C/exec sql                  
    C+     values current server
    C+       into :SysName      
    C/end-exec                  
    

    –Ted

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    Manta Technologies

    The Leader in IBM i Education!
    Need training on anything i?
    Manta is all you need.

    130 courses and competency exams on:
    · IBM i operations
    · System Management and Security
    · IBM i Programming Tools
    · Programming in RPG, COBOL, CL, Java
    · Web Development

    SQL, DB2, QueryProduct features:
    · Runs in every popular browser
    · Available 24/7/365
    · Free Student Reference Guides
    · Free Student Administration
    · Concurrent User License
    · Built-In IBM i Simulator

    You can download our 200-page catalog and take sample sessions at MantaTech.com

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Bsafe Bolsters OS/400 Security Software with New Logging, Alerts New Domino and Blue Domino: A Little of Both At Lotusphere

    Leave a Reply Cancel reply

Content archive

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

Recent Posts

  • With Power11, Power Systems “Go To Eleven”
  • With Subscription Price, IBM i P20 And P30 Tiers Get Bigger Bundles
  • Izzi Buys CNX, Eyes Valence Port To System Z
  • IBM i Shops “Attacking” Security Concerns, Study Shows
  • IBM i PTF Guide, Volume 27, Number 26
  • Liam Allan Shares What’s Coming Next With Code For IBM i
  • From Stable To Scalable: Visual LANSA 16 Powers IBM i Growth – Launching July 8
  • VS Code Will Be The Heart Of The Modern IBM i Platform
  • The AS/400: A 37-Year-Old Dog That Loves To Learn New Tricks
  • IBM i PTF Guide, Volume 27, Number 25

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