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

Identify comp/comp-3 data from file


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bipinpeter

Active User


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

PostPosted: Thu Jan 14, 2016 2:27 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Jan 14, 2016 2:55 pm
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

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

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

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Thu Jan 14, 2016 2:58 pm
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

Moderator Emeritus


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

PostPosted: Thu Jan 14, 2016 4:15 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Jan 14, 2016 4:22 pm
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

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Thu Jan 14, 2016 4:46 pm
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

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Thu Jan 14, 2016 5:09 pm
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: 213
Location: Cochin/Kerala/India

PostPosted: Fri Jan 15, 2016 7:08 pm
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: 8697
Location: Dubuque, Iowa, USA

PostPosted: Fri Jan 15, 2016 7:38 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts How to save SYSLOG as text data via P... All Other Mainframe Topics 4
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Store the data for fixed length COBOL Programming 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
Search our Forums:

Back to Top