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 

Add header-records into a data-file

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


Joined: 25 Mar 2007
Posts: 11
Topics: 4
Location: Switzerland

PostPosted: Tue Feb 03, 2009 12:46 pm    Post subject: Add header-records into a data-file Reply with quote

Hi all,

I'm trying to merge 2 files.
The first file is a header-file, the second is a data-file.
In both files are the first four character the group-identification (Id)

Header-file:
Code:

0001 headertext1
0003 headertext1
0003 headertext2
0003 headertext3
0005 headertext1
0005 headertext2
0006 headertext1
0007 headertext1
9999 headertext-default

I have for each group-identification 0-n headertexts
Not each group-identification must be have a headertext. (we have one headertext-default)

Data-file:
Code:

0001 data
0001 data
0002 data
0002 data
0002 data
0003 data
0003 data
0003 data
0004 data
0004 data
0005 data
0007 data
0007 data
0007 data
0007 data
0008 data
0008 data
0008 data
0009 data
0010 data
0010 data

Not each group-identification must be have datas.

Output should be:
Code:

0001 headertext1
0001 data
0001 data
0002 headertext-default
0002 data
0002 data
0002 data
0003 headertext1
0003 headertext2
0003 headertext3
0003 data
0003 data
0003 data
0004 headertext-default
0004 data
0004 data
0005 headertext1
0005 headertext2
0005 data
0007 headertext1
0007 data
0007 data
0007 data
0007 data
0008 headertext-default
0008 data
0008 data
0008 data
0009 headertext-default
0009 data
0010 headertext-default
0010 data
0010 data

If the data-group (same ID) has no header then i need the default text (but with the same ID as the data-text).


Is this possible with dfsort or icetool?


thank you very much in advance

hungerbuehler[/list]
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Feb 03, 2009 1:31 pm    Post subject: Reply with quote

hungerbuehler,

What is the LRECL and RECFM of both the files?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
hungerbuehler
Beginner


Joined: 25 Mar 2007
Posts: 11
Topics: 4
Location: Switzerland

PostPosted: Tue Feb 03, 2009 2:16 pm    Post subject: Reply with quote

Hi kolusu,

Both files (header-file and data-file) have the RECFM=FB and the LRECL=80

many thanks.

Best regards
Daniel Hungerbuehler
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Feb 03, 2009 4:17 pm    Post subject: Reply with quote

hungerbuehler,

The following DFSORT JCL will give you the desired results. I assumed that the header records can be identified with word 'head' in pos 6 in the header record file. I used the WHEN=GROUP function of DFSORT available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) in step0200. If you don't have the July, 2008 PTF installed, ask your System Programmer to install it (it's free).

For complete details on the new WHEN=GROUP and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/


Code:

//STEP0100 EXEC PGM=ICEMAN     
//SYSOUT   DD SYSOUT=*         
//SORTIN   DD DSN=your 80 byte header file,
//            DISP=SHR
//         DD DSN=your 80 byte data file,
//            DISP=SHR
//SORTOUT  DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *                                           
  OPTION EQUALS                                           
  SORT FIELDS=(1,4,CH,A)                                 
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'00')),           
  IFTHEN=(WHEN=(6,4,CH,EQ,C'HEAD'),OVERLAY=(81:C'1')),   
  IFTHEN=(WHEN=NONE,OVERLAY=(82:C'1'))                   
  OUTFIL BUILD=(1,80,16X),REMOVECC,                       
  SECTIONS=(1,4,                                         
  TRAILER3=(1,4,' HEADERTEXT-DEFAULT',                   
            81:TOT=(81,1,ZD,M11,LENGTH=8),               
            89:TOT=(82,1,ZD,M11,LENGTH=8)))               
//*
//STEP0200 EXEC PGM=ICEMAN                                         
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD DSN=&&T1,DISP=SHR                                     
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  OMIT COND=(81,8,ZD,GE,1,AND,89,8,ZD,GT,0)                         
  OPTION EQUALS                                                     
  SORT FIELDS=(1,4,CH,A,81,16,CH,D)                                 
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(97:SEQNUM,8,ZD,RESTART=(1,4))),
  IFTHEN=(WHEN=GROUP,BEGIN=(97,8,ZD,EQ,1),PUSH=(81:81,16))         
  OUTFIL OMIT=(89,8,ZD,EQ,0,AND,89,8,CH,NE,C' '),                   
  BUILD=(1,80)                                                     
//*

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


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

PostPosted: Tue Feb 03, 2009 5:00 pm    Post subject: Reply with quote

The following DFSORT JCL will give you the desired results. This job does not require any identification of header. I used the WHEN=GROUP function of DFSORT available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) in step0200. If you don't have the July, 2008 PTF installed, ask your System Programmer to install it (it's free).

For complete details on the new WHEN=GROUP and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/

Code:

//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG  DD SYSOUT=*     
//DFSMSG   DD SYSOUT=*
//HDR      DD DSN=your 80 byte header file,
//            DISP=SHR
//DAT      DD DSN=your 80 byte data file,
//            DISP=SHR       
//T1       DD DSN=&&T1,DISP=(MOD,PASS),SPACE=(CYL,(X,Y),RLSE)       
//OUT      DD SYSOUT=*                                               
//TOOLIN   DD *                                                     
  SORT FROM(HDR) USING(CTL1)                                         
  SORT FROM(DAT) USING(CTL2)                                         
  SORT FROM(T1)  USING(CTL3)
//*                                         
//CTL1CNTL DD *                                                     
  OPTION EQUALS                                                     
  SORT FIELDS=(1,4,CH,A)                                             
  OUTFIL FNAMES=T1,BUILD=(1,80,X,24C'0'),REMOVECC,                   
  SECTIONS=(1,4,                                                     
  TRAILER3=(1,4,81:C'H',8C'0',COUNT=(M11,LENGTH=8),8C'0'))           
//*
//CTL2CNTL DD *                                                     
  OPTION EQUALS                                                     
  SORT FIELDS=(1,4,CH,A)                                             
  OUTFIL FNAMES=T1,BUILD=(1,80,X,24C'0'),REMOVECC,                   
  SECTIONS=(1,4,                                                     
  TRAILER3=(1,4,' HEADERTEXT-DEFAULT',                               
            81:C'H',16C'0',COUNT=(M11,LENGTH=8)))                   
//*
//CTL3CNTL DD *                                                     
  OPTION EQUALS                                                     
  INREC IFTHEN=(WHEN=(81,1,CH,EQ,C' '),OVERLAY=(82:SEQNUM,8,ZD))     
  SORT FIELDS=(1,4,CH,A,82,8,CH,A)                                   
  SUM FIELDS=(90,8,ZD,98,8,ZD)                                       
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(81,1,CH,EQ,C'H'),PUSH=(90:90,16))
  OUTFIL FNAMES=OUT,BUILD=(1,80),                                   
  OMIT=(81,1,CH,EQ,C'H',AND,90,8,ZD,GE,1,OR,                         
        98,8,ZD,EQ,0)                                               
//*

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


Joined: 25 Mar 2007
Posts: 11
Topics: 4
Location: Switzerland

PostPosted: Tue Feb 10, 2009 4:14 am    Post subject: Reply with quote

Hi Kolusu,

Many thanks for your help. It works perfect.

DFSORT and this forum are great!

Best regards
Back to top
View user's profile Send private message
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