View previous topic :: View next topic
Author
Message
satish.ms10 Active User Joined: 10 Aug 2009Posts: 184 Location: India
Hi There,
Hope you are doing well.
I am in need of some help with DFSORT. I have a PD field of 5 bytes and I want to convert it into display format and show CR and DB in front of the value based on the sign (CR for +, DB for -) as mentioned below.
Input Sample Data:
Code:
=COLS> ----+
****** *****
000100 <
01234
0234C
------------
000200 ÂÄÀ(
06664
0234D
------------
000300 êëè*
05555
0234C
------------
000400 bcdý
08888
0234D
------------
000500
01111
0234D
------------
000600 klm¸
09999
0234D
Expected Output is:
Code:
CR 001223344
DB 006263644
CR 005253545
DB 008283848
DB 001213141
DB 009293949
I have tried couple of ways but couldn't figure out exact solution for my scenario.
I have tried below sort cards
Code:
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1,5,PD,M3)
/*
Output:
----+----1----
**************
12,233.44
62,636.44CR
52,535.45
82,838.48CR
12,131.41CR
92,939.49CR
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1,5,PD,EDIT=(STTTTTTTTT),SIGNS=(+,-))
/*
Output:
----+----1
**********
+001223344
-006263644
+005253545
-008283848
-001213141
-009293949
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1,5,PD,EDIT=(TTTTTTTTTS),SIGNS=(,,C,D))
/*
Output:
----+----1
**********
001223344C
006263644D
005253545C
008283848D
001213141D
009293949D
Kindly guide me in this regard. Thanks in advance.
Back to top
Joerg.Findeisen Senior Member Joined: 15 Aug 2015Posts: 1327 Location: Bamberg, Germany
Quick hack:
Code:
//WHATEVER EXEC PGM=ICEMAN
//SORTIN DD *
<
klm¸
/*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(1,5,PD,EDIT=(STTTTTTTTTTT),SIGNS=(C,D),
1:1,1,CHANGE=(3,C'C',C'CR ',C'D',C'DB ')))
END
/*
Back to top
satish.ms10 Active User Joined: 10 Aug 2009Posts: 184 Location: India
Hi Joerg.Findeisen,
Thank you so much for your help. It worked for my scenario.
Back to top
Joerg.Findeisen Senior Member Joined: 15 Aug 2015Posts: 1327 Location: Bamberg, Germany
If you have unsigned PD fields, you should add also a NOMATCH clause to the CHANGE operation. Other than that, you are good to go.
Back to top
satish.ms10 Active User Joined: 10 Aug 2009Posts: 184 Location: India
Hi Joerg.Findeisen
There are no unsigned values in that field. Thank you
Back to top
Please enable JavaScript!