I am trying to read a EBCDIC file and convert it to ASCII format in Java, with a help of copybook. I am using JRecord to read the copybook. So now, how do I get the field level from the copybook using JRecord?
In attached copybook, the field in line 1 can have values from line 2 to line 4. If the EXTRA-TYPE is 01, then I have to read fields in line 6 to line 11. Similarly, if the EXTRA-TYPE is 02, then I have to read fields in line 12 to line 16. I am trying to split the Transaction type and its respective fields dynamically.(I need to get the start and end position of the fields with respect to the transaction type in line 1)How do I achieve this in Java?
A COBOL copybook is a selection of code that defines data structures. If a particular data structure is used in many programs, then instead of writing the same data structure again, we can use copybooks. We use the COPY statement to include a copybook in a program. COPY statement is used in the WorkingStorage Section.
Note: If you specify EXEC SQL statements using the COPY verb, the SQLOption preprocessor will compile the program and will generate an error messagefor any host variable referenced from the copybook without the COPY directivebeing set. If you port the same program to the mainframe, the SQL code may notprecompile unless your installation has a product that expands copybooks beforepassing them to the DB2 mainframe preprocessor.
Thanks,
RE: COBOL Copybook Explaination chimota (TechnicalUser)(OP)4 Jan 01 14:56Thank you Greenguy71 for the example. What I still don't understand is 1) Does the spacing matter? 2) How do I know if it is a pic or a value or to put something like COMP-3 after the size? Again the example helps. Thanks
jtr RE: COBOL Copybook Explaination RASI (Programmer)5 Jan 01 09:24Chimota,
I have a few question for you.
1. Does your sample data dictionary represent a cobol data file? ie.. Do you have a cobol file and also the layout of it as Greenguy71 posted.
2. Do you know the cobol file type. Sequential, Index etc.
Data Junction can read many different types of files as you know, but first you have to define to data junction what the file type is and its structure.
Can you post any information about your sample data dictionary? What COBOL vendor produced this file?
The comp-3 etc that you mention determines how the internal value is read etc... So it matters greatly..
RE: COBOL Copybook Explaination RonaldB (Programmer)6 Jan 01 17:48Chimota,
sounds like you are in dire need of a quick introduction into the COBOL language.
As i estimate, no short answer will do in response to your question; i'm going to give it a try, anyway.
Some points of interest may be these:
Every COBOL program source defines a section that is known as Working Storage. This is a map of a section of memory the program in question uses to store input from files, intermediate results, output to be written to files, etc.
The Working-Storage Section of any COBOL program defines a map for that program. Parts of that map can be hard coded in every program; however, is several programs manipulate e.g. the same file, it makes sense to define the layout for that file into a copybook. Each program can incorporate the exact same layout (= the copybook) in it's working storage by use of the COPY statement.
A Working-Storage definition follows strict rules; so will any copybook. Some of them are (using the example GreenGuy71 gave you):
The words are identifiers to give the program a reference to access a certain portion of memory, i.e. PKLR1-CONTRACT-NUMBER (12th line) defines a 10 byte section of alphameric data. The numbers at the beginning of each line are level numbers; the top level is identified by '01', every number beneath that defines a part of the '01'-level.
For instance, PKLR1-DETAIL-LOAN-RECORD' references the whole definition, since it is at 01-level; PKLR1-BASIC-SECTION is the only defintion at 10-level, and therefore superfluous; every 20-level listed in the example divides the 10-level (and therfore the 01-level) up into several bits that may be manipulated indivdually.
The 'PIC'-clause (PICture) defines the way the referenced bytes should be looked at. I.e. PIC X(10) means 10 bytes of alphameric content, PIC 9(02) means 2 bytes of numeric content, with each byte containing 1 digit, PIC S9(02) means the same, burt with a sign (= positive or negative). The adjective 'COMP-3' means that the numeric content should be stored in a specific format, where each nibble (=4 bits) holds 1 digit. This saves space in the memory occupied.
About spacing: every line in a COBOL program is devided up into 2 sections; area 'A', in the case of your copybook, runs froms position 7 up to 11; position 7 is reserved for comment characters, and the '01' level indicator should be in the positions from 8 to 11 (usually starting at 8). Every other bit should be in the 'B'-section, from position 12 up to the end of the line (usually 72). In section 'B'. spacing is mostly relevant for legibility, as long as each part of a line (that is, level nember, identifier name, 'PIC'-clause, picture, etc.) is at least seperated be a single space.
About value: the 'VALUE'-clause presets the defined memory area to a certain value. Normally, this is determined by the program while executing; however, it can be used to set the value for certain identifiers at the start of execution, either as an initial value, or as a value for a constant.
I hope this lengthy response gets you on the way and NOT confuses you even more !
Good luck ! RE: COBOL Copybook Explaination Doylet (Programmer)1 Feb 01 10:24There is a detailed tutorial at...
Best Wishes,
==================
learning & sharing
googletag.cmd.push(function() googletag.display('div-gpt-ad-1406030581151-2'); ); Red Flag This PostPlease let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.
CancelRed Flag SubmittedThank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.
The program is well documented (IMHO) and you should find it fairly easy to follow. The GCic.cbl program was written to work with a native Windows or Windows/MinGW build of GnuCOBOL as well as a Windows/Cygwin, UNIX or OS X build.
Source listings generated by GCic will show the original source code of your programs, with all indentation and comments preserved. Additionally, any COPYed code will be included in the listing immediately (in compressed form) following the COPY statement that triggered its inclusion into your program.
We have designed this License in order to use it for manuals for freesoftware, because free software needs free documentation: a freeprogram should come with manuals providing the same freedoms that thesoftware does. But this License is not limited to software manuals;it can be used for any textual work, regardless of subject matter orwhether it is published as a printed book. We recommend this Licenseprincipally for works whose purpose is instruction or reference.
This works fine when a copybook is referenced as copy copybook. ,the relevant paths are added to the copybook paths and the file has an extension that has been configured but does not work with the syntax shown above.
Thanks, this already helps.
It doesn't work entirely as expected though.
Example code:
copy "path/to/select/file1"
copy "path/to/fd/file1"
copy "path/to/status/file1"
Each of these files contains respectively the file-control, the fd and the status entries needed for ISAM file "file1".
With the mapping of extensionless file set to Micro Focus Cobol other copybooks (with a unique name) show the expected content but the sample above shows the content of the "select" file for each of the 3 copy statements listed.
So it seems that the path specified in the copy statement is now being ignored.
Now I need to do the same thing with a PUT request, where the COBOL program will read the data via an EXEC CICS GET CONTAINER, i.e., read a whole block of data in one go and where the data read corresponds to a COBOL copybook. For example, the first 10 bytes might represent a date, the next 25 a customer name etc.
My question is, how do I define these fields in Postman (remembering that there might be 40, 50 or many more of them).
I found the following link
After the CONNX TCP/IP listener program is started as a batch job, the next step is to use the CONNX Data Dictionary Manager program to import metadata from COBOL copybooks into a CONNX Data Dictionary file. The following steps show how to import metadata for the CONNX sample VSAM customer KSDS (Key Sequenced Data Set) file:
e2b47a7662