Page 1 of 2

Syncsort - ZD to PD with signs

PostPosted: Wed Oct 23, 2013 4:01 pm
by Raj2006
Hi All,

When I tried the below conversion, I expected a negative sign(D) for the 2nd and 3rd.But I am not getting it.

>> When I tried the "TO-PD" --> I GOT 'F' - UNSIGNED POSITIVE
>> After searched our forums, I tried using "TO=PDC" --> I got 'C' signed positive

Could please anyone clarify me? We use SYNCSORT FOR Z/OS 1.4.0.1R.
Input:
0445000
0}57500
0L20000


Sort:
SORT FIELDS=COPY
OUTREC FIELDS=(25,7,ZD,TO=PDC)

 á 
0400
450C
----
 ï&
0550
070C
----
   
0200
300C

Re: Syncsort - ZD to PD with signs

PostPosted: Wed Oct 23, 2013 4:12 pm
by Akatsukami
Note that the negative zones are in position 2; position 7 is positive. Thus, Syncsort interprets the whole as a positive number.

Re: Syncsort - ZD to PD with signs

PostPosted: Wed Oct 23, 2013 4:28 pm
by Raj2006
Dear Akatsukami,

I did not get yours.... could you elaborate it for me?

0}57500 --> 0550
070D - Shouldn't it be?

Re: Syncsort - ZD to PD with signs

PostPosted: Wed Oct 23, 2013 7:49 pm
by Akatsukami
Raj2006 wrote:Dear Akatsukami,

I did not get yours.... could you elaborate it for me?

0}57500 --> 0550
070D - Shouldn't it be?

The string "0}57500"' has a hex value of X'F0D0F5F7F5F0F0'' in EBCDIC. When converting from zoned decimal to packed decimal, the zones (high-order nybbles of each byte) are discarded, except for the zone of the low-order byte, which is used to determine the sign for the number. The low-order byte is X'F0', so the packed decimal number is given a sign of X'F', normalized to X'C'.

Re: Syncsort - ZD to PD with signs

PostPosted: Wed Oct 23, 2013 9:45 pm
by dick scherrer
Hello,

0}57500 --> 0550
070D - Shouldn't it be?
No. You need to read about how zoned numbers are stored.

How were these values created? No normal calculation that i know of would cause these results . . .

Re: Syncsort - ZD to PD with signs

PostPosted: Wed Oct 23, 2013 10:02 pm
by Akatsukami
dick scherrer wrote:How were these values created? No normal calculation that i know of would cause these results . . .

Oh, it's quite simple; Raj-kun is conflating two zoned decimal fields, one of two bytes and one of five.

Re: Syncsort - ZD to PD with signs

PostPosted: Wed Oct 23, 2013 11:22 pm
by dick scherrer
Yeah, i wondered about that, but did not know how the "result" was determined with the "}" "helping" with the result . . .

Long week today . . . :?

d

Re: Syncsort - ZD to PD with signs

PostPosted: Wed Oct 23, 2013 11:25 pm
by Raj2006
oh...

I confused with this input format. It seems, they come from some assembler program.

But I wanted this to be converted into PD. Is there any other way I can achieve this? Or do you need more info about the input format. Please advice...

Re: Syncsort - ZD to PD with signs

PostPosted: Wed Oct 23, 2013 11:58 pm
by Raj2006
Again I have tried the below, for the same input...

SORT FIELDS=COPY
OUTREC FIELDS=(26:26,6,ZD,PD,LENGTH=6)

I am able to see this field in file AID as below, but how would I get negative values? FIELD pic is --> S9(09)V99 COMP-3

4450.00
575.00
3200.00

Please advice...

Re: Syncsort - ZD to PD with signs

PostPosted: Thu Oct 24, 2013 12:04 am
by Akatsukami
This gets a little messy, because } is a zoned decimal negative zero, which isn't as straightforward to work with as other negative numbers. However, try this:
  SORT   FIELDS=COPY                                   
  OUTREC IFTHEN=(WHEN=(2,1,BI,GE,208,AND,2,1,BI,LE,217),
           OVERLAY=(1,7,ZD,MUL,-1,TO=PDC)),             
         IFTHEN=(WHEN=NONE,                             
           OVERLAY=(1,7,ZD,MUL,+1,TO=PDC))