View previous topic :: View next topic
|
Author |
Message |
vinodh k r
New User
Joined: 03 Jul 2014 Posts: 5 Location: india
|
|
|
|
Hi,
We need to migrate files to WINDOWS, for this purpose, the packed decimal fields needs to be Unpacked.
I am looking to code a generic COBOL program which can be used to unpack COMP/COMP-3 fields to corresponding length Non-Comp field. I will be having 2 input files. First file will be the one to be unpacked. Second file will contain info about the layout of the file in below format
Code: |
START POS(1-4) END-POS(5-8) DATATYPE(9-10)
1 3 PD |
Above is example for S9(5) COMP-3, occupying 3 bytes which needs to be moved to PIC S9(5) occupying 6 bytes in DISPLAY format.
I can make the input file as VARYING with maximum length possible and also, the output file as VARYING in order to accomodate the increased LRECL.
Is this workable? If so, Can you please give me an idea on how to code this?
I hope i made it clear, if not please let me know.
Thanks in advance!
Code'd and de-mangled |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You'll need to know if the field is signed, or not (unless all are unsigned, or all are signed).
Given the information you are supplying, I'd do it in SORT, rather than a COBOL program. Process your second file to generate SORT control cards, run the generated cards on file 1. |
|
Back to top |
|
|
vinodh k r
New User
Joined: 03 Jul 2014 Posts: 5 Location: india
|
|
|
|
Hi Bill,
Thanks for your post!
The second file, that is the layout file will be a manual file so we can add info expected by you like whether field is SIGNED or UNSIGNED. In the file to be migrated, it can contain mixed types.
I do agree that this could be done in SORT with OUTREC fields, EDIT mentioning SIGN, but as conveyed earlier i am looking to make something GENERIC so that once we manually make the layout file with information
START POS END POS DATATYPE SIGNED/UNSIGNED
1 3 PD S
I am expecting it to get unpacked to corresponding DISPLAY format.
Since we have 250 files, and for all file, SORT card cannot be coded manually so thinking to make this generic.
Do you think if not in COBOL, by REXX could we make this work?
Thanks in advance! |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
What I'm suggesting is that you take your file description, and generate the SORT control cards from that.
Why is file 2 manual? Have you looked at extracting it from a compile listing?
PS. I never use OUTREC FIELDS. If I need to use OUTREC to make a new record, I use BUILD. Join us in the 21st Century, please. |
|
Back to top |
|
|
vinodh k r
New User
Joined: 03 Jul 2014 Posts: 5 Location: india
|
|
|
|
Hi Bill,
The files that i need to migrate are from different systems, we do not have the program compile listing that generates these files.
We are provided only with files and the Layout of it in copybook format.
I am just curious to know if through the available input, can we make some generic code/tool which can be used for all files to be able to migrate either through SORT or COBOL program.
PS: Thanks for pointing about BUILD! Will use that henceforth
Thanks in advance! |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
If I had to do this, I would do it in COBOL, and maybe I would use the whole copybook as parameter ("2nd file").
But I would have a few questions, like:
In which format the file is expected, on the PC side: plain flat file, CSV, XML ?
Are there also COMP values ?
What about dates ? |
|
Back to top |
|
|
vinodh k r
New User
Joined: 03 Jul 2014 Posts: 5 Location: india
|
|
|
|
Hi Marso,
The file is expected in PC side is plain flat file.
Yes there are COMP values in files at different places.
There will be no date fields in the file.
If you have an idea to do it in COBOL, can you please explain the process?
Thanks in advance! |
|
Back to top |
|
|
|