Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Merging 2 records at multiple rows wi... Bijesh DFSORT/ICETOOL 2 Wed Dec 06, 2017 1:50 am
No new posts Extract record for change in combinat... Trinadh DFSORT/ICETOOL 6 Thu Nov 23, 2017 3:32 pm
No new posts Fetching data from JHS as per the cur... arunsoods All Other Mainframe Topics 4 Wed Nov 22, 2017 1:54 pm
No new posts Extract Record using range of Data scorp_rahul23 DFSORT/ICETOOL 3 Wed Nov 15, 2017 11:54 pm
No new posts Increment number for every group of r... srajendran2 DFSORT/ICETOOL 7 Thu Nov 09, 2017 10:31 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us