Sort Utility to convert
Select messages from
# through # FAQ
[/[Print]\]

MVSFORUMS.com -> Utilities

#1: Sort Utility to convert Author: Deepika PostPosted: Tue Jun 06, 2006 8:24 am
    —
Hi,
Please let me know the sort option or other utility to convert zoned decimal positive value to negative value.

#2:  Author: kolusuLocation: San Jose PostPosted: Tue Jun 06, 2006 8:43 am
    —
Deepika,

You need to provide us with details. Show us a sample input and desired output. Also explain what exactly you mean by convert as zoned decimals have a sign ovepunched on the last byte.

Kolusu

#3:  Author: Deepika PostPosted: Tue Jun 06, 2006 9:03 am
    —
For eg: Amount field is 15.35 then internally in mainframe it is stored as
Positive Value is stored as : FFFFFFFFFFF
00000001535
Negative value is stored as : FFFFFFFFFFD
00000001535


We need the Sort utility function to convert the X'F' to X'D' ( Last half byte), hence the Zoned decimal amount field will be converted to Negative amount.

#4:  Author: kolusuLocation: San Jose PostPosted: Tue Jun 06, 2006 9:10 am
    —
Deepika,

Is your input field a packed decimal ? You say zoned decimal but your data shows a packed decimal data(comp-3) . only packed decimal fields have the sign in the last nibble X'F' & X'C' represent Positive values and X'D' represents negative value.

Just tell me the cobol declaration of the input field and desired output field.

Kolusu

#5:  Author: Deepika PostPosted: Tue Jun 06, 2006 9:46 am
    —
Thanks for the quick response,Kolusu.
The COBOL Declaration for Input field is S9(18)V9(2) Comp-3.
The output should be in the same format but multipied with -1.
Please let me know if there is any sort option for the same.

#6:  Author: kolusuLocation: San Jose PostPosted: Tue Jun 06, 2006 10:14 am
    —
Deepika,

Assuming that you only wanted to convert positive values to negative values , the following jcl will give you the desired results. I assumed that your input field to be changed starts from position 1. S9(18)V9(2) Comp-3 occupies 11 bytes.


Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD DSN=YOUR INPUT FILE,
//            DISP=SHR                   
//SORTOUT  DD DSN=YOUR OUTPUT FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *
 SORT FIELDS=COPY                                       
 OUTREC IFTHEN=(WHEN=(01,11,PD,GT,0),                   
            OVERLAY=(-1,MUL,1,11,PD,PD,LENGTH=11)),     
        IFTHEN=(WHEN=NONE,OVERLAY=(01,11))               
/*


Hope this helps...

Cheers

Kolusu

Ps: The next time please be clear with the questions.

#7:  Author: Frank YaegerLocation: San Jose PostPosted: Tue Jun 06, 2006 11:28 am
    —
Hmmm ... I took the values to be:

Code:

Positive Value is stored as :
FFFFFFFFFFF
00000001535

Negative value is stored as :
FFFFFFFFFFD
00000001535


which would be ZD. I don't understand how that can be interpreted as PD.
Of course, if it is PD, it really doesn't look like that.

The same question was asked on another board and this is the response I gave:

You can do that with DFSORT by multiplying by -1.

Let's assume you have an 11-byte ZD field starting in position 21.

If you only have positive ZD values, you can use:

Code:

  OPTION COPY
  INREC OVERLAY=(21:21,11,ZD,MUL,-1,TO=ZD,LENGTH=11)


If you have both positive and negative ZD values and you only want to change the positive values to negative values, you can use:

Code:

  INREC IFTHEN=(WHEN=(21,11,ZD,GE,+0),
        OVERLAY=(21:21,11,ZD,MUL,-1,TO=ZD,LENGTH=11))

#8:  Author: kolusuLocation: San Jose PostPosted: Tue Jun 06, 2006 12:57 pm
    —
Quote:

I don't understand how that can be interpreted as PD.
Of course, if it is PD, it really doesn't look like that.



Frank,

The last post from deepika is this

deepika wrote:

Thanks for the quick response,Kolusu.
The COBOL Declaration for Input field is S9(18)V9(2) Comp-3.
The output should be in the same format but multipied with -1.
Please let me know if there is any sort option for the same.


I agree that the first initial posts are confusing , but I guess some people have hardtime understanding the basic differences zoned/binary/packed formats.

Kolusu

#9:  Author: Frank YaegerLocation: San Jose PostPosted: Tue Jun 06, 2006 2:03 pm
    —
Quote:
The COBOL Declaration for Input field is S9(18)V9(2) Comp-3.


Yes, I know deepika said that. My point was that the declare doesn't match the data he showed on both boards. So either he pulled the data he showed out of a hat, or he pulled the COBOL declare he showed out of a hat. Hard to tell which it is. At any rate, I think we've covered all the cases.



MVSFORUMS.com -> Utilities


output generated using printer-friendly topic mod. All times are GMT - 5 Hours

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group