IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Unpack COMP/COMP-3 fields


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vinodh k r

New User


Joined: 03 Jul 2014
Posts: 5
Location: india

PostPosted: Thu Jul 03, 2014 11:56 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jul 03, 2014 12:56 pm
Reply with quote

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
View user's profile Send private message
vinodh k r

New User


Joined: 03 Jul 2014
Posts: 5
Location: india

PostPosted: Thu Jul 03, 2014 1:05 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jul 03, 2014 1:44 pm
Reply with quote

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
View user's profile Send private message
vinodh k r

New User


Joined: 03 Jul 2014
Posts: 5
Location: india

PostPosted: Thu Jul 03, 2014 2:29 pm
Reply with quote

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 icon_smile.gif

Thanks in advance!
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Jul 03, 2014 6:41 pm
Reply with quote

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
View user's profile Send private message
vinodh k r

New User


Joined: 03 Jul 2014
Posts: 5
Location: india

PostPosted: Mon Jul 07, 2014 10:17 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
Search our Forums:

Back to Top