Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Identify comp/comp-3 data from file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 208
Location: Cochin/Kerala/India

PostPosted: Thu Jan 14, 2016 2:27 pm    Post subject: Identify comp/comp-3 data from file
Reply with quote

Hi All,

I am trying to read a file in rexx and trying to convert the data if fields are comp or comp-3.I have seen some of the thread for conversion.

I have the variables starting position and length but dont have type of the fields.I done substring on the record with start position and length and then did DATATYPE check.but always it will return type as CHAR.Is any way in rexx that can identify a field is comp or comp-3 field after reading from file.

Regards,
Bipin Peter
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Thu Jan 14, 2016 2:55 pm    Post subject: Reply to: Identify comp/comp-3 data from file
Reply with quote

Quote:
.Is any way in rexx that can identify a field is comp or comp-3 field after reading from file.


NO ...

just think about it PLEASE!

x'0c' could be a 0 packed or a 12 binary
x'c1" could be an A ( char) or a 193 in binary

so it is up to You to implement the proper conversion functions .

see here for working snippets for packed data

http://ibmmainframes.com/viewtopic.php?t=31547&postdays=0&postorder=asc&start=15

http://ibmmainframes.com/viewtopic.php?t=27921&highlight=rexx+pack
Back to top
View user's profile Send private message
Willy Jensen

New User


Joined: 01 Sep 2015
Posts: 94
Location: Switzerland

PostPosted: Thu Jan 14, 2016 2:58 pm    Post subject:
Reply with quote

Hi, I'm not a COBOL person, but I understand that a comp-3 field is what in assembler is a packed decimal field.
A packed decimal field has the hex format X'nnnnns' where n must be a number and s is the sign C,D or F.
You can then identify a field to be comp-3 using something like the following:

u=c2x(substr(p,1,2)) /* pick field from record, convert to readable hex */
/* test for comp-3 */
if verify(left(u,3),'0123456789','N')=0,
& pos(right(u,1),'CDF')>0 then do /* comp-3 */
end
else do /* not comp-3 */
end

Willy
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Jan 14, 2016 4:15 pm    Post subject:
Reply with quote

Willy Jensen wrote:
You can then identify a field to be comp-3 ...


As enrico has indicated, it is not possible to do. X'0C' may be the last byte of a packed-decimal, but it can equally be a value in a binary field, a floating-point field, or some value even in a PIC X field (all bit patterns are valid).

Unless you know the start, length and type, you can only guess.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Thu Jan 14, 2016 4:22 pm    Post subject: Reply to: Identify comp/comp-3 data from file
Reply with quote

especially because the TS has asked
Quote:
if fields are comp or comp-3
Back to top
View user's profile Send private message
prino

Active Member


Joined: 07 Feb 2009
Posts: 982
Location: Oostende, Belgium

PostPosted: Thu Jan 14, 2016 4:46 pm    Post subject:
Reply with quote

You can do a bit of educated guesswork, but not much more, using:

length = 1: packed decimal or char
length = 2: all bets are off
length = 3: packed decimal or char
length = 4: all bets are off
length = 5/6/7/8: packed decimal or char
length > 8: most likely char

Of course if you use 64-bit comp-whatever binaries and 31 digit fixed decimals even more bets are off...
Back to top
View user's profile Send private message
Willy Jensen

New User


Joined: 01 Sep 2015
Posts: 94
Location: Switzerland

PostPosted: Thu Jan 14, 2016 5:09 pm    Post subject:
Reply with quote

well, he did say 'I have the variables starting position and length' so I took it that he needed a test for comp3 or not comp3 (which is a 2-byte field as I understand). I agree that there could be something entire different in that area.
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 208
Location: Cochin/Kerala/India

PostPosted: Fri Jan 15, 2016 7:08 pm    Post subject:
Reply with quote

Hi All,

I managed to get the type of data from the layout.

Now i am trying to convert the comp & comp-3 data to readable form.

One of my comp fields definition is PIC s9(07) comp.

Using substring I have taken the data and used C2X and X2D functions.

for this particular field, when i am viewing the data with fileaid I can see data as 1077990645.

After C2X function the compressed data got converted to 4040D4F5 but its giving error in X2D function.

Do you have any idea why this error happened and how we can do conversion?

Bipin Peter
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7905
Location: Bellevue, IA

PostPosted: Fri Jan 15, 2016 7:38 pm    Post subject:
Reply with quote

PIC S9(07) COMP will be a 4-byte hexadecimal value. X'4040D4F5' is 1077990645 in decimal. If you are seeing 1077990645 in File Aid, then the value is not being converted by your routines -- and I would suspect a problem with your layout since X'4040D4F5' is space space M 5 as zoned decimal DATA.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us