views:

555

answers:

2

Is there a way to specifiy the JOB name when creating a spooled file? So that my created s.f. doesn't have the default "QPRTJOB".

My method that creates a spooled file with the default QPRTJOB job:


   public static SpooledFile createSpoolFile( com.ibm.as400.access.AS400 as, PrinterFile pPrinterFile,
         OutputQueue outq, String msg ) {
      SpooledFile result = null;
      try {
         PrintParameterList parms = new PrintParameterList();

         // create a PrintParameterList with the values that we want
         // to override from the default printer file...we will override
         // the output queue and the copies value.
         parms.setParameter( PrintObject.ATTR_PRINTER_FILE, pPrinterFile.getPath() );
         parms.setParameter( PrintObject.ATTR_JOBUSER, AS400.getUser().getUserProfileName() );
         parms.setParameter( PrintObject.ATTR_JOBNAME, "NASAOBRJVA" );
         parms.setParameter( PrintObject.ATTR_OUTPUT_QUEUE, outq.getPath() );
         parms.setParameter( PrintObject.ATTR_CHAR_ID, "*SYSVAL" );

         SpooledFileOutputStream spool = new SpooledFileOutputStream( as, parms, pPrinterFile,
               outq );


         SCS5256Writer scsWtr = new SCS5256Writer( spool, pPrinterFile.getSystem().getCcsid(), pPrinterFile.getSystem() );

         String[] redovi = msg.split( "\n" );
         for ( int i = 0; i < redovi.length; i++ ) {
            if (redovi[i].equals( "" ) || redovi[i].equals( " " )) {
               continue;
            }
            scsWtr.write( redovi[i].trim() );
            if (i < redovi.length - 1) {
               scsWtr.newLine();
            }
         }

         scsWtr.close();
         result = spool.getSpooledFile();
         System.out.println("Spool is in Job: " + result.getJobNumber() + "/" + result.getJobUser() + "/" + result.getJobName());
      }
      catch ( Exception e ) {
         LOG.error( e );
      }
      return result;
   }
+2  A: 

ATTR_JOBUSER and ATTR_JOBNAME are read-only attributes for a spooled file. I've noticed that whenever my Java programs talk to the AS/400--even those that are running natively on the AS/400--they talk to host server jobs and not necessarily the job that submitted the Java call. In this case, you are talking to a print server job on the 400 and all of your spooled files will get a QPRTJOB job name.

An elaborate work-around would be to have your Java program submit a new job named NASAOBRJVA with a command to call some simple RPG program with the message text as a parameter. That's probably a lot of effort for a job name on a spooled file, but you know your project enough to know if it's worth that effort.

Tracy Probst
You suggest that an RPG program creates a spool file?
interstellar
Creating spooled files what RPG was originally designed to do. :) You have to submit the RPG program to a new job with the job name specified. It's an inelegant solution, but it will give you a spooled file with the job name you want.
Tracy Probst
I'll ask my colleague to write a simple RPG and try with a Command Call from Java.
interstellar
Make sure the command call is a SBMJOB command specifying the job name you want.
Tracy Probst
I gave up trying to have the same jobname this way... i find out another way:SBMJOB CMD( RUNJVA CLASS('/myJar.jar') PROP((java.version '1.6')) JOB(NASAJAVA) OUTPUT(*PRINT) ) JOB(NASAJAVA) JOBQ(QBATCH)Which submits two jobs with the same jobname on the QBATCH subsystem.The created spooled file from within Java goes to an agreed OUTPUT QUEUE, so we look it there.
interstellar
A: 

Job, user and job number are assigned by the system and cannot be changed. To the best of my knowledge anyway.

Mike Wills
the code I posted should run on iSeries, so my plan is to start the java program like this:RUNJVA CLASS('/home/username/myJar.jar') PROP((java.version '1.6')) JOB(MYJOBNAME) OUTPUT(*PRINT)So I would like that my spool file gets the jobname of the JOB that started the program. In this case MYJOBNAME
interstellar