星期四, 11月 09, 2023

2012-07-18 如何於 AS400 系統中取得 AS/400 主機的 HOST name 及 Domain name ?(Retrieve TCP/IP Attributes (QtocRtvTCPA) API)


如何於 AS400 系統中取得 AS/400 主機的 HOST name 及 Domain name ?(Retrieve TCP/IP Attributes (QtocRtvTCPA) API)

ile  : QCLSRC

Member: RTVTCPHOST

Type  : CLLE

Usage : CRTBNDCL RTVTCPHOST
        CALL RTVTCPHOST     



pgm
/*http://publib.boulder.ibm.com/infocenter/iseries/v6r1m0/index.jsp? */
/*topic=/apis/qtocrtvtcpa.htm                                        */

   Dcl     &hostname       *CHAR      64
   Dcl     &domainname     *CHAR     255
   Dcl     &RcvVar         *CHAR     512
   Dcl     &ApiErr         *CHAR       8  X'0000000000000000'
   Dcl     &TCPAFormat     *CHAR       8  'TCPA0300'
   Dcl     &RcvVarLen      *CHAR       4
   Dcl     &MsgId          *CHAR       7
   Dcl     &MsgDta         *CHAR     256
   Dcl     &MsgF           *CHAR      10
   Dcl     &MsgFLib        *CHAR      10
   Dcl     &MsgTxt         *CHAR     256

   MonMsg     MsgId(CPF0000 MCH0000) Exec(Goto Error)

   ChgVar %Bin(&RcvVarLen) 512
   CallPrc 'QtocRtvTCPA' ( &RcvVar    +
                           &RcvVarLen +
                           &TCPAFormat    +
                           &ApiErr)

   ChgVar  &hostname      %SST(&RcvVar 177 64)
   ChgVar  &domainname    %SST(&RcvVar 241 255)

   SndPgmMsg  MsgId(CPF9897) MsgF(QCPFMSG)  +
              MsgDta('Hostname:' *BCAT &hostname *Bcat +
                      'Domainname:' *Bcat &domainname)  +
              MsgType(*info  )

   Return
/*  ===============================================================  */
/*  = Error routine                                               =  */
/*  ===============================================================  */

Error:

  RcvMsg     MsgType( *Excp )                                         +
             MsgDta( &MsgDta )                                        +
             MsgID( &MsgID )                                          +
             MsgF( &MsgF )                                            +
             MsgFLib( &MsgFLib )
  MonMsg     ( CPF0000 MCH0000 )

SndMsg:

  SndPgmMsg  MsgID( &MsgID )                                          +
             MsgF( &MsgFLib/&MsgF )                                   +
             MsgDta( &MsgDta )                                        +
             MsgType( *Escape )
  MonMsg     ( CPF0000 MCH0000 )

/*  ===============================================================  */
/*  = End of program                                              =  */
/*  ===============================================================  */
endpgm



沒有留言: