One Star ase
One Star

copybook ebcdic with files ascii cobol

Hi,
I must insert in oracle differents elements from files cobol.
The problem is that files are ascii with a big copy book !
I had imported the copy book into the copybook ebcdic in metada but the files cobol are ascii.
Thank you for your help.
ASE
1 REPLY
Employee

Re: copybook ebcdic with files ascii cobol

Hello,
If i really understand your need, you have your ebcdic file is in ascii format and you want to read this file.
If you know the line delimiteur in the file, use the tFileInputFilePositonal and extract fields as byte[]
If you don't know the line delimiter, to translate the ascii into ebcdic, you can use the tJavaFlex like this :
Begin part of tJavaFlex :
===============
String fileNewName_tFileInputPositional_1= context.path_dir+"ebcdic2ascii.txt";
java.io.File createFiletFileInputPositional_1 = new java.io.File(fileNewName_tFileInputPositional_1);

java.io.InputStream is = new java.io.FileInputStream(createFiletFileInputPositional_1);

// Get the size of the file
long length = createFiletFileInputPositional_1.length();

// You cannot create an array using a long type.
// It needs to be an int type.
// Before converting to an int type, check
// to ensure that file is not larger than Integer.MAX_VALUE.
if (length > Integer.MAX_VALUE) {
// File is too large
}

// Create the byte array to hold the data
//byte[] bytes = new byte;
byte[] filler_1 = new byte;
byte[] password = new byte;
byte[] filler_2 = new byte;
byte[] retour_chariot=new byte;
// Read in the bytes
int offset = 0;
int numRead_1 = 0;
int numRead_2 = 0;
int numRead_3 = 0;
int numRead_n = 0;

/*while (offset < bytes.length
&& (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {*/

while (offset < length
&& (numRead_1=is.read(filler_1))>= 0&& (numRead_2=is.read(password))>= 0&& (numRead_3=is.read(filler_2)) >= 0 && (numRead_n=is.read(retour_chariot)) >= 0){

main part of tJavaFlex :
==============
//If you have for example the fields filler,password_e,filler_2
offset += numRead_1+numRead_2+numRead_3+numRead_n;
ascii2ebcdic.filler=new String(filler_1);
ascii2ebcdic.password_e=password;
ascii2ebcdic.filler_2=new String(filler_2);

end part of tJavaFlex :
==============
}

// Ensure all the bytes have been read in
if (offset < length) {
throw new IOException("Could not completely read file "+createFiletFileInputPositional_1.getName());
}

// Close the input stream and return bytes
is.close();

Link the tJavaFlex out put to your output component.
Perhaps is not you are wanted. If so, please try to describe more your need with sample file and screenshots for examples etc
Regards,