MVSFORUMS.com A Community of and for MVS Professionals
View previous topic :: View next topic
Author
Message
bprasanna Beginner Joined: 05 Sep 2003 Posts: 119 Topics: 33 Location: Hyderabad
Posted: Fri Jun 11, 2004 8:41 am Post subject: Any clue for the remainder of division in SORT?
Hi all,
Is there any way in sort to get the remainder of a number?
I am having a filed in my flat file. I need to get the final value with this below function.
Output = (xxx - 1) mod 12
where xxx is the number from my input file.
Let's think that my xxx is having the value of 353.Then
Output = (353-1) mod 12
= Remainder of (352/12)
= 4
Please note my shop doesn't have DFSORT.It is having only the SYNCSORT.
Thanks
Murali
Back to top
Frank Yaeger Sort Forum Moderator Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Fri Jun 11, 2004 9:03 am Post subject:
I know you said you have Syncsort, not DFSORT, but for the record, here's an example of how you could do this with DFSORT:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
353
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTREC FIELDS=((1,3,ZD,SUB,+1),MOD,+12,TO=ZD,LENGTH=3)
/*
_________________ 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
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12380 Topics: 75 Location: San Jose
Posted: Fri Jun 11, 2004 9:12 am Post subject:
Try this,
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
353
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC FIELDS=(1,3,ZD,DIV,+12,EDIT=(TTT),X,
+1,SUB,1,3,ZD,EDIT=(TTT))
OUTREC FIELDS=(5,3,ZD,SUB,(+12,MUL,1,3,ZD),EDIT=(TTT))
/*
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
bprasanna Beginner Joined: 05 Sep 2003 Posts: 119 Topics: 33 Location: Hyderabad
Posted: Mon Jun 14, 2004 7:24 am Post subject:
Hi,
Thanks for u r reply.I got another doubt here.Can we do it only with
OUTREC statement(as same as Frank's reply) ?Because I need to list out some other details from the input and I need to perfome some other calculations on the same field.
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12380 Topics: 75 Location: San Jose
Posted: Mon Jun 14, 2004 7:53 am Post subject:
bprasanna,
Post your complete requirement and may be we can suggest something. Also post the LRECL, POSITION of the computing field and RECFM of the input of the dataset. It would be great if you can post a sample input and desired output
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
bprasanna Beginner Joined: 05 Sep 2003 Posts: 119 Topics: 33 Location: Hyderabad
Posted: Tue Jun 15, 2004 8:57 am Post subject:
Hi Kolusu,
Thanks again for u r reply.
Here is my requirement.
We are having FB file of length 714.The data in it is like below.
$ 100136940201 090 *
51FFFFFFFFFFFF04111FFF 00500
B51001369402010055509013C1C
Here I am having the hex value(which is in red) 01035C010C.
Now I have to peform the following calculations on this value.
Calculation 1: (01035-1) Mod 12 + 1.
So I will get the value as 3.
I tried with u r previous example.That is working fine for all conditions except for the below.
If i am having the hex value as 00780c001c,
then
= (780-1) mod 12 + 1
=11 + 1
=12
Where I am getting the problem is once we divide the input value with 12 ,it is rounding the value to 65,but we need 64 only over there.
then we will get the correct value.
Ie..064 779----------->from the in rec statement
779-(64*12)---------> 11 +1 =12--------->from out rec statement.
I hope I am able to explain my problem.
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12380 Topics: 75 Location: San Jose
Posted: Tue Jun 15, 2004 10:22 am Post subject:
bprasanna,
Let me get this clear.
You have a number ex: 353 , 780...
1. You need to subtract 1 from that number which makes them as 352, 779 ...
2. Divide this number by 12 to get the remainder which is 4 and 11 respectively.
3. Now add 1 to the remainder which makes them 5 and 12 respectively
Is that right ?
If that is true then the following JCL will give you the results.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
353
780
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC FIELDS=(+1,SUB,1,3,ZD,EDIT=(TTT),X,
(+1,SUB,1,3,ZD),DIV,+12,EDIT=(TTT))
OUTREC FIELDS=(1,3,X,
+1,ADD,(1,3,ZD,SUB,(+12,MUL,5,3,ZD)),EDIT=(TTT))
/*
Hope this helps...
Cheers
Kolusu
Ps: I used the generic example because you did not specify , the position and format of the field. _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
bprasanna Beginner Joined: 05 Sep 2003 Posts: 119 Topics: 33 Location: Hyderabad
Posted: Wed Jun 23, 2004 2:38 am Post subject:
Thank you very much Kolusu!!!It worked fine!
Since as I am out of station,Today I checked it and it worked fine.
Thanks again..
Back to top
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