RATE THIS ANSWER
0
Click to Vote:
0
0
I got this src from a website a long time ago. Have used it a couple of times - Thanks to the author who I forget
/* =============================================================== */
/* = Program....... RtvIPAddrC = */
/* = Description... Retrieve IP address of current device = */
/* = --------------------------------------------------------- = */
/* = CrtCLPgm Pgm( YourLib/RtvIPAddrC ) + = */
/* = SrcFile( YourLib/YourSrcF ) = */
/* =============================================================== */
Pgm ( &IPAddr )
/* --------------------------------------------------------------- */
/* - Variable declarations - */
/* --------------------------------------------------------------- */
Dcl &RcvVar *Char ( 892 )
Dcl &RcvVarLen *Char ( 4 ) ( X'0000037C' )
Dcl &Format *Char ( 8 ) ( 'DEVD0600' )
Dcl &DevD *Char ( 10 )
Dcl &APIError *Char ( 8 ) ( X'0000000000000000' )
Dcl &IPAddr *Char ( 15 )
Dcl &MsgID *Char ( 7 )
Dcl &MsgDta *Char ( 256 )
Dcl &MsgF *Char ( 10 )
Dcl &MsgFLib *Char ( 10 )
/* --------------------------------------------------------------- */
/* - Global error trap - */
/* --------------------------------------------------------------- */
MonMsg ( CPF0000 MCH0000 ) Exec( GoTo Error )
/* --------------------------------------------------------------- */
/* - Retrieve current device name and its dotted IP address - */
/* --------------------------------------------------------------- */
RtvJobA Job( &DevD )
Call QDCRDEVD +
( &RcvVar +
&RcvVarLen +
&Format +
&DevD +
&APIError )
ChgVar &IPAddr ( %Sst( &RcvVar 878 15 ) )
Return
/* --------------------------------------------------------------- */
/* - Error handler (percolate error message to caller) - */
/* --------------------------------------------------------------- */
Error:
RcvMsg MsgType( *Excp ) +
Rmv(*No ) +
MsgDta( &MsgDta ) +
MsgID( &MsgID ) +
MsgF( &MsgF ) +
MsgFLib( &MsgFLib )
MonMsg ( CPF0000 MCH0000 )
SndPgmMsg MsgID( &MsgID ) +
MsgF( &MsgFLib/&MsgF ) +
MsgDta( &MsgDta ) +
MsgType( *Escape )
MonMsg ( CPF0000 MCH0000 )
EndPgm
Satsho
===========================================================
Also, if you need the host name you can use the following:
PGM
DCL VAR(&NAME) TYPE(*CHAR) LEN(65)
DCL VAR(&SIZE) TYPE(*INT) LEN(4) VALUE(64)
CALLPRC PRC('gethostname') PARM((&NAME) (&SIZE *BYVAL))
SNDPGMMSG MSG('Host name = ' || &NAME)
ENDPGM
Kevin "BigKat" Ketzler -----------------
I believe the program was contributed by Gary Guthrie. Thanks Gary,
---------------------------------------
The preceding program returns the IP address of the display device associated with the current job.
The original question however was how to return/get the IP address of the AS/400 machine and not of the device (though perhaps the question was worded incorrectly). As the system can have multiple IP addresses more information is needed about the environment the CL program is running in. For instance, does the program have a current socket connection? And what in the world does the Java program need a/the external system IP address of the system for anyway?
Bruce Vining
Bruce Vining Services
Last Answered:
Sep 2 2009 2:49 PM GMT by Bvining 
4885 pts.