132 lines
4.9 KiB
HTML
132 lines
4.9 KiB
HTML
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
<!DOCTYPE html
|
||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html lang="en-us" xml:lang="en-us">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<meta name="security" content="public" />
|
||
|
<meta name="Robots" content="index,follow" />
|
||
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
||
|
<meta name="DC.Type" content="reference" />
|
||
|
<meta name="DC.Title" content="Example: Using JobLog to display messages in the job log" />
|
||
|
<meta name="abstract" content="" />
|
||
|
<meta name="description" content="" />
|
||
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
|
||
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
|
||
|
<meta name="DC.Format" content="XHTML" />
|
||
|
<meta name="DC.Identifier" content="joblogexample" />
|
||
|
<meta name="DC.Language" content="en-us" />
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
||
|
<title>Example: Using JobLog to display messages in the job log</title>
|
||
|
</head>
|
||
|
<body id="joblogexample"><a name="joblogexample"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Example: Using JobLog to display messages in the job log</h1>
|
||
|
<div><p></p>
|
||
|
<div class="section"><div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm#codedisclaimer">Code
|
||
|
example disclaimer</a> for important legal information.</div>
|
||
|
<pre>///////////////////////////////////////////////////////////////////////////
|
||
|
//
|
||
|
// This program is an example of the job log fuction of the
|
||
|
// IBM Toolbox for Java. It will display the messages in the job
|
||
|
// log for a job that belongs to the current user.
|
||
|
//
|
||
|
// Command syntax:
|
||
|
// jobLogExample system userID password
|
||
|
//
|
||
|
// (Password is optional)
|
||
|
//
|
||
|
/////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
import java.lang.*;
|
||
|
import java.util.*;
|
||
|
import com.ibm.as400.access.*;
|
||
|
|
||
|
public class jobLogExample
|
||
|
{
|
||
|
|
||
|
|
||
|
public static void main (String[] args)
|
||
|
{
|
||
|
// If a system and user were not specified, display help text and exit.
|
||
|
if (args.length < 2)
|
||
|
{
|
||
|
System.out.println("Usage: jobLogExample system userid <password>");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
String userID = null;
|
||
|
|
||
|
try
|
||
|
{
|
||
|
// Create an AS400 object. The system name was passed
|
||
|
// as the first command line argument. If a userid
|
||
|
// and password were passed on the command line,
|
||
|
// set those as well.
|
||
|
AS400 system = new AS400 (args[0]);
|
||
|
|
||
|
if (args.length > 1)
|
||
|
{
|
||
|
userID = args[1];
|
||
|
system.setUserId(userID);
|
||
|
}
|
||
|
|
||
|
if (args.length > 2)
|
||
|
system.setPassword(args[2]);
|
||
|
|
||
|
|
||
|
// Create a job list object. This object will be used to get
|
||
|
// the list of active jobs on the system. Once the list of
|
||
|
// jobs is retrieved, the program will find a job for the
|
||
|
// current user.
|
||
|
JobList jobList = new JobList(system);
|
||
|
|
||
|
// Get the list of active jobs on the AS/400
|
||
|
Enumeration list = jobList.getJobs();
|
||
|
|
||
|
boolean Continue = true;
|
||
|
|
||
|
// Look through the list to find a job for the current user.
|
||
|
while (list.hasMoreElements() && Continue)
|
||
|
{
|
||
|
Job j = (Job) list.nextElement();
|
||
|
|
||
|
if (j.getUser().trim().equalsIgnoreCase(userID))
|
||
|
{
|
||
|
// A job matching the current user was found. Create
|
||
|
// a job log object for this job.
|
||
|
JobLog jlog = new JobLog(system, j.getName(), j.getUser(), j.getNumber());
|
||
|
|
||
|
// Enumerate the messages in the job log then print them.
|
||
|
Enumeration messageList = jlog.getMessages();
|
||
|
|
||
|
while (messageList.hasMoreElements())
|
||
|
{
|
||
|
AS400Message message = (AS400Message) messageList.nextElement();
|
||
|
System.out.println(message.getText());
|
||
|
}
|
||
|
|
||
|
// We found one job matching the current user so exit.
|
||
|
Continue = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
System.out.println ("Error: " + e.getMessage ());
|
||
|
}
|
||
|
|
||
|
System.exit(0);
|
||
|
}
|
||
|
|
||
|
}</pre>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
</body>
|
||
|
</html>
|