How to retrieve system name on which I am working in AS/400?

5 pts.
AS/400 administration
CL Program
CL programming
How do I retrieve system name on which I am working in AS/400?

Software/Hardware used:

Answer Wiki

Thanks. We'll let you know when a new response is added.

A CL program (or module) can retrieve the system name this way:

dcl &SysName *char 10
rtvneta sysname( &SysName )

In HLLs such as RPG, the Retrieve Network Attributes (QWCRNETA) API can retrieve the same info. (The API can also be called in CL, but the RTVNETA command is easier.)

You need to be aware that the “system name” is not the same as the system’s host name. To retrieve the host name, use the gethostname() — Retrieve Host Name — API like you would on any system that runs TCP/IP.

Also be aware that a system name isn’t required to be unique. Some other identifier might be better in some cases. System serial number is an example.


Below is a RPGLE Program you can use to callp from an RPGLE to retreive the system name.  You can compile this as a *MODULE or *PGM.  In the beginning is the code to insert into an RPGLE program.  If you compile as *MODULE, you will have to bind into your program.

 * Retreive System Name Module for Prototype Call                         
 *  Only use 1 of the PR Statements.                                      
 *  D rtvsysnam       PR                                                  
 *  D rtvsysnam       PR             extpgm(‘RTVSYSNAM’)                  
 *  D  sysnam1                       8A   const                           
 *  D  sysnam1                       8A   const                           
 *  d sysnam          s              8                                    
 *  callp(E) rtvsysnam(sysnam) ;                                          
 *– Api error data structure:  —————————————–**
D ApiError        Ds                                                      
D  AeBytPro                     10i 0 Inz( %Size( ApiError ))             
D  AeBytAvl                     10i 0 Inz                                 
D  AeMsgId                       7a                                       
D                                1a                                       
D  AeMsgDta                    128a                 
 *———Network attributes————-          
d/copy qsysinc/qrpglesrc,qwcrneta                   
d rcv             ds           256                  
d  number                 1      4b 0               
d  off1                   5      8b 0               
d misc            ds                                
d  rcvsiz                 1      4b 0 inz(256)      
d  nbr                    5      8b 0 inz(1)        
d  neta                   9     18    inz(‘SYSNAME’)
d off             s              3  0               
d sysnam          s              8                  
 * Call Retrieve Network Attributes API             
c                   call      ‘QWCRNETA’            
c                   parm                    rcv     
c                   parm                    rcvsiz  
c                   parm                    nbr     
c                   parm                    neta    
c                   parm                    apierror
  if Number = 1;                                    
  off = off1 + 1 ;                                  
  // Header Information for the Network Attribute   
  %subst(qwcrat:1:16) = %subst(rcv:off:16) ;        
  off += 16  ;                                      
  clear sysnam;                                     
  %subst(sysnam:1:qwcld) = %subst(rcv:off:qwcld);   
  endif  ;                                          
  *INLR = *ON  ;                                    
C     *INZSR        BEGSR                           
C     *ENTRY        PLIST                           
C                   PARM                    sysnam     
C                   ENDSR                              

Discuss This Question: 3  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • jinteik
    wrkjob then the system name will be shown like qpadev******
    18,995 pointsBadges:
  • Gayathri123
    Please use the command "DSPNETA". The "current system name" parameter will give the name of the system you are working with.
    925 pointsBadges:
  • ToddN2000
    It shows on the AS/400 sign on screen, and if you type DSPPTF it shows in the upper right. As well as other places.
    132,650 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: