Question

1st i want to say thank you for viewing this Question :)

I'm a beginner to AS400/JAVA development. I want to know how to get spool file list to java and how to convert it to PDF from OUTQ, Using JT400.

Can anyone to tell me or give me sample java code ?

Thanks in advance!

Was it helpful?

Solution

Split it in two.

One is reading the characters in the spool file. I did this a few years back. I believe there is a SPoolFile class where you then need to search for the actual spool file given the job name/user name/job number triplet and then choose the one of potentially many generated by that job. Then you need to transform it (I had to use cp850 on our host as the code page) but the rest eludes me.

The second is to generate a PDF file containing the characters read. This is a pure Java thing - I believe it was iText I used and it was pretty straight forward.

OTHER TIPS

            SpooledFile spooledFile = new SpooledFile(as400, splfName.trim(), Integer.parseInt(spoolFileNumber), jobName.trim(), jobUser.trim(), jobNumber.trim());
            PrintParameterList printParms = new PrintParameterList();
            printParms.setParameter(PrintObject.ATTR_WORKSTATION_CUST_OBJECT, "/QSYS.LIB/QWPDEFAULT.WSCST");
            printParms.setParameter(PrintObject.ATTR_MFGTYPE, "*WSCST");
            try {
                InputStreamReader in = new InputStreamReader(spooledFile.getTransformedInputStream(printParms), "cp850");
                char[] buf = new char[32767];
                outputData = new StringBuilder();
                if (in.ready()) {
                    int bytesRead = 0;
                    bytesRead = in.read(buf, 0, buf.length);
                    while (bytesRead > 0) {
                        outputData.append(buf, 0, bytesRead);
                        bytesRead = in.read(buf, 0, buf.length);
                    }
                }
            //    System.out.println(sbuf.toString());

            } catch (Exception e) {
                e.printStackTrace();
            }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top