IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Merge 2 files using DFSORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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 Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Jun 09, 2008 10:57 pm
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:

Use [URL] BBCode for External Links
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
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 Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Jun 10, 2008 12:41 am
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
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 Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Jun 10, 2008 8:48 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top