(First and foremost, i like to thank Bruce Martin for his dedication, work and support. I think he helped a lot of people.)
Im trying to build a custom .bin file using the JRecord libary.
The file im trying to write has 3 kinds of lines (AbstractLines) each with a different layoutDetail.
I can get one layoutDetail from a copybook (in .CPY format) but the other two layouts i have to custom build.
So far i got code for the copybook layoutDetail, what seems to work as intended.
This is how im creating a new AbstractLine and feed it with the respective layoutDetail:
AbstractLine line =
LineIOProvider.getInstance().getLineProvider(layoutDetail).getLine(layoutDetail);
The problem i run into is, that i cant seem to write these lines into the same file, without one layout, overwriting the other.
For example the first line has a length of for example 1000, and this length gets applied to the other lines im trying to write, even when theyre shorter or longer.
-Am i on the right approach or am i doing it the wrong way?
-How do I achieve, that a line is dynamically sometimes shorter, sometimes longer, depending if a field is filled or not, is this possible?
Also on another note:
-How do i read a copybook in XML format, like this:
Final Application to run on the mainframe (very unlikely)
Assuming you are sending to the mainframe, The two easiest options are
Write in EBCDIC FB as you are doing -easy safest transfer, will handle binary files
Write in ASCII/UTF-8 and use IFileStructureConstants.IO_STANDARD_TEXT_FILE
and do the UTF-8 ===> EBCDIC translation when transfering the file.
This only works for text files, binary files get corrupted. There can be Translation issues.
For small files I would just use the larger record-length and IO_FIXED_LENGTH
as you are doing an accept the wasted space.
Fixed Length IO_FIXED_LENGTH
The File-Structure of IO_FIXED_LENGTH means every record is the same length
with no End-of-line makings (i.e. no \n or \r characters). i.e.
This is normal in Cobol with a single copybook used in the file.
Windows/Linux Style IO_STANDARD_TEXT_FILE
If you use IFileStructureConstants.IO_STANDARD_TEXT_FILE with IBM01141, you get
a standard windows/linux style file but it probably will not be understood
on the mainframe.
VB Files (IO_VB)
You could use IFileStructureConstants.IO_VB, you might have problems
transfering to the mainframe (my experience is from a long time ago, so things
might of changed). For FTP use the RDW option
I did as you mentioned and just accepted the wasted space. I just filled the shorter lines with spaces, so they are the same length as the longest line.
JRecordInterface1.CB2XML worked with the xml copybooks aswell. Thanks again.
You are correct, i want to send a the files i create to a mainframe, kind of. I need the files to be the exact same as the ones the mainframe can work with. But I didn't actually do this yet.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There should not be any problem working with a FB file on the mainframe. If the program is expecting a VB file, you can use Sort or IEBCOPY etc utilites to do the conversion from FB to VB
Hello,
(First and foremost, i like to thank Bruce Martin for his dedication, work and support. I think he helped a lot of people.)
Im trying to build a custom .bin file using the JRecord libary.
The file im trying to write has 3 kinds of lines (AbstractLines) each with a different layoutDetail.
I can get one layoutDetail from a copybook (in .CPY format) but the other two layouts i have to custom build.
So far i got code for the copybook layoutDetail, what seems to work as intended.
This is my attempt to build a custom layoutDetail:
This is the writer im using:
This is how im creating a new AbstractLine and feed it with the respective layoutDetail:
The problem i run into is, that i cant seem to write these lines into the same file, without one layout, overwriting the other.
For example the first line has a length of for example 1000, and this length gets applied to the other lines im trying to write, even when theyre shorter or longer.
-Am i on the right approach or am i doing it the wrong way?
-How do I achieve, that a line is dynamically sometimes shorter, sometimes longer, depending if a field is filled or not, is this possible?
Also on another note:
-How do i read a copybook in XML format, like this:
Thanks in advance for any answers.
Last edit: Martin Scheibe 2025-05-13
You are using IBM01141 - EBCDIC encoding
so I presume you are either
Assuming you are sending to the mainframe, The two easiest options are
and do the UTF-8 ===> EBCDIC translation when transfering the file.
This only works for text files, binary files get corrupted. There can be Translation issues.
For small files I would just use the larger record-length and IO_FIXED_LENGTH
as you are doing an accept the wasted space.
Fixed Length IO_FIXED_LENGTH
The File-Structure of IO_FIXED_LENGTH means every record is the same length
with no End-of-line makings (i.e. no \n or \r characters). i.e.
This is normal in Cobol with a single copybook used in the file.
Windows/Linux Style IO_STANDARD_TEXT_FILE
If you use IFileStructureConstants.IO_STANDARD_TEXT_FILE with IBM01141, you get
a standard windows/linux style file but it probably will not be understood
on the mainframe.
VB Files (IO_VB)
You could use IFileStructureConstants.IO_VB, you might have problems
transfering to the mainframe (my experience is from a long time ago, so things
might of changed). For FTP use the RDW option
Format of VB File
Where RDW is the record-descriptor word (4 bytes, it includes a 2 byte legth).
## Xml copybook
It looks like the xml produced by cb2xml. To process it
It basically works like JRecordInterface1.COBOL
Last edit: Bruce Martin 2024-05-15
Hello Bruce,
Thanks a lot for your reply.
I did as you mentioned and just accepted the wasted space. I just filled the shorter lines with spaces, so they are the same length as the longest line.
JRecordInterface1.CB2XML worked with the xml copybooks aswell. Thanks again.
You are correct, i want to send a the files i create to a mainframe, kind of. I need the files to be the exact same as the ones the mainframe can work with. But I didn't actually do this yet.
There should not be any problem working with a FB file on the mainframe. If the program is expecting a VB file, you can use Sort or IEBCOPY etc utilites to do the conversion from FB to VB
This should work.
If the file is Only text, you could write as a normal ascii text file and let FTP do the conversion (and write a VB file
I did do a some google searches and could not find any way to send a VB file to the mainframe; you could ask some experienced mainframe people
Finally running Java/JRecord on the mainframe would allow the creation of VB files using java-zos services
Last edit: Bruce Martin 2024-05-22