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 copying data without knowing location arunsoods DFSORT/ICETOOL 6 Thu Jul 20, 2017 1:03 pm
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 18 Thu Jul 13, 2017 2:11 pm
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts NDM syntax checking without actually ... GAPX1 All Other Mainframe Topics 0 Wed Jun 07, 2017 2:36 am


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