MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Change from binary [S9(8) comp] to binary [S9(4) comp]

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
deepesh123
Beginner


Joined: 01 Feb 2008
Posts: 3
Topics: 1

PostPosted: Sun Feb 03, 2008 1:33 pm    Post subject: Change from binary [S9(8) comp] to binary [S9(4) comp] Reply with quote

Hi Everyone,
I'm facing a situation where in I have to change the length of a field of input file from S9(8) comp to S9(4) comp into the output file using SORT. I have tried it change it directly as

Code:

  SORT FIELDS=COPY                                           
  OUTREC  FIELDS=(1,361,362:362,4,BI,BI,LENGTH=2,364:366,18)


But it is giving me unexpected results.

Note: The whole situation is we have to change the S9(8) comp to S(4) comp by truncating the ZEROS.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Sun Feb 03, 2008 7:11 pm    Post subject: Reply with quote

Quote:
But it is giving me unexpected results.


This doesn't really tell us anything, so I can only guess what the problem is.

S9(8) comp and S9(4) comp are signed values - that's what the S means. With signed comp values, plus values have leading zeros whereas minus values have leading ones.

BI is an unsigned format, so it can handle the plus values correctly, but not the minus values.

FI is a signed format that can handle the plus and minus values correctly. So if you do have minus values, you need to use FI rather than BI.

If that isn't the problem/solution, then you need to give more details about the unexpected results such as what the input value looks like in hex and what the "incorrect" output value looks like in hex.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
deepesh123
Beginner


Joined: 01 Feb 2008
Posts: 3
Topics: 1

PostPosted: Sun Feb 03, 2008 9:32 pm    Post subject: Reply with quote

Actually, the situation is that we have a file which is having the field with value as S9(8) comp, and we need to change it to S9(4) comp. by truncating the leading 4 bytes which we are assuming to be ZEROS always.

eg. if we have data in i/p file as "00005678" then o/p file should have "5678" with proper sign.

So I tried to use this with the SORT card (as stated above) to convert the BI data directly from S9(8) comp to S9(4) comp. but it did not worked( I checked in FILE-AID, the last 4 bytes are not the same, it seems they are displayed in binary format).

I have also tried to convert the BI to ZD using INREC and again from ZD to BI using OUTREC.
I'm getting the last 4 bytes as expected, but I'm not able to handle the sign in the output.If you need I can provide this sort card also.

Note: The input file can have both -ive and +ive values

Please suggest.
Back to top
View user's profile Send private message
CraigG
Intermediate


Joined: 02 May 2007
Posts: 202
Topics: 0
Location: Viginia, USA

PostPosted: Sun Feb 03, 2008 10:41 pm    Post subject: Reply with quote

Did you read Frank's reply?
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Feb 04, 2008 11:28 am    Post subject: Reply with quote

deepesh123,

You seem to be totally confused about the various data formats, lengths, etc. You don't seem to know if your input field is in BI format, FI format, ZD format, etc. So it's difficult to help you.

You say you want to change from S9(8) comp to S9(4) comp. S9(8) comp is 4 bytes. S9(4) comp is 2 bytes. Yet you say you want to truncate the leading 4 bytes even though the original input field is only 4 bytes. And you go back and forth about whether the values can be negative or not. I don't see how you can expect anyone to help you with all of the confusing misinformation you're posting.

You show

362:362,4,BI,BI,LENGTH=2

So I'm assuming the field you want to convert is in positions 362-365. Run the following job to display the values in hex, and post the SORTOUT output ... perhaps that will help me determine what format you actually have for the input field.

Code:

//S1   EXEC  PGM=ICEMAN               
//SYSOUT    DD  SYSOUT=*               
//SORTIN DD DSN=...  input file   
//SORTOUT  DD SYSOUT=*                 
//SYSIN    DD    *                     
 OPTION COPY,STOPAFT=5                 
 INREC BUILD=(362,4,HEX)               
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
deepesh123
Beginner


Joined: 01 Feb 2008
Posts: 3
Topics: 1

PostPosted: Wed Feb 06, 2008 10:28 pm    Post subject: Reply with quote

Hi Frank,

Sorry for all the confusion, actually the input file has data in BI format only(362-365) and we have to convert it from 4 bytes to 2 bytes (i.e from S9(8) comp to S9(4) comp).
As suggested I'm sending you the result of sysout for your Job
09458587
094589DE
09458E35
0945928C

Please suggest.
Back to top
View user's profile Send private message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Thu Feb 07, 2008 12:08 am    Post subject: Reply with quote

deepesh123,

Code provided by Frank works exactly what you need. You have to post your input file contents here to help you better.
Back to top
View user's profile Send private message Send e-mail
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Feb 07, 2008 10:24 am    Post subject: Reply with quote

So your first input field has value X'09458587'. That means it has significant data in all 4 bytes. You can't "convert" that to 2 bytes without losing significant data. If you convert it to a 2-byte BI value using

362,4,BI,BI,LENGTH=2

it will be X'8587' so you will lose the first two bytes of X'0945'. Thus, it's unclear what you're trying to do or what result you'd want for this conversion.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group