Need help about overlay of DFSORT



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Need help about overlay of DFSORT

Postby richiewu » Thu Jul 18, 2013 12:48 pm

I have a problem about using OVERLAY:

suppose one sequential flat file:
0001 1 +100.70
0002 1 +120.13
0001 2 +600.80
0001 1 +100.20
0002 2 +500.10

I need sort with unique result, if the 6th byte is 1, then change the amount sign as "+", else if 6th byte is 2, then change as "-"

here is my JCL
//SYSIN    DD *                                     
 INREC IFTHEN=(WHEN=INIT,                           
     OVERLAY=(8:8,7,SFF,TO=ZD)),                     
       IFTHEN=(WHEN=(6,1,CH,EQ,C'1'),               
     OVERLAY=(8:7,2,ZD,MUL,-1)),                     
       IFTHEN=(WHEN=(6,1,CH,EQ,C'2'),               
     OVERLAY=(8:7,2,ZD,MUL,1))                       
 SORT FIELDS=(1,6,CH,A)                             
 SUM FIELDS=(8,7,ZD)                                 
 OUTREC OVERLAY=(8:8,7,ZD,EDIT=(SIIT.TT),SIGNS=(+,-))
/*                                                   


But got abend, how to use OVERLAY to override amount sign?

Thanks,
Ricky
richiewu
 
Posts: 9
Joined: Mon Jul 12, 2010 8:10 am
Has thanked: 2 times
Been thanked: 0 time

Re: Need help about overlay of DFSORT

Postby NicC » Thu Jul 18, 2013 4:48 pm

What abend?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Need help about overlay of DFSORT

Postby skolusu » Thu Jul 18, 2013 11:00 pm

richiewu wrote:I need sort with unique result, if the 6th byte is 1, then change the amount sign as "+", else if 6th byte is 2, then change as "-"


You seem to do the opposite of what you described. As for the abend you need to realize that your INIT statement has already modified the numeric edited item and now the sign on the last byte. Your Next statement is trying to multiply just 2 bytes from position 8 and since you did not have a format/length, DFSORT will create a 16 byte FS(leading spaces and sign at the end) output value from the arithmetic operation. So you need to provide the format and length.

Use the following DFSORT JCL which will give you the desired results. Also you need to remember that you might have an overflow

//STEP0100 EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                       
----+----1----+----2----+----3----+----4----+----5----+----6----+----7-
0001 1 +100.70                                                         
0002 1 +120.13                                                         
0001 2 +600.80                                                         
0001 1 +100.20                                                         
0002 2 +500.10                                                         
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(8:8,7,SFF,TO=ZD)),                 
  IFTHEN=(WHEN=(6,1,CH,EQ,C'2'),OVERLAY=(8:8,7,ZD,MUL,-1,ZD,LENGTH=7))
  SORT FIELDS=(1,6,CH,A)                                               
  SUM FIELDS=(8,7,ZD)                                                 
  OUTREC OVERLAY=(8:8,7,ZD,EDIT=(SIIT.TT),SIGNS=(+,-))                 
//*


The output from this job is
0001 1 +200.90
0001 2 -600.80
0002 1 +120.13
0002 2 -500.10


If that is not what you want you need to explain the rules with a sample of input and desired output.
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

These users thanked the author skolusu for the post:
richiewu (Fri Jul 19, 2013 3:09 pm)
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: Need help about overlay of DFSORT

Postby richiewu » Fri Jul 19, 2013 3:10 pm

skolusu wrote:
richiewu wrote:I need sort with unique result, if the 6th byte is 1, then change the amount sign as "+", else if 6th byte is 2, then change as "-"


You seem to do the opposite of what you described. As for the abend you need to realize that your INIT statement has already modified the numeric edited item and now the sign on the last byte. Your Next statement is trying to multiply just 2 bytes from position 8 and since you did not have a format/length, DFSORT will create a 16 byte FS(leading spaces and sign at the end) output value from the arithmetic operation. So you need to provide the format and length.

Use the following DFSORT JCL which will give you the desired results. Also you need to remember that you might have an overflow



Thanks,

I found the way yesterday:
//SYSIN    DD *                                     
 INREC IFTHEN=(WHEN=INIT,                           
     OVERLAY=(8:8,7,SFF,TO=PD,LENGTH=7)),           
       IFTHEN=(WHEN=(6,1,CH,EQ,C'2'),               
     OVERLAY=(8:8,7,PD,MUL,-1,TO=PD,LENGTH=7))       
 SORT FIELDS=(1,6,CH,A)                             
 SUM FIELDS=(8,7,PD)                                 
 OUTREC OVERLAY=(8:8,7,PD,EDIT=(SIIT.TT),SIGNS=(+,-))
/*                                                   


How can I avoid overflow if the actual data is S9(15)V99 COMP-3?
richiewu
 
Posts: 9
Joined: Mon Jul 12, 2010 8:10 am
Has thanked: 2 times
Been thanked: 0 time

Re: Need help about overlay of DFSORT

Postby BillyBoyo » Fri Jul 19, 2013 6:42 pm

If you have 17 decimal digits, your LENGTH= should be 9. If you want to avoid overflow in the SUM, what is the maximum value you expect to have as a total per key? If you want more than five digits on your OUTREC, you need to make the EDIT long enough so that there is an I or a T to represent every digit you want in the output.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post