Question

Is there any way to get spooled file data without other details (Page number, End of report line , file details lines)

My Code :

AS400 sys = new AS400();  
SpooledFile sf = new SpooledFile( sys,          // AS400
                                        SPLFNAME,       // splf name
                                        SPLNO,           // splf number
                                        JOBNAME,    // job name
                                        JOBUSER,      // job user
                                        JOBFNUMBER );

PrintParameterList printParms = new PrintParameterList();
printParms.setParameter(PrintObject.ATTR_WORKSTATION_CUST_OBJECT,  "/QSYS.LIB/QWPDEFAULT.WSCST");
printParms.setParameter(PrintObject.ATTR_MFGTYPE, "*WSCST");
PrintObjectTransformedInputStream is = sf.getTransformedInputStream(printParms);

BufferedReader d = new BufferedReader(new InputStreamReader(is));
        String data = "";
while((data = d.readLine()) != null)
{
    System.out.println (data);
    jTextArea1.append(data + "\n");

}

Output Spooled file :

PROGRAM ID:  XXXXXXX                            COMPANY NAME 1                                     REPORT DATE:  9/27/13 PAGE:    1  
USER      :  XXXXXXX                          Loan file list                                    REPORT TIME: 12:59:53

ID      NAME  
--------------------------------------------------------------------  
01      AAAAAAA  
02      BBBBBBB  
03      CCCC 
04      DDDDDDD 

PROGRAM ID:  XXXXXXX                            COMPANY NAME 1                                        REPORT DATE:  9/27/13 PAGE:    2  
USER      :  XXXXXXX                          Loan file list                                      REPORT TIME: 12:59:53

ID      NAME  
--------------------------------------------------------------------  
05      EEEEEEE  
06      FFFFFF  
07      GGGGGG  
08      HHHHHHH  

**************************       End of Report       ***************************

I want to get output like this :

ID      NAME  
--------------------------------------------------------------------  
01      AAAAAAA  
02      BBBBBBB  
03      CCCC 
04      DDDDDDD 

ID      NAME  
--------------------------------------------------------------------  
05      EEEEEEE  
06      FFFFFF  
07      GGGGGG  
08      HHHHHHH

Or :

01      AAAAAAA  
02      BBBBBBB  
03      CCCC 
04      DDDDDDD 

05      EEEEEEE  
06      FFFFFF  
07      GGGGGG  
08      HHHHHHH

Anyone know how to do this? using updating my JT400 Java code or Formatting this spooled text file

Was it helpful?

Solution

No. There is no built-in mechanism for identifying the detail lines. As far as the spooled file is concerned, they're all detail lines. You'll have to scan each line to see if it matches the layout of the lines you want to capture. For instance, a non-blank in position 1, blanks in positions 3-8, then nonblanks in positions 9-12. You'd need another scan to accept the dashed line.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top