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

Help reqd in formatting a Record based on previous record


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

Active User


Joined: 05 Jun 2009
Posts: 185
Location: Planet Earth

PostPosted: Mon Aug 24, 2009 6:54 pm
Reply with quote

I have an input file which has many columns. I want to copy the records from my input file into an output file with a extra column (say col 2).

Col 2 should have the value 1 if the content of one particular column (say col 1) in that record is not equal to col1 of the previous record.
Col 2 should have the value one greater than col 2 of the previous record, if col 1 of this record matches with that of the previous record.

For instance, assume the following example,
Input Records :
A
B
C
C
B
D
E
E
E
B
E
A
D

Desired Output Records :

A1
B1
C1
C2
B1
D1
E1
E2
E3
B1
E1
A1
D1

As the above example shows, the col 2 value need not continue and have to restart when the col 1 repeats after a break. Its only when the previous and the current value of col 1 matches, col 2 has to increase.

Please note - I do not want a SORT to be done on the input records.. I only want a COPY..

I actually had couple of more activities to be done on the same input file like replacing certain strings with a different strings and conditional formatting based on the current record's value. But I already found ways to do that by using CHANGE/NOMATCH and IFTHEN resply. Despite trying to read DFSORT manual twice, I couldn't find which command can help me to match with the previous record.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Mon Aug 24, 2009 9:15 pm
Reply with quote

rockish,

Use the following DFSORT JCL

Code:

//STEP0100 EXEC PGM=SORT                       
//SYSOUT   DD SYSOUT=*                         
//SORTIN   DD *                               
A                                             
B                                             
C                                             
C                                             
B                                             
D                                             
E                                             
E                                             
E                                             
B                                             
E                                             
A                                             
D                                             
//SORTOUT  DD SYSOUT=*                         
//SYSIN    DD *                               
  SORT FIELDS=COPY                             
  INREC OVERLAY=(2:SEQNUM,1,ZD,RESTART=(1,1)) 
/*
Back to top
View user's profile Send private message
rockish

Active User


Joined: 05 Jun 2009
Posts: 185
Location: Planet Earth

PostPosted: Tue Aug 25, 2009 1:49 am
Reply with quote

Thanks a lot for your response Skolusu. It worked !!!!

Now I have a doubt. I also have one more thing to do. I need to omit all the records which repeats more than 5 times continuously. That is the no records with the sequence number greater than 5 should be in the output file.

I was in the assumption that OMIT COND will act on the INREC output. But just realised that OMIT acts on the input record. Hence if I give OMIT on the position of the sequence number, I am getting error message !!!!

ICE027A 2 END OF FIELD BEYOND MAXIMUM RECORD LENGTH

Can you please help me in finding out how to omit the record numbers beyond a particular sequence number ???
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Aug 25, 2009 2:49 am
Reply with quote

Use the following JCL. This appends the 2 byte seqnum in pos 10 and we drop the records where the sequence number is greater than 5. Look at the E record which is repeated 6 times

Code:

//STEP0100 EXEC PGM=SORT                     
//SYSOUT   DD SYSOUT=*                       
//SORTIN   DD *                               
A KEEP                                       
B KEEP                                       
C KEEP                                       
C KEEP                                       
B KEEP                                       
D KEEP                                       
E KEEP                                       
E KEEP                                       
E KEEP                                       
E KEEP                                       
E KEEP                                       
E DROP                                       
B KEEP                                       
E KEEP                                       
A KEEP                                       
D KEEP                                       
//SORTOUT  DD SYSOUT=*                       
//SYSIN    DD *                               
  SORT FIELDS=COPY                           
  INREC OVERLAY=(10:SEQNUM,2,ZD,RESTART=(1,1))
  OUTFIL OMIT=(10,2,ZD,GT,5)                 
/*                                           
Back to top
View user's profile Send private message
rockish

Active User


Joined: 05 Jun 2009
Posts: 185
Location: Planet Earth

PostPosted: Tue Aug 25, 2009 3:06 am
Reply with quote

Thanks Kolusu icon_smile.gif

That solved my problem...
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 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 To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top