Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Help reqd in formatting a Record based on previous record

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Help reqd in formatting a Record based on previous record
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    Post subject:
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    Post subject: Reply to: Help reqd in formatting a Record based on previous
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    Post subject: Reply to: Help reqd in formatting a Record based on previous
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to get previous month in SYMNAMES Suganya87 SYNCSORT 9 Fri Oct 28, 2016 1:37 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us