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 

How to save and/or compare information from previous record

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


Joined: 10 Jun 2021
Posts: 1
Topics: 1
Location: USA

PostPosted: Mon Jun 14, 2021 7:01 pm    Post subject: How to save and/or compare information from previous record Reply with quote

I've looked high and low for this example. There are many almost like it, but none that I see hit the mark. I need to process a given record, based on the previous record. I'd like to use DFSORT/ICETOOL for a solution.
I've done quite a lot with DFSORT, but have limited experience with ICETOOL syntax.
I have a file that looks as follows, and for the sake of discussion it's FB, LRECL=80. It is sorted by key and line.
Code:

KEY1LINE1COMDATA1
KEY1LINE2COMDATA2
KEY1LINE3MAEDATA3
KEY2LINE1MAEDATA4
KEY2LINE2MAEDATA5
KEY2LINE3COMDATA6
KEY3LINE1COMDATA7
KEY3LINE2MAEDATA8
KEY3LINE3COMDATA9
KEY4LINE1MAEDATAA
KEY4LINE2COMDATAB 


I'd like the output to be 2 files that look as follows:

Header file:
Code:

KEY1        DATA1
KEY1        DATA2
KEY3        DATA7 


Detail file:
Code:

KEY2LINE2   DATA6
KEY3LINE2   DATA9
KEY4LINE1   DATAB


The rules are, that if the first record of a group (KEY) has a value 'COM' in column 10, then treat the data as 'header' data. All contiguous 'COM' records will also be treated as 'header' data, as shown with the KEY1 value.
If a record is not a COM record, then it may be the start of string of 'line' data, as shown by KEY2-LINE2.

Said another way, all COM records need to be reference the previous non COM record of the same KEY, or be treated as a header record.

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


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

PostPosted: Mon Jun 14, 2021 11:39 pm    Post subject: Reply with quote

gmgsci,

Try this untested DFSORT JCL

Code:

//STEP0100 EXEC PGM=SORT                           
//SYSOUT   DD SYSOUT=*                             
//SORTIN   DD *                                     
KEY1LINE1COMDATA1                                   
KEY1LINE2COMDATA2                                   
KEY1LINE3MAEDATA3                                   
KEY2LINE1MAEDATA4                                   
KEY2LINE2MAEDATA5                                   
KEY2LINE3COMDATA6                                   
KEY3LINE1COMDATA7                                   
KEY3LINE2MAEDATA8                                   
KEY3LINE3COMDATA9                                   
KEY4LINE1MAEDATAA                                   
KEY4LINE2COMDATAB                                   
//OUT1     DD SYSOUT=*                             
//OUT2     DD SYSOUT=*                             
//SYSIN    DD *                                     
  OPTION COPY                                       
  INREC IFTHEN=(WHEN=INIT,                         
             OVERLAY=(81:SEQNUM,4,ZD,RESTART=(01,04))), 
        IFTHEN=(WHEN=GROUP,                         
               BEGIN=(81,04,ZD,EQ,1),               
                PUSH=(86:10,03),RECORDS=2)         
                                                   
  OUTFIL FNAMES=OUT1,                               
  INCLUDE=(86,3,CH,EQ,C'COM',AND,                   
           10,3,CH,EQ,C'COM'),                     
    BUILD=(01,04,7X,13,5)                           
                                                   
  OUTFIL FNAMES=OUT2,                               
  INCLUDE=(86,3,CH,NE,C'COM',AND,                   
           10,3,CH,EQ,C'COM'),                     
    BUILD=(01,09,3X,13,5)                           
/*

_________________
Kolusu
www.linkedin.com/in/kolusu
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