4

01) I was trying to get IBM/AS400 Serial no using command call method. code is working coz it's nothing given any error or exception. i thing there is something missing. help me to correct it.

02) is there is any way to get AS/400 serial no using jt400 (java). i found getSerialNum() method. but com.ibm.cics.server.CertificateInfo import is give exception. also help me to correct it (if anyone can tell me how to get serial no using getSerialNum() method it's really helpful for me)

Thank in advance!

My command call code :

AS400 system = new AS400();
CommandCall command = new CommandCall(system);
try
{
    // Run the command "DSPSYSVAL" and parameter value for "SYSVAL" is "QSRLNBR"
    if (command.run("DSPSYSVAL QSRLNBR") != true)
    {
        // Note that there was an error.
        System.out.println("Command failed!");
    }else{

           // Show the messages (returned whether or not there was an error.)
    AS400Message[] messagelist = command.getMessageList();
    for (int i = 0; i < messagelist.length; ++i)
    {
        // Show each message.
        System.out.println(messagelist[i].getText());
    }

    }

}
catch (Exception e)
{
    System.out.println("Command " + command.getCommand() + " issued an exception!");
    e.printStackTrace();
}
// Done with the system.
System.out.println("End!");
system.disconnectService(AS400.COMMAND);
sheanD
  • 191
  • 5
  • 19
  • 1
    It is extremely unlikely that CICS is being run on your IBM i system. – WarrenT Oct 25 '13 at 05:10
  • 1
    To clarify why this does not work: IBM i commands don't output their results to stdout. If the command is OUTPUT(*), the output is directed to a 5250 terminal. If the output is OUTPUT(*PRINT) the output is directed to a printer (spooled file). So the *nix technique of run a command, read the results won't work. The IBM i way to consume a command's output is to use an API and get the results in a memory structure. – Buck Calabro Oct 26 '13 at 14:19
  • Is this for license enforcement? – Thorbjørn Ravn Andersen Mar 01 '14 at 00:50
  • @BuckCalabro Could one execute the command with OTUPUT(*PRINT) and the read the spooled file? – Delfic Nov 16 '15 at 13:10
  • Yes, one can certainly do that. Be aware that printed output can change from release to release, and even across PTF levels. Finding the serial number on line 7, columns 18 - 24 on 7.2 is no guarantee that it will be in the same place in earlier (or later) versions. – Buck Calabro Nov 16 '15 at 15:00

1 Answers1

6

Have a look at the SystemValue class.

Buck Calabro
  • 7,558
  • 22
  • 25