IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

subtract option in DFsort


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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 Developer


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

PostPosted: Fri Jan 22, 2010 10:12 pm
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
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: 2146
Location: At my coffee table

PostPosted: Sun Jun 27, 2010 10:14 pm
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

Moderator Emeritus


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

PostPosted: Mon Jun 28, 2010 12:33 am
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 Developer


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

PostPosted: Mon Jun 28, 2010 9:45 pm
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:

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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts SCOPE PENDING option -check data DB2 2
No new posts DFsort help with SUM() DFSORT/ICETOOL 12
Search our Forums:

Back to Top