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

Passing data through records


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
spradeepece

New User


Joined: 25 Jun 2008
Posts: 19
Location: Chennai

PostPosted: Mon May 03, 2010 2:32 pm
Reply with quote

Hi,

Is is possible to carry over values from previous record to current record, using Sort? For example, I have a condition where based on a field value, another field in previous record should be copied to the current record.

For instance, if column 5 in the input file reads 'R', data in column 1 to 3 should be carried over to the next line.

Input File (FB/5)

Code:
AAA 
123 R
    R
BBB 
CCC 
DDD 
EEE R
    R


Output File (FB/5)

Code:
AAA 
AAA R
AAA R
BBB 
CCC 
DDD 
DDD R
DDD R
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Mon May 03, 2010 3:42 pm
Reply with quote

Just a bit of confusion....

for first case ...AAA is carried over and not 123

But in second case...DDD(char associated with R) is carried over
Back to top
View user's profile Send private message
spradeepece

New User


Joined: 25 Jun 2008
Posts: 19
Location: Chennai

PostPosted: Mon May 03, 2010 3:57 pm
Reply with quote

Yes.

For 123, the previous record - AAA is carried over. For the third record (spaces) AAA will 'NOW' be the previous record. Hence AAA is carried over.

DDD in input file is not associated with R. Here again, 'EEE' and 'Spaces' were 'Overlayed' with the 'DDD'.

In other words.. Until the next occurence of non-R character (here Space) in Column 5, the data (with a non-R character in Column 5) should be repeated.

Thanks..
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Mon May 03, 2010 6:50 pm
Reply with quote

Sorry.. I think, I confused you.. .
Here is DFSORT sortstep will give you desired result
Code:

//S1    EXEC  PGM=SORT                                         
//SYSOUT    DD  SYSOUT=*                                       
//SORTIN DD *                                                 
AAA                                                           
123 R                                                         
    R                                                         
BBB                                                           
CCC                                                           
DDD                                                           
EEE R                                                         
    R                                                         
/*                                                             
//SORTOUT DD SYSOUT=*                                         
//SYSIN    DD    *                                             
  OPTION COPY                                                 
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(5,1,CH,EQ,C' '),PUSH=(6:1,3))
  OUTFIL BUILD=(6,3,4,2)                                       


Output will be
Code:

AAA 
AAA R
AAA R
BBB 
CCC 
DDD 
DDD R
DDD R
Back to top
View user's profile Send private message
spradeepece

New User


Joined: 25 Jun 2008
Posts: 19
Location: Chennai

PostPosted: Mon May 03, 2010 9:31 pm
Reply with quote

Thanks a lot Sambhaji,

This was perfect..
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Mon May 03, 2010 9:55 pm
Reply with quote

spradeepece wrote:
Thanks a lot Sambhaji,

This was perfect..

Am glad it helped.. icon_smile.gif
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: Mon May 03, 2010 11:06 pm
Reply with quote

sambhaji,

Just curious - why did you use both INREC and OUTFIL when you could just use INREC?

Code:

  OPTION COPY                                                 
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(5,1,CH,EQ,C' '),PUSH=(6:1,3)),
    IFTHEN=(WHEN=INIT,BUILD=(6,3,4,2)) 
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Mon May 03, 2010 11:14 pm
Reply with quote

Frank Yaeger wrote:
sambhaji,
Just curious - why did you use both INREC and OUTFIL when you could just use INREC?


Hmmm... Actually yeah...
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Store the data for fixed length COBOL Programming 1
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top