× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I'm using JTOpen to do point-to-point integrations between our iSeries server 
and a PeopleSoft application server running on Microsoft.
 
One thing we want to do is invoke Java classes that read DB2 physical files on 
the iSeries and create fixed with text files on the PeopleSoft server. I'm 
using record-level access to do this, and have succeeded in coding Java classes 
that create CSV files and XML files. But the fixed width format is giving me 
problems. It seems signed or packed fields in DB2 files have their leading 
zeros truncated. This frameshifts the record in the fixed width file.
 
Below is the exact code I'm using. Any ideas on what I'm missing? Is the 
truncation forced by JTOpen? Is the truncation forced by the Object.toString() 
method? Any way to work around this (other than making sure the DB2 file only 
contains character fields)?
 
Thanks in advance for any help.
Kelly
 
/* Establish a connection with the iSeries. */
AS400 system = new AS400(systemName, user, password);
      
String filePath = (new QSYSObjectPathName(db2Library, db2File, 
"FILE")).getPath();
SequentialFile file = new SequentialFile(system, filePath);
system.connectService(AS400.RECORDACCESS);
      
/* Get the record format of the DB2 file. */   
RecordFormat format = (new AS400FileRecordDescription(system, 
filePath)).retrieveRecordFormat()[0];
String fields[] = format.getFieldNames();
file.setRecordFormat(format);
 
/* Generate the fixed width text file from the DB2 file. */   
File theFixFile = new File(fixFile);
PrintWriter txtOut = new PrintWriter(new FileWriter(theFixFile));
file.open(AS400File.READ_ONLY, 0, AS400File.COMMIT_LOCK_LEVEL_NONE);
Record record = file.readNext();
while (record != null){
    for (int i = 0; i < fields.length; i++){
        rawData = record.getField(i);
        fieldData = rawData.toString();
        recordLine = (recordLine + fieldData);
    }//end-for
    txtOut.println(recordLine);
    recordLine = "";
    record = file.readNext();
}//end-while
txtOut.close();
file.close();
    
/* Disconnect from the iSeries. */
system.disconnectService(AS400.RECORDACCESS);
 

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.