Retreiving host name

65 pts.
Tags:
AS/400
Currently we have 2 iSeries systems on our network. We run the same CL's on both boxes, we need to determine which iSeries is currently running the CL procedure. How can I retrieve the host name in a CL program?
ASKED: July 19, 2006  11:56 AM
UPDATED: November 27, 2010  5:16 AM

Answer Wiki

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

You can retrieve the system name in a CL by executing the RTVNETA command, There is a parameter on this command named SYSNAME. You would define an 8 character variable and do the RTVNETA to get the system name into the variable.

If you are using SDA to define display files used in RPG programs, you can enter *SYSNAME on a screen format and press Enter. This will add a system name field to the screen. The operating system handles loading this value when the screen is displayed.

Discuss This Question: 4  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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Vatchy
    Alternatively, you could retrieve the system value QSRLNBR to get the system's serial number. On two systems, the system names could possibly be the same but the serial numbers should be unique.
    1,410 pointsBadges:
    report
  • Ayahel1
    If you need the TCP/IP host name you can try to use the C function gethostname(name, size). The problem calling this from a CL program is that CL can not pass an "int" parameter until V5R3. With V5R3 and above, you can. Try this: PGM DCL VAR(&NAME) TYPE(*CHAR) LEN(33) DCL VAR(&SIZE) TYPE(*INT) LEN(4) VALUE(32) CALLPRC PRC('gethostname') PARM((&NAME) (&SIZE *BYVAL)) SNDPGMMSG MSG('Host name = ' || &NAME) ENDPGM
    0 pointsBadges:
    report
  • Ayahel1
    If you need the TCP/IP host name you can try to use the C function gethostname(name, size). The problem calling this from a CL program is that CL can not pass an "int" parameter until V5R3. With V5R3 and above, you can. Try this: PGM DCL VAR(&NAME) TYPE(*CHAR) LEN(33) DCL VAR(&SIZE) TYPE(*INT) LEN(4) VALUE(32) CALLPRC PRC('gethostname') PARM((&NAME) (&SIZE *BYVAL)) SNDPGMMSG MSG('Host name = ' || &NAME) ENDPGM
    0 pointsBadges:
    report
  • TomLiotta
    The problem calling this from a CL program is that CL can not pass an “int” parameter until V5R3. CL has been able to pass "int" parameters almost from the beginning. It just couldn't pass "*INT" parameters. There's a difference. To study the difference, use this to define the &SIZE variable:
     DCL        VAR(&SIZE) TYPE(*CHAR) LEN(4) VALUE(X'00000020')
    A 4-byte *CHAR variable can be assigned hexadecimal values. A 4-byte *INT variable holds x'00000020' when the integer value is (32), so that's the hex value to assign. To handle numeric value changes in *CHAR variables, use the %BIN() built-in function. Tom
    125,585 pointsBadges:
    report

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following