Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

subtract option in DFsort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
l.nethaji

New User


Joined: 16 Mar 2008
Posts: 90
Location: tamil nadu

PostPosted: Thu Jan 07, 2010 11:45 pm    Post subject: subtract option in DFsort
Reply with quote

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
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri Jan 22, 2010 10:12 pm    Post subject:
Reply with quote

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:

Code:

S1     90   
S2    180   
Back to top
View user's profile Send private message
l.nethaji

New User


Joined: 16 Mar 2008
Posts: 90
Location: tamil nadu

PostPosted: Sun Jun 27, 2010 9:59 pm    Post subject: Reply to: subtract option in DFsort
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Sun Jun 27, 2010 10:14 pm    Post subject:
Reply with quote

I would suggest you bookmark the z/OS V1R11.0 DFSORT Application Programming Guide.
And a good place to start your understanding would be the z/OS V1R11.0 DFSORT: Getting Started. It should make for some informative reading.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Jun 28, 2010 12:33 am    Post subject:
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Mon Jun 28, 2010 9:45 pm    Post subject:
Reply with quote

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:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DFSORT - Overriding default option TU... Steve Ironmonger DFSORT/ICETOOL 3 Tue Apr 04, 2017 3:54 pm
No new posts Compare two files and subtract values ameetmund DFSORT/ICETOOL 7 Fri Mar 31, 2017 3:35 pm
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts BWO option in VSAM blayek CICS 3 Sat Nov 05, 2016 10:47 am
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us