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: Tue Apr 24, 2012 5:50 pm
Reply with quote

hi,
i have requirement which i want to achieve it through dfsort.



(input lrecl=54,key-1-23)

Code:
01  DETAIL.                                   
    03 KEY.                                   
      05 STORE              PIC 9(5).         
      05 PRODA             PIC 9(9).         
      05 PRODB             PIC 9(9).         
    03 DATA.                                 
      05 STocK         PIC S9(9) COMP-3. 
      05 QTY1          PIC S9(9) COMP-3. 
      05 QTY2          PIC S9(9) COMP-3. 
      05 IND           PIC X.             
      05 SIZE          PIC 9(5)V99.       
      05 WEIGHT        PIC X.             
      05 WGT           PIC 9(5)V99. 

my input file is as below.
Code:
----------------------------------------------------------------------------------------------------
 (1-5)  (6-14)     (15-23)    (24-28)  (29-33)     (34-38)     (39-39)  (40-46)   (47-47) (48-54)
     
00010   050009698  008774500  +100    +222222222   +111111111    N      00006.00   I      00008.00

00010   050009698  008774600  +100    +222222222   +111111111    N      00006.00   I      00008.00

00010   050009698  008774700  +100    +222222222   +111111111    N      00006.00   I      00008.00

00010   050009700  008777500  +100    +222222222   +111111111    N      00005.00   I      00008.00

00010   050009700  008777600  +200    +222222222   +111111111    N      00006.10   I      00008.00

00010   050009700  008777700  +300    +222222222   +111111111    N      00007.20   I      00008.00

00010   050009700  008777800  +400    +222222222   +111111111    N      00008.00   I      00008.00
------------------------------------------------------------------------------------------------------


WHEN PRODA has multiple PRODB in STORE (when ALL PRODB has same size ):

then calculate the stock as 100+100+100=300


WHEN PRODA has multiple PRODB in STORE (when ALL PRODB has different size ):

then recalculate stock=100+(200*00006.10)/00005.00+(300*000007.20)/00005.00+(400*00008.00)/00005.00

=100+240+420+640=1400

Code:
----------------------------------------------------------------------------------------------------
00010   050009698  008774500  +300    +222222222   +111111111    N      00006.00   I      00008.00

00010   050009698  008774600  +100    +222222222   +111111111    N      00006.00   I      00008.00

00010   050009698  008774700  +100    +222222222   +111111111    N      00006.00   I      00008.00

00010   050009700  008777500  +100    +222222222   +111111111    N      00005.00   I      00008.00

00010   050009700  008777600  +240    +222222222   +111111111    N      00006.10   I      00008.00

00010   050009700  008777700  +420    +222222222   +111111111    N      00007.20   I      00008.00

00010   050009700  008777800  +640    +222222222   +111111111    N      00008.00   I      00008.00
--------------------------------------------------------------------------------------------------

step2:

bunch all the stock under that PRODA . and assign it to first PRODB.


and my final output should be
Code:
----------------------------------------------------------------------------------------------------
00010   050009698  008774500  +300    +222222222   +111111111    N      00006.00   I      00008.00

00010   050009698  008774600  +100    +222222222   +111111111    N      00006.00   I      00008.00

00010   050009698  008774700  +100    +222222222   +111111111    N      00006.00   I      00008.00

00010   050009700  008777500  +1400   +222222222   +111111111    N      00005.00   I      00008.00

00010   050009700  008777600  +240    +222222222   +111111111    N      00006.10   I      00008.00

00010   050009700  008777700  +420    +222222222   +111111111    N      00007.20   I      00008.00

00010   050009700  008777800  +640    +222222222   +111111111    N      00008.00   I      00008.00
--------------------------------------------------------------------------------------------------


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

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Tue Apr 24, 2012 5:51 pm
Reply with quote

i ran the below jcl . but it failed with rc=6. please correct me in case if anything wrong.

Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD DSN=MY INPUT FILE,DISP=SHR
//INB DD DSN=SAME INPUT FILE,DISP=SHR
//SORTOUT DD SYSOUT=*
//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,F2:57,4)
INREC IFOUTLEN=54,
IFTHEN=(WHEN=(55,2,ZD,EQ,1),OVERLAY=(24:57,4))
//*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(57:24,4)),
IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,14),PUSH=(55:SEQ=2)),
IFTHEN=(WHEN=(55,2,ZD,GT,1),
OVERLAY=(57:(57,4,PD,MUL,40,7,ZD),DIV,+5,EDIT=(TT),X,
(57,4,PD,MUL,40,7,ZD),MOD,+5,EDIT=(TT)),HIT=NEXT),
IFTHEN=(WHEN=(61,2,ZD,GT,0),OVERLAY=(24:57,4,PD,ADD,+1,EDIT=(TT)))
//*
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(57:24,4)),
IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,14),PUSH=(55:SEQ=2)),
IFTHEN=(WHEN=(55,2,ZD,GT,1),
OVERLAY=(57:(57,4,PD,MUL,40,7,ZD),DIV,+5,EDIT=(TT),X,
(57,4,PD,MUL,40,7,ZD),MOD,+5,EDIT=(TT)),HIT=NEXT),
IFTHEN=(WHEN=(61,2,ZD,GT,0),OVERLAY=(24:57,4,PD,ADD,+1,EDIT=(TT)))

SUM FIELDS=(57,4,PD)
//*

regds,
useit
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Apr 24, 2012 5:57 pm
Reply with quote

Quote:
i ran the below jcl . but it failed with rc=6. please correct me in case if anything wrong.
Why not post the actual output, instead of making everyone guess as to what the error message is?
Back to top
View user's profile Send private message
useit

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Tue Apr 24, 2012 6:34 pm
Reply with quote

my final output should be.

Code:
----------------------------------------------------------------------------------------------------
00010 050009698 008774500 +300 +222222222 +111111111 N 00006.00 I 00008.00

00010 050009698 008774600 +100 +222222222 +111111111 N 00006.00 I 00008.00

00010 050009698 008774700 +100 +222222222 +111111111 N 00006.00 I 00008.00

00010 050009700 008777500 +1400 +222222222 +111111111 N 00005.00 I 00008.00

00010 050009700 008777600 +240 +222222222 +111111111 N 00006.10 I 00008.00

00010 050009700 008777700 +420 +222222222 +111111111 N 00007.20 I 00008.00

00010 050009700 008777800 +640 +222222222 +111111111 N 00008.00 I 00008.00
--------------------------------------------------------------------------------------------------


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: Tue Apr 24, 2012 6:36 pm
Reply with quote

I suspect the EDIT=(TT) is a problem.

In the original solution, you had a two-byte zoned-decimal, which is what the EDIT=(TT) would give you.

Here, you have four-byte packed-decimal, according to your coding. TO=PD,LENGTH=4 would give you a four-byte packed-decimal answer.

There may be other problems...

Since you have the same code (except for the SUM) under both the JNFnCNTLs, I'd get it working on one first, and then copy it once it is working.

If you post again, please use the Code tags and post the output from the step as well.
Back to top
View user's profile Send private message
useit

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Tue Apr 24, 2012 7:05 pm
Reply with quote

i tried removing EDIT class but it did not work for me:(. also i just dont want to hard code DIV,+5...i want to populate it dynamically..since that value can change for the next key.

say for example

Code:
00010 050009700 008777700 +50 +222222222 +111111111 N 00002.00 I 00008.00

00010 050009700 008777800 +100 +222222222 +111111111 N 00003.00 I 00008.00


then i should recalulate it as


50+(100*3)/2=50+150=200


so my output will be



Code:
00010 050009700 008777700 +200 +222222222 +111111111 N 00002.00 I 00008.00

00010 050009700 008777800 +150 +222222222 +111111111 N 00003.00 I 00008.00
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: Tue Apr 24, 2012 7:36 pm
Reply with quote

When attempting the Code tags, try the Preview button, it allows you to see what the Post looks like before you Submit it, so you can make changes if necessary.

From you earlier record-layout, it seems that STOCK is 24 for a length of 5, PD, not 4.

I'm not going to go through checking everything for you. You need to do that. I've hacked about your Cobol layout into SYMNAMES and produced the SYMNOUT from that.

Code:
------- ORIGINAL STATEMENTS FROM SYMNAMES -------
STORE,1,5,CH                                     
PRODA,*,9,CH                                     
PRODB,*,9,CH                                     
STOCK,*,5,PD                                     
QTY1,*,5,PD                                     
QTY2,*,5,PD                                     
IND,*,1,CH                                       
SIZE,*,7,ZD                                     
WEIGHT,*,1,CH                                   
WGT,*,7,ZD                                       
                                                 
------------------ SYMBOL TABLE -----------------
STORE,1,5,CH                                     
PRODA,6,9,CH                                     
PRODB,15,9,CH                                   
STOCK,24,5,PD                                   
QTY1,29,5,PD                                     
QTY2,34,5,PD                                     
IND,39,1,CH                                     
SIZE,40,7,ZD                                     
WEIGHT,47,1,CH                                   
WGT,48,7,ZD                       


You can either use the symbols in your code, or at least use the definitions.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Apr 24, 2012 8:06 pm
Reply with quote

Your unreadable posts have been edited to use the code tags!

we moderators would appreciate if You started doing so Yourself
it' s a nuisance to have to waste time editing the posts of inconsiderate posters
but it' something that must be done to show respect and consideration
for the people spending time to help You !

use the preview button to check that Your posts look the way they should!
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Tue Apr 24, 2012 9:11 pm
Reply with quote

useit,

What should be the expected output for input records like below? This is where you have multiple PRODB records under PRODA but with the same values(00006.00) . Is it even possible?
Code:
00010   050009698  008774500  +100    +222222222   +111111111    N      00006.00   I      00008.00

00010   050009698  008774500  +100    +222222222   +111111111    N      00006.00   I      00008.00

00010   050009698  008774500  +100    +222222222   +111111111    N      00006.00   I      00008.00

Thanks,
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Apr 25, 2012 3:38 am
Reply with quote

useit wrote:
hi,
i have requirement which i want to achieve it through dfsort.
WHEN PRODA has multiple PRODB in STORE (when ALL PRODB has same size ):

then calculate the stock as 100+100+100=300


WHEN PRODA has multiple PRODB in STORE (when ALL PRODB has different size ):

then recalculate stock=100+(200*00006.10)/00005.00+(300*000007.20)/00005.00+(400*00008.00)/00005.00

=100+240+420+640=1400


useit,

You truly live up to your nickname USEit. icon_sad.gif I always wonder as to why people post imaginary requirements when they have trouble adapting the proposed solution to the real requirements. Are you under the assumption that we cannot comprehend the requirement as you do? You already have a topic about rounding and summing up the values and you cannot adopt that solution to the actual requirement here because there are many other factors to consider. As Bill pointed out, PD field you used in calculation is 5 bytes and you are calculating using just 4 bytes.
useit wrote:

i ran the below jcl . but it failed with rc=6.

RC=6? DFSORT does not issue an return code of 6. well I guess you are hungry and ate the 10 or you simply rounded it ? How hard is to post the complete sysout? I guess the mods did a good job adding the code tags to your post.

Anyway despite all the above the requirement isn't clear.

200*00006.10)/00005.00 = 244 but you had 240. So are you rounding the size field (value 6.10) to 6 and performing the math or you taking the entire 200*00006.10)/00005.00 = 244 and then round it to 240?

Which value are you rounding? And how is the rounding done? if it is size then any value greater than 49 in the decimal field will be rounded to next integer . ie 6.50, 6.99 becomes 7 and 6.01, 6.49 becomes 6.

Or if you are rounding after calculating the entire value , then how do you plan to round?

241,242,243,244 becomes 240 ??

245,246,247,248,249 becomes 250??
Back to top
View user's profile Send private message
useit

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Wed Apr 25, 2012 9:12 am
Reply with quote

skolusu,
extremely sorry.

WHEN PRODA has multiple PRODB in STORE (when ALL PRODB has different size ):

then recalculate stock=100+(200*00006.10)/00005.00+(300*000007.20)/00005.00+(400*00008.00)/00005.00

=100+244+432+640=1416.

so my output should be.

Code:
00010 050009698 008774500 +300 +222222222 +111111111 N 00006.00 I 00008.00

00010 050009698 008774600 +100 +222222222 +111111111 N 00006.00 I 00008.00

00010 050009698 008774700 +100 +222222222 +111111111 N 00006.00 I 00008.00

00010 050009700 008777500 +1416 +222222222 +111111111 N 00005.00 I 00008.00

00010 050009700 008777600 +244 +222222222 +111111111 N 00006.10 I 00008.00

00010 050009700 008777700 +432 +222222222 +111111111 N 00007.20 I 00008.00

00010 050009700 008777800 +640 +222222222 +111111111 N 00008.00 I 00008.00

sorry for the typo.return code which am getting is 16:(

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

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Wed Apr 25, 2012 11:07 am
Reply with quote

HI ,
i ran the below jcl but i did not get the correct output.please correct me the jcl whic i have coded.


Code:
//STEP0100 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//INA      DD DSN=INPUT FILE,DISP=SHR         
//INB      DD DSN=SAME INPUT FILE,DISP=SHR           
//SORTOUT  DD DSN=OUTPUT FILE,DISP=SHR     
//SYSIN    DD *                                         
  OPTION COPY                                           
  JOINKEYS F1=INA,FIELDS=(1,23,A),SORTED,NOSEQCK       
  JOINKEYS F2=INB,FIELDS=(1,23,A)                       
  REFORMAT FIELDS=(F1:1,54,55,2,F2:57,5)               
  INREC IFOUTLEN=54,                                   
  IFTHEN=(WHEN=(55,2,ZD,EQ,1),OVERLAY=(24:57,5))       
//*                                                     

//JNF1CNTL DD *                                                         
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(57:24,5)),                           
  IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,23),PUSH=(55:SEQ=2)),                 
  IFTHEN=(WHEN=(55,2,ZD,GT,1),                                         
  OVERLAY=(57:(57,5,PD,MUL,40,7,ZD),DIV,+5,PD,LENGTH=5,X,               
              (57,5,PD,MUL,40,7,ZD),MOD,+5,PD,LENGTH=5),HIT=NEXT),     
  IFTHEN=(WHEN=(61,2,ZD,GT,0),OVERLAY=(24:57,5,PD,ADD,+1,PD,LENGTH=5)) 
//*                                                                     
//JNF2CNTL DD *                                                         
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(57:24,5)),                           
  IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,23),PUSH=(55:SEQ=2)),                 
  IFTHEN=(WHEN=(55,2,ZD,GT,1),                                         
  OVERLAY=(57:(57,5,PD,MUL,40,7,ZD),DIV,+5,PD,LENGTH=5,X,               
              (57,5,PD,MUL,40,7,ZD),MOD,+5,PD,LENGTH=5),HIT=NEXT),     
  IFTHEN=(WHEN=(61,2,ZD,GT,0),OVERLAY=(24:57,5,PD,ADD,+1,PD,LENGTH=5)) 
  SUM FIELDS=(57,5,PD)                                                 
//*
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Wed Apr 25, 2012 11:22 am
Reply with quote

the preview button... the fkng preview button

edited again Your last two posts to put the code tags in the proper place
Back to top
View user's profile Send private message
useit

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Wed Apr 25, 2012 12:17 pm
Reply with quote

Hi,

when i give 40,7,ZD Calculated value was wrong.when i give 40,5,ZD VALUE is populated correctly. what should be the lcorrect length of
FOR PIC 9(5)V99??

Code:
OVERLAY=(57:(57,5,PD,MUL,40,5,ZD),DIV,+5,PD,LENGTH=5,X,             
             (57,5,PD,MUL,40,5,ZD),MOD,+5,PD,LENGTH=5),HIT=NEXT),   



Regds,
useit

edited again icon_evil.gif
Back to top
View user's profile Send private message
useit

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Wed Apr 25, 2012 12:19 pm
Reply with quote

Code:
OVERLAY=(57:(57,5,PD,MUL,40,7,ZD),DIV,+5,PD,LENGTH=5,X,
(57,5,PD,MUL,40,7,ZD),MOD,+5,PD,LENGTH=5),HIT=NEXT),


edited again
icon_evil.gif
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 1:39 pm
Reply with quote

useit wrote:
Hi,

when i give 40,7,ZD Calculated value was wrong.when i give 40,5,ZD VALUE is populated correctly. what should be the lcorrect length of
FOR PIC 9(5)V99??

Code:
OVERLAY=(57:(57,5,PD,MUL,40,5,ZD),DIV,+5,PD,LENGTH=5,X,             
             (57,5,PD,MUL,40,5,ZD),MOD,+5,PD,LENGTH=5),HIT=NEXT),   



Regds,
useit

edited again icon_evil.gif


The correct length of 9(5)V99 is seven bytes. Note there is no way to define a decimal decimal place, 40,7,ZD could be 9(5)99 or 9(7) or V9(7) or anything which is seven digits with or without a decimal place. So you have to deal with any decimal places in your calculation. Is that what went "wrong"?
Back to top
View user's profile Send private message
useit

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Wed Apr 25, 2012 2:02 pm
Reply with quote

bill,

yes.it is giving some huge namber after calculation


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 2:06 pm
Reply with quote

So for every part with decimal places, you need to keep things is check as you progress through the calculation.

One way is divide by +100 for each two decimal places (divide by +10 for each decimal place).
Back to top
View user's profile Send private message
useit

Active User


Joined: 05 Oct 2006
Posts: 152

PostPosted: Wed Apr 25, 2012 2:30 pm
Reply with quote

thanks a lot bill.it is working fine.
one more doubt is in the below statement i have hardcodeddiv, +5 which i want to populate it dynamically.

Code:
OVERLAY=(57:(57,5,PD,MUL,40,5,ZD),DIV,+5,PD,LENGTH=5,X,             
             (57,5,PD,MUL,40,5,ZD),MOD,+5,PD,LENGTH=5),HIT=NEXT),


how can we use the push command to populate the value?

FOR EXAMLE.

Code:
00010   050009700  008777500  +100    +222222222   +111111111    N      00005.00   I      00008.00

00010   050009700  008777600  +240    +222222222   +111111111    N      00006.00   I      00008.00

00010   050009700  008777700  +420    +222222222   +111111111    N      00007.00   I      00008.00

00010   050009999  008777500  +100    +222222222   +111111111    N      00001.00   I      00008.00

00010   050009999  008777600  +240    +222222222   +111111111    N      00002.00   I      00008.00

00010   050009999  008777700  +420    +222222222   +111111111    N      00003.00   I      00008.00


in this case for the first key i will recalculate the stock as

100+(240*00006.00)/00005.00+(420*00006.00)/00005.00

for the second key

100+(240*00002.00)/00001.00+(420*00003.00)/00001.00

so i cant simply divide by some value. i need to mention the proper position.

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 2:40 pm
Reply with quote

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


This is where you identify the first record which makes up your group of records.

If that record contains the "divisor" that you want to use "dynamically", extend the PUSH so that it includes, at a location you are not already using, a copy of the divisor which can be used for all the records. Remember you have decimal places in that as well, it seems.
Back to top
View user's profile Send private 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