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

Difference of values between first & last record in a gr


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

New User


Joined: 14 Aug 2007
Posts: 14
Location: Chennai

PostPosted: Wed Jul 06, 2011 8:46 pm
Reply with quote

Hi

I have a requirement as explained below

There is a flat file of length 150 bytes.

In that file 1 thru 6 position is the identifier field and from 96 thru 103 is the service year field. The file is sorted on identifier ascending and service years descending.

The requirement is to find out the difference between the service years for the first & last record in a group of identifiers.

eq:

Consider the below sample of recs


IDENTIFIER
|CHR 6
|(1:6)
|2
*********** TOP OF DA
XXXX02
XXXX02
XXXX07
XXXX07
XXXX10
XXXX10
XXXX10
XXXX10
XXXX11
XXXX11
XXXX11
XXXX11
XXXX13
XXXX13
U20014
U20014
U20016


|SERVICE YEAR
|PAC 15
|(96:103)
|12
* TOP OF DATA *****
29.00
19.00
12.00
7.00
22.00
9.00
8.00
6.00
54.00
25.00
15.00
12.00
21.00
14.00
19.00
9.00
20.00


For the identifier XXXX10:

The difference should be 22 - 6 = 16

There may be n number of records in a group.

Is there any way to do this using DFsort or ICETOOL?

Regards
Santhosh
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Jul 06, 2011 9:06 pm
Reply with quote

Just few more bits of information needed on your problem,
1: for U20016(Only occurance) - Should it come in output? if yes with what value?

2: What is the version of DFSORT you have installed at your shop...
(To know read this first and reply www.ibmmainframes.com/viewtopic.php?t=33389)

3: Can you show this example with code tag facility used...
Back to top
View user's profile Send private message
sthirumalai

New User


Joined: 14 Aug 2007
Posts: 14
Location: Chennai

PostPosted: Wed Jul 06, 2011 9:12 pm
Reply with quote

Hi Escapa,

Please find my answers below

for

#1.Yes this is a possibility. If there is only one record then the service years of that records should come in the O/P. In the case of U20016 the Service years should be 20.

#2. We use DFSORT V1R12

#3. I am not sure about code tag facility. can you explain bit more on that please?

Regards
Santhosh
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Jul 06, 2011 9:16 pm
Reply with quote

sthirumalai wrote:
Hi Escapa,

#2. We use DFSORT V1R12

#3. I am not sure about code tag facility. can you explain bit more on that please?


#2 -> No. You havnt read link I gave you properly, We want to know PTF level, post complete ICE201I message you are getting.

#3 -> I don't know how to explain this.. Cz.. This is assumed to be one of those common sense thing..
Back to top
View user's profile Send private message
sthirumalai

New User


Joined: 14 Aug 2007
Posts: 14
Location: Chennai

PostPosted: Wed Jul 06, 2011 9:22 pm
Reply with quote

Okay for

#2 ICE201I H RECORD TYPE.

Please let me know if you need more details
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: Wed Jul 06, 2011 10:02 pm
Reply with quote

Hello,

Quote:
#3. I am not sure about code tag facility. can you explain bit more on that please?

Notice that your question has been "Quoted". Next to the Quote Tag is the Code Tag. Highlight data you want the alignment preserved and click Code. Then click Preview to see your post as it will appear to the forum. Then Submit when it looks as you want.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Jul 06, 2011 10:13 pm
Reply with quote

Hi,
bit turbid one, you got to spend some testing on it... I have simulated it for 80 byte record length file...

Code:

//S1    EXEC  PGM=ICETOOL     
//SYSOUT    DD  SYSOUT=*     
//DFSMSG    DD  SYSOUT=*     
//TOOLMSG   DD  SYSOUT=*     
//IN DD *                     
XXXX02     29.00             
XXXX02     19.00             
XXXX07     12.00             
XXXX07     7.00               
XXXX10     22.00             
XXXX10     9.00               
XXXX10     8.00               
XXXX10     6.00               
XXXX11     54.00             
XXXX11     25.00             
XXXX11     15.00             
XXXX11     12.00             
XXXX13     21.00             
XXXX13     14.00             
U20014     19.00             
U20014     9.00                                           
U20016     20.00                                           
/*                                                         
//OUT DD DSN=&&TEMP,DISP=(NEW,PASS)                       
//OUT1 DD SYSOUT=*                                         
//TOOLIN DD *                                             
  SELECT ON(1,6,CH) FROM(IN) TO(OUT) LAST USING(CTL1)     
  COPY   FROM(OUT) TO(OUT1) USING(CTL2)                   
//CTL1CNTL DD *                                           
 OPTION COPY,EQUALS                                       
 INREC IFTHEN=(WHEN=GROUP,                                 
       KEYBEGIN=(1,6),PUSH=(81:12,6,91:SEQ=8)),           
       IFTHEN=(WHEN=INIT,                                 
       OVERLAY=(12:81,6,UFF,SUB,12,6,UFF,EDIT=(IIIT.II))) 
/*                                                         
//CTL2CNTL DD *                                           
 OPTION COPY,EQUALS                                       
 INREC IFTHEN=(WHEN=(91,8,ZD,EQ,1),                       
       OVERLAY=(12:81,6,X))                               
 OUTFIL BUILD=(1,80)                                       


Output will be...
Code:

XXXX02       10.00         
XXXX07        5.00         
XXXX10       16.00         
XXXX11       42.00         
XXXX13        7.00         
U20014       10.00         
U20016     20.00           
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: Thu Jul 07, 2011 3:30 am
Reply with quote

Here's a better way to do it with DFSORT using only one pass and no sorting. I assumed the Service Year was actually a 96,8,PD input field based on the description of PAC 15 (96:103).

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/150)
//SORTOUT DD DSN=...  output file (FB/26)
//SYSIN DD *
  OPTION COPY
  INREC IFOUTLEN=26,
    IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,6),PUSH=(31:96,8,41:SEQ=8)),
    IFTHEN=(WHEN=(41,8,ZD,EQ,1),
      BUILD=(1,6,11:31,8,PD,EDIT=(IIIIIIIIIIIIT.TT))),
    IFTHEN=(WHEN=(41,8,ZD,GT,1),
      BUILD=(1,6,11:31,8,PD,SUB,96,8,PD,
        EDIT=(IIIIIIIIIIIIT.TT)))
  OUTFIL REMOVECC,NODETAIL,
   SECTIONS=(1,6,
    TRAILER3=(1,6,11:11,16))
/*


SORTOUT would have:

Code:

XXXX02               10.00       
XXXX07                5.00       
XXXX10               16.00       
XXXX11               42.00       
XXXX13                7.00       
U20014               10.00       
U20016               20.00       
Back to top
View user's profile Send private message
sthirumalai

New User


Joined: 14 Aug 2007
Posts: 14
Location: Chennai

PostPosted: Fri Jul 08, 2011 2:01 am
Reply with quote

Hi Frank/Escapa/Dick

Thanks for all your help

Frank,Your solution works 100%.

Thanks again

Regards
Santhosh
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top