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
 

 

Passing data through records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Passing data through records
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Mon May 03, 2010 11:06 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts SPUFI -- Joining 3 tables – data in... Sysaron DB2 2 Wed Mar 08, 2017 4:18 am


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