<?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: Creating SCS spooled files" /> <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="npexamplecreatescssplf" /> <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: Creating SCS spooled files</title> </head> <body id="npexamplecreatescssplf"><a name="npexamplecreatescssplf"><!-- --></a> <!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script> <h1 class="topictitle1">Example: Creating SCS spooled files</h1> <div><p></p> <div class="section"><p>This example uses the SCS3812Writer class to generate an SCS data stream and write it to a spooled file on the server.</p> </div> <div class="section"><p>This application can take the following arguments, or it can use the defined defaults:</p> </div> <div class="section"><ul><li>Name of the server to receive the spooled file.</li> <li>Name of the outqueue on the server to receive the spooled file. </li> </ul> <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 source is an example of IBM Toolbox for Java "SCS3812Writer". // ///////////////////////////////////////////////////////////////////////// import com.ibm.as400.access.*; class NPExampleCreateSCSSplf { private static final String DEFAULT_SYSTEM = new String("RCHAS1"); private static final String DEFAULT_OUTQ = new String("/QSYS.LIB/QUSRSYS.LIB/PRT01.OUTQ"); public static void main(String [] args) { try { AS400 system; SpooledFileOutputStream out; PrintParameterList parms = new PrintParameterList(); SCS3812Writer scsWtr; // Process the arguments. if (args.length >= 1) { system = new AS400(args[0]); // Create an AS400 object } else { system = new AS400(DEFAULT_SYSTEM); } if (args.length >= 2) // Set the outq { parms.setParameter(PrintObject.ATTR_OUTPUT_QUEUE, args[1]); } else { parms.setParameter(PrintObject.ATTR_OUTPUT_QUEUE, DEFAULT_OUTQ); } out = new SpooledFileOutputStream(system, parms, null, null); scsWtr = new SCS3812Writer(out, 37); // Write the contents of the spool file. scsWtr.setLeftMargin(1.0); scsWtr.absoluteVerticalPosition(6); scsWtr.setFont(scsWtr.FONT_COURIER_BOLD_5); scsWtr.write(" Java Printing"); scsWtr.newLine(); scsWtr.newLine(); scsWtr.setCPI(10); scsWtr.write("This document was created using the IBM Toolbox for Java."); scsWtr.newLine(); scsWtr.write("The rest of this document shows some of the things that"); scsWtr.newLine(); scsWtr.write("can be done with the SCS3812Writer class."); scsWtr.newLine(); scsWtr.newLine(); scsWtr.setUnderline(true); scsWtr.write("Setting fonts:"); scsWtr.setUnderline(false); scsWtr.newLine(); scsWtr.setFont(scsWtr.FONT_COURIER_10); scsWtr.write("Courier font "); scsWtr.setFont(scsWtr.FONT_COURIER_BOLD_10); scsWtr.write(" Courier bold font "); scsWtr.setFont(scsWtr.FONT_COURIER_ITALIC_10); scsWtr.write(" Courier italic font "); scsWtr.newLine(); scsWtr.setBold(true); scsWtr.write("Courier bold italic font "); scsWtr.setBold(false); scsWtr.setCPI(10); scsWtr.newLine(); scsWtr.newLine(); scsWtr.setUnderline(true); scsWtr.write("Lines per inch:"); scsWtr.setUnderline(false); scsWtr.newLine(); scsWtr.write("The following lines should print at 8 lines per inch."); scsWtr.newLine(); scsWtr.newLine(); scsWtr.setLPI(8); scsWtr.write("Line one"); scsWtr.newLine(); scsWtr.write("Line two"); scsWtr.newLine(); scsWtr.write("Line three"); scsWtr.newLine(); scsWtr.write("Line four"); scsWtr.newLine(); scsWtr.write("Line five"); scsWtr.newLine(); scsWtr.write("Line six"); scsWtr.newLine(); scsWtr.write("Line seven"); scsWtr.newLine(); scsWtr.write("Line eight"); scsWtr.newLine(); scsWtr.endPage(); scsWtr.setLPI(6); scsWtr.setSourceDrawer(1); scsWtr.setTextOrientation(0); scsWtr.absoluteVerticalPosition(6); scsWtr.write("This page should print in portrait orientation from drawer 1."); scsWtr.endPage(); scsWtr.setSourceDrawer(2); scsWtr.setTextOrientation(90); scsWtr.absoluteVerticalPosition(6); scsWtr.write("This page should print in landscape orientation from drawer 2."); scsWtr.endPage(); scsWtr.close(); System.out.println("Sample spool file created."); System.exit(0); } catch (Exception e) { // Handle error. System.out.println("Exception occured while creating spooled file. " + e); System.exit(0); } } }</pre> </div> </div> </body> </html>