View previous topic :: View next topic
Author
Message
l.nethaji New User Joined: 16 Mar 2008Posts: 90 Location: tamil nadu
Hi,
This is one of the interview question asked,
We have 2 files A and B.
We have one key say S1,S2 which is common to both A and B.
If the keys are same ,say in the below example s1 ,i have to do the below functionality
s1 value in file A -s1 value in file B i.e 100-10 =90 .this 90 should be saved in File A under key s1
file A file B
key value key value
S1 100 S1 10
S2 200 S2 20
i just wanna to know which option we use in DFsort for subtracting the value from 1 file from the another.
For Summing we use options sum fields .similarly whether we have any option for subtraction
Please help .
thanks,
L.Nethaji
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
There's no equivalent to SUM for subtraction. However, here's one way you can do what you want with DFSORT (there are others).
Code:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
S1 100
S2 200
// DD *
S1 10
S2 20
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION EQUALS
SORT FIELDS=(1,2,CH,A)
OUTREC IFOUTLEN=80,
IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,1,ZD,RESTART=(1,2))),
IFTHEN=(WHEN=(81,1,ZD,EQ,2),
OVERLAY=(7:7,3,ZD,MUL,-1,TO=ZD,LENGTH=3))
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(1,2,
TRAILER3=(1,2,7:TOT=(7,3,ZD,EDIT=(IIT))))
/*
SORTOUT will have:
Back to top
l.nethaji New User Joined: 16 Mar 2008Posts: 90 Location: tamil nadu
hi frank,
thanks for the reply.
This may be lay man question .since i am new to DFsort's i am asking this .
Could be please explain me this part
IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,1,ZD,RESTART=(1,2))),
what is the use of if then ,initiate,overlay,seqnum,restart.
IFTHEN=(WHEN=(81,1,ZD,EQ,2),
OVERLAY=(7:7,3,ZD,MUL,-1,TO=ZD,LENGTH=3))
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(1,2,
TRAILER3=(1,2,7:TOT=(7,3,ZD,EDIT=(IIT))))
what is use of trailers ,section.
Whether as u said it can be done in other way,whether it possible in basic sort.
please clarify,
thanks,
l.nethaji
Back to top
CICS Guy Senior Member Joined: 18 Jul 2007Posts: 2146 Location: At my coffee table
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19244 Location: Inside the Matrix
Hello,
Suggest you consider this. . . .
If you want to wrlte programs using "a sort" you will surely need more than "SORT FIELDS= ". For what you asked to do, the solution Frank provided IS basic.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
nethaji,
If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:
www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080
Back to top
Please enable JavaScript!