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
 

 

Merge 2 files using DFSORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
guptah

New User


Joined: 08 Apr 2008
Posts: 5
Location: Gurgaon

PostPosted: Mon Jun 09, 2008 10:21 pm    Post subject: Merge 2 files using DFSORT
Reply with quote

My requirement is:

I have two files
File 1 - It has four fields with lengths of 6,8,3,1 byte respectively
A1 A2 A3 A4
00000100000001001R
File 2 (similar to File 1)

Merge these two files and create a new file with Header & Trailer Record in it.
Merging these 2 records is easy but i don't know how can i put header & trailer into the file as the input file doesn't contain any header.

Header record will have:
Low Values in first 14 bytes.
Some hard coded value in next 10 bytes
Another hard coded value in next 1 byte
Date of 8 bytes (numeric). This field should come from a file which stores date in first 8 bytes in PD format.

Trailer record will have:
High values in first 14 bytes.
Some hard coded value in next 10 bytes
Another hard coded value in next 1 byte
Record count in next 10 bytes.

ICETOOL can be used to put Header and trailer but i am not too sure how to use it.

Can anybody help me in this?

Regards,
M
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 Jun 09, 2008 10:57 pm    Post subject:
Reply with quote

Quote:
Date of 8 bytes (numeric). This field should come from a file which stores date in first 8 bytes in PD format.


You can use that record to create a symbol for TDATE as follows:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  file with date
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  INREC BUILD=(C'TDATE,''',1,8,C'''',80:X)
/*


Then you can use this Symbol in your merge step for the date by including this DD statement:

//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)

You can use DFSORT's OUTFIL statement with HEADER1 for the header and TRAILER1 for the trailer. For example:

Code:

    OUTFIL HEADER1=(14X'00',C'cccccccccc'c',TDATE),             
      TRAILER1=(14X'00',C'cccccccccc',C'c',COUNT=(M11,LENGTH=10))


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html
Back to top
View user's profile Send private message
guptah

New User


Joined: 08 Apr 2008
Posts: 5
Location: Gurgaon

PostPosted: Tue Jun 10, 2008 12:06 am    Post subject: Reply to: Merge 2 files using DFSORT
Reply with quote

Hi Frank,

Thanks for your answer.

So the complete solution i can say will look somethng like:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  file with date
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  INREC BUILD=(C'TDATE,''',1,8,C'''',80:X)
/*

//S2 EXEC PGM=SORT
//SYSOUT    DD  SYSOUT=*
/SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=....file 1
//             DD DSN=.....file2
//SORTOUT DD DSN=Output file,UNIT=SYSDA,SPCE=(CYL(1,1)),DISP=(NEW,CATLG,DELETE),LERECL=40 etc.
//SYSIN DD *
   SORT FIELDS = (1,6,CH,A,7,8,CH,A,15,3,CH,A) - To sort o/p file on       Key
  OUTFIL HEADER1=(14X'00',C'cccccccccc',C'c',TDATE),             
           TRAILER1=(14X'00',C'cccccccccc',C'c',COUNT=(M11,LENGTH=10))
/*


Please correct me if i am wrong.
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: Tue Jun 10, 2008 12:41 am    Post subject:
Reply with quote

Well, you're close but you have some errors. The job would be:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  file with date
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY
  INREC BUILD=(C'TDATE,''',1,8,C'''',80:X)
/*
//S2 EXEC PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=....file1
//       DD DSN=....file2
//SORTOUT DD DSN=outputfile,UNIT=SYSDA,SPACE=(CYL,(1,1)),
//  DISP=(NEW,CATLG,DELETE)
//SYSIN DD *
  SORT FIELDS=(1,6,CH,A,7,8,CH,A,15,3,CH,A)
  OUTFIL HEADER1=(14X'00',C'cccccccccc',C'c',TDATE),
         TRAILER1=(14X'00',C'cccccccccc',C'c',COUNT=(M11,LENGTH=10))
/*
Back to top
View user's profile Send private message
guptah

New User


Joined: 08 Apr 2008
Posts: 5
Location: Gurgaon

PostPosted: Tue Jun 10, 2008 12:29 pm    Post subject: Reply to: Merge 2 files using DFSORT
Reply with quote

Hi Frank,

I did run the Job,its running fine with few exceptions.
the Date on the Header is still coming in PD format but i want it in NUmeric displayable format. I am doing anything wrong here?

Here is the header record i am getting:

Code:
1              GCCEDTRIGRR  Ø <         
F00000000000000CCCCCEDCCDD00834444444444
100000000000000733543997992001C000000000
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: Tue Jun 10, 2008 8:48 pm    Post subject:
Reply with quote

Quote:
the Date on the Header is still coming in PD format but i want it in NUmeric displayable format.


I took the following statement in your first post to mean you wanted it in PD format

Quote:
Date of 8 bytes (numeric). This field should come from a file which stores date in first 8 bytes in PD format.


PD is "numeric". Do you mean you want it in ZD format? If so, then just change the INREC statement to:

Code:

  INREC BUILD=(C'TDATE,''',1,8,PD,TO=ZD,LENGTH=n,C'''',80:X)


where n is the length you want for the ZD date field.
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts getting three output files out of JOI... migusd SYNCSORT 7 Mon Jun 05, 2017 11:30 pm
No new posts Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Dynamic split of files under groups sril.krishy DFSORT/ICETOOL 4 Mon Apr 17, 2017 1:09 pm
No new posts DFSORT - Overriding default option TU... Steve Ironmonger DFSORT/ICETOOL 3 Tue Apr 04, 2017 3:54 pm


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