MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Retain previous record values into subsequent record

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
nbdtrjk1
Beginner


Joined: 12 Apr 2007
Posts: 76
Topics: 41

PostPosted: Wed Dec 14, 2011 2:51 am    Post subject: Retain previous record values into subsequent record Reply with quote

Hi all,

I have a requirement to copy particular values from previous record into subsequent records. File format is VB & 600 Recl.

Input(3,3 is Key value(100 & 200) and 6,2 is state values(13 & 58 ) copy into subsequent records).
Code:
A110013X1
B1100X2
C1100X3
A120058AAAAAAA
B1200A2
B2200A2
C1200B3

Output
Code:
A110013X1
B110013X2
C110013X3
A120058AAAAAAA
B120058A2
B220058A2
C120058B3


I want to do it using sort/ICETOOL. Please provide your assistence
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12368
Topics: 75
Location: San Jose

PostPosted: Wed Dec 14, 2011 11:41 am    Post subject: Reply with quote

nbdtrjk1,

You do realize that your output length will be increased by 2 bytes? Use the following DFSORT JCL which will give you the desired results
Code:

//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD DSN=&&VB,DISP=SHR                               
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                               
  SORT FIELDS=COPY                                             
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,5X,5)),                   
  IFTHEN=(WHEN=GROUP,PUSH=(5:12,5),                           
  BEGIN=(12,3,SS,EQ,C'100,200',AND,15,2,SS,EQ,C'13,58')),     
  IFTHEN=(WHEN=(5,5,CH,EQ,12,5,CH),BUILD=(1,4,10)),           
  IFTHEN=(WHEN=((5,3,CH,EQ,12,3,CH),AND,15,2,CH,NE,8,2,CH),   
  BUILD=(1,4,10,5,8,2,15)),                                   
  IFTHEN=(WHEN=NONE,BUILD=(1,4,10))                           
//*

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nbdtrjk1
Beginner


Joined: 12 Apr 2007
Posts: 76
Topics: 41

PostPosted: Thu Dec 15, 2011 12:20 am    Post subject: Reply with quote

Kolusu,

The values what ever I said Like 13,58,100 and 200. I have millions of values like this. Kind of Situation how to handle?.

Your code looks hard coded values rather than dynamiclly checking previous row values.


Thanks
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12368
Topics: 75
Location: San Jose

PostPosted: Thu Dec 15, 2011 11:31 am    Post subject: Reply with quote

nbdtrjk1,

How do you recognize the start of the key? is it the first record of the Key(3,3) ??
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nbdtrjk1
Beginner


Joined: 12 Apr 2007
Posts: 76
Topics: 41

PostPosted: Mon Dec 19, 2011 11:54 pm    Post subject: Reply with quote

You are right. Always my keys present in 3,3
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12368
Topics: 75
Location: San Jose

PostPosted: Tue Dec 20, 2011 1:10 pm    Post subject: Reply with quote

nbdtrjk1,


Use the following DFSORT control cards which will give you the desired results
Code:

//SYSIN    DD *                                           
  SORT FIELDS=COPY                                         
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,10X,5)),             
  IFTHEN=(WHEN=GROUP,KEYBEGIN=(17,3),PUSH=(5:SEQ=8,20,2)),
  IFTHEN=(WHEN=(5,8,ZD,EQ,1),BUILD=(1,4,15)),             
  IFTHEN=(WHEN=NONE,BUILD=(1,4,15,5,13,2,20))             
//*

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nbdtrjk1
Beginner


Joined: 12 Apr 2007
Posts: 76
Topics: 41

PostPosted: Thu Dec 22, 2011 12:38 am    Post subject: Reply with quote

Thanks kolusu..Working fine
Back to top
View user's profile Send private message
tcurrier
Intermediate


Joined: 10 Feb 2006
Posts: 188
Topics: 68

PostPosted: Thu Jan 26, 2012 7:29 am    Post subject: retaining previous values when putting out new detail line Reply with quote

Along the lines of retaining previous values, would it be possible to reformat a report into detail lines that contain a date value appended to the front of the detail line? Here is my example:

Code:
INPUT:                                   
                                         
FRUIT INVENTORY PRODUCED ON: 01-25-12   
                                         
APPLES    20                             
PEARS     15                             
ORANGES   35                             
                                         
FRUIT INVENTORY PRODUCED ON: 01-17-12   
                                         
APPLES    27                             
PEARS     34                             
ORANGES   42                 

OUTPUT:            (Date to be reformatted to YYMMDD for sorting purposes)
                   
120125 APPLES    20
120125 PEARS     15
120125 ORANGES   35
120117 APPLES    27
120117 PEARS     34
120117 ORANGES   42


Thanks.
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Jan 26, 2012 12:35 pm    Post subject: Reply with quote

You can use a DFSORT job like the following to do what you asked for:

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
FRUIT INVENTORY PRODUCED ON: 01-25-12

APPLES    20
PEARS     15
ORANGES   35

FRUIT INVENTORY PRODUCED ON: 01-17-12

APPLES    27
PEARS     34
ORANGES   42
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  OPTION COPY
  OMIT COND=(1,8,CH,EQ,C' ')
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,15,CH,EQ,C'FRUIT INVENTORY'),
    PUSH=(81:30,8))
  OUTFIL OMIT=(1,15,CH,EQ,C'FRUIT INVENTORY'),
    BUILD=(87,2,81,2,84,2,X,1,80)
/*

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group