View previous topic :: View next topic
|
Author |
Message |
chinnielr
New User
Joined: 11 Jul 2005 Posts: 87
|
|
|
|
Can anyone let me know how to convert a negative numeric field to positive using SORT.
i.e., I have a flat file in which one column (AMOUNT) is having values like 100.00, -200.00, 450.00
I want the output like 100.00, 200.00, 450.00. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You can use INREC, OUTREC or OUTFIL with something like
(...,p,7,UFF,EDIT=(TTT.TT),...)
where p is the starting position of the input field. DFSORT's UFF format will extract the digits and ignore the sign. If you want more specific help, you need to give more details such as the starting position and length of the input field and the starting position and length of the output field and what you want the output field to look like (e.g. leading zeros? no leading zeros?). |
|
Back to top |
|
|
chinnielr
New User
Joined: 11 Jul 2005 Posts: 87
|
|
|
|
Hi Frank,
Thanks for your reply.
But my Amount fields are of PD format and I want to remove the negative sign. The output format should have PD format.
starting poistion of input field = 21
length of input field = 8
starting position of output field = 21
length of output field = 8
both input and output positions and length are same I just want to remove the sign and the output should ahve the same format as input.
Thanks in advance. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
But my Amount fields are of PD format and I want to remove the negative sign. The output format should have PD format. |
Was I supposed to guess that or just read your mind? Please try to give all of the relevant information in the future.
Here's a DFSORT job that will do what you asked for:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=... output file
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=(21,8,PD,LT,+0),
OVERLAY=(21:21,8,PD,MUL,-1,TO=PD,LENGTH=8))
/*
|
|
|
Back to top |
|
|
|