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

Calculate and rounding up value using dfsort


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
useit

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Wed Apr 25, 2012 3:13 pm
Reply with quote

bill,

sorry i did not get:( . my first record will contain a "divisor" at 40,7 position. am not aware how to extend the push command.could you please help me in this regard

Regds,
useit
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Apr 25, 2012 3:23 pm
Reply with quote

Code:
IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,23),PUSH=(55:SEQ=2,63:40,7)),


Then replace the +5s with references to 63,7,ZD, remembering to take account of the decimal places.

I have not tested, nor more than superficially checked that column 63 is free.
Back to top
View user's profile Send private message
useit

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Wed Apr 25, 2012 6:14 pm
Reply with quote

bill,
thanks a lot for your help. i ran the jcl and it worked as expected. only problem calulated value is rounding down. it is not rounding up.

also kindly let me know why we have used MOD Instead of DIV.

PLEASE FIND my final jcl.

Code:
//STEP0100 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//INA      DD DSN=INFILE,DISP=SHR           
//INB      DD DSN=INFILE,DISP=SHR           
//SORTOUT  DD DSN=XK00.MULTIPLE.TPNB.CLONE,DISP=SHR     
//SYSIN    DD *                                         
  OPTION COPY                                           
  JOINKEYS F1=INA,FIELDS=(1,14,A),SORTED,NOSEQCK       
  JOINKEYS F2=INB,FIELDS=(1,14,A)                       
  REFORMAT FIELDS=(F1:1,54,55,2,57,7,F2:64,5)           
  INREC IFOUTLEN=54,                                   
  IFTHEN=(WHEN=(55,2,ZD,EQ,1),OVERLAY=(24:64,5))       
//*                                                     
//JNF1CNTL DD *                                                         
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(64:24,5)),                           
  IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,14),PUSH=(55:SEQ=2,57:40,7)),         
  IFTHEN=(WHEN=(55,2,ZD,GT,1,AND,57,7,ZD,NE,40,7,ZD),                   
  OVERLAY=(64:(64,5,PD,MUL,40,7,ZD),DIV,57,7,ZD,PD,LENGTH=5,X,         
              (64,5,PD,MUL,40,7,ZD),MOD,57,7,ZD,PD,LENGTH=5),HIT=NEXT) 
//*                                                                     
//JNF2CNTL DD *                                                         
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(64:24,5)),                           
  IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,14),PUSH=(55:SEQ=2,57:40,7)),         
  IFTHEN=(WHEN=(55,2,ZD,GT,1,AND,57,7,ZD,NE,40,7,ZD),                   
  OVERLAY=(64:(64,5,PD,MUL,40,7,ZD),DIV,57,7,ZD,PD,LENGTH=5,X,         
              (64,5,PD,MUL,40,7,ZD),MOD,57,7,ZD,PD,LENGTH=5),HIT=NEXT) 
  SUM FIELDS=(64,5,PD)                                                 
//*                                                                   


REGDS,
USEIT
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Apr 25, 2012 6:37 pm
Reply with quote

This is from Kolusu's original solution to you first topic.

Code:
//JNF1CNTL DD *                                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(11:6,2)),                         
  IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,5),PUSH=(9:SEQ=2)),                 
  IFTHEN=(WHEN=(9,2,ZD,GT,1),                                       
  OVERLAY=(11:(11,2,ZD,MUL,8,1,ZD),DIV,+6,EDIT=(TT),X,               
              (11,2,ZD,MUL,8,1,ZD),MOD,+6,EDIT=(TT)),HIT=NEXT),     
  IFTHEN=(WHEN=(14,2,ZD,GT,0),OVERLAY=(06:11,2,ZD,ADD,+1,EDIT=(TT)))


The final IFTHEN is doing your "rounding up". For any number which is not exactly divisible by +6, one will be added to the result.

The MOD is used to work out the "exactly divisible", since if exactly divisble 14,2,ZD will be zero.

I don't know how it is "working" but not correct, but there we go.

You have no equivalent final IFTHEN, so you are just getting the straight output from DFSORT's DIV. Without the IFTHEN you don't need the MOD, but you won't get the "rounding up", you'll get the "rounding" from DIV.

You haven't used MOD instead of DIV, you've used both. As it stands, nothing is using the result of the MOD.
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 DFsort help with SUM() DFSORT/ICETOOL 12
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top