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
 

 

Complex Merge Logic.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
vissubhai

New User


Joined: 07 Nov 2007
Posts: 12
Location: Hyderabad

PostPosted: Sat Nov 24, 2007 7:22 am    Post subject: Complex Merge Logic.
Reply with quote

Hi All,

I have two input flat files of record length 625. Each file contain more than a million records. Each record contain two fields. The Record-Type which is of 1 byte and Data-Description which is of 624 bytes

Now I need to merge these two files based on the following criteria:
1. If record-type is 0, it is the file header. The output file should contain only one file header.
2. If record-type is 1, it is the merchant header. The output file should contain only one merchant header.
3.If the record-type is 2, it is the merchant data record. The output should the merged records from files 1 and 2.
4.If the record-type is 3, it is the merchant trailer record. The ouput file should only one merchant trailer by adding the counts present in the two files.
5.If record-type is 9, it is the file trailer. The output file should contain only one file trailer.

Let me provide you the sample inputs and output:

File1
0ABCDEFGHIJKLMN
1
2000123456789012
2000123456789013
2000123456789015
3123
9

File2
0ABCDEFGHIJK
1
2000123456789012
2000123456789013
2000123456789018
2000123456789019
3200
9

Output File
0ABCDEFGHIJKLMN
1
2000123456789012
2000123456789012
2000123456789013
2000123456789013
2000123456789015
2000123456789018
2000123456789019
3323
9


Guess I am clear with the requirements.


Viswanath.
Back to top
View user's profile Send private message

krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Sat Nov 24, 2007 12:30 pm    Post subject:
Reply with quote

You could use this SORT JCL if you dont need the records starting with 2 to be sorted as you have shown in your o/p/.
Code:
//*******************************************************
//STEP001  EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                         
0ABCDEFGHIJKLMN                                         
1                                                       
2000123456789012                                         
2000123456789013                                         
2000123456789015                                         
3123                                                     
9                                                       
0ABCDEFGHIJK                                             
1                                                       
2000123456789012                                         
2000123456789013                                         
2000123456789018                                         
2000123456789019                                         
3200                                                     
9                                                       
/*                                                       
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD   *                                               
  OPTION EQUALS                                                 
  OMIT COND=(1,1,ZD,EQ,9)                                       
  INREC  IFTHEN=(WHEN=INIT,OVERLAY(81:SEQNUM,8,ZD,               
                                   90:3C'0')),                   
         IFTHEN=(WHEN=(1,1,ZD,EQ,3),OVERLAY=(81:8X,90:2,3)),     
         IFTHEN=(WHEN=(1,1,ZD,LT,2),OVERLAY=(81:8X))             
  SORT FIELDS=(1,1,CH,A,81,8,CH,A)                               
  SUM FIELDS=(90,3,ZD)                                           
  OUTREC IFTHEN=(WHEN=(1,1,ZD,EQ,3),OVERLAY=(2:90,3)),IFOUTLEN=80
  OUTFIL REMOVECC,TRAILER2=(C'9')                               
/*     


SORTOUT
Code:
0ABCDEFGHIJKLMN
1               
2000123456789012
2000123456789013
2000123456789015
2000123456789012
2000123456789013
2000123456789018
2000123456789019
3323           


If it is a must to have the records starting with 2 to be exactly as you have shown please confirm.
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: Sat Nov 24, 2007 9:38 pm    Post subject:
Reply with quote

Viswanath,

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file2 (FB/625)
//SYM DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY                                     
  OUTFIL FNAMES=SYM,INCLUDE=(1,1,CH,EQ,C'3'),     
    BUILD=(C'T3_CT,+',2,3,80:X)                   
  OUTFIL FNAMES=T2,INCLUDE=(1,1,CH,EQ,C'2')       
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN01 DD DSN=...  input file1 (FB/625)
//SORTIN02 DD DSN=&&T2,DISP=(OLD,PASS)
//SORTOUT DD DSN=..    output file (FB/625)
//SYSIN    DD    *
  OPTION EQUALS
  MERGE FIELDS=(1,625,CH,A)
  OUTREC IFTHEN=(WHEN=(1,1,CH,EQ,C'3'),
    OVERLAY=(2:2,3,ZD,ADD,T3_CT,EDIT=(TTT)))
/*


The SORTOUT data set for step S2 would have:

Code:

0ABCDEFGHIJKLMN         
1                       
2000123456789012         
2000123456789012         
2000123456789013         
2000123456789013         
2000123456789015         
2000123456789018         
2000123456789019         
3323                     
9                       
Back to top
View user's profile Send private message
vissubhai

New User


Joined: 07 Nov 2007
Posts: 12
Location: Hyderabad

PostPosted: Mon Nov 26, 2007 12:38 pm    Post subject:
Reply with quote

Thanks krisprems and Frank. Your information is very valuable.

Frank,

I am getting the following syntax error while running your job.

WER268A OUTREC STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE

The syntax error is at the ADD,T3_CT in the OUTREC statement.
I guess the above job does not work for syncsort. icon_sad.gif
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Mon Nov 26, 2007 12:42 pm    Post subject:
Reply with quote

vissubhai,

The solution suggested by Frank is a DFSORT one and your shop has SYNCSORT.
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Mon Nov 26, 2007 8:36 pm    Post subject:
Reply with quote

vissubhai,
Can you provide the complete SYSOUT information?
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 500
Location: USA

PostPosted: Thu Nov 29, 2007 1:54 am    Post subject:
Reply with quote

Viswanath,

Frank's solution should work if you are running SyncSort for z/OS 1.2.1.0 or later.
If you would like further assistance, please post the complete SyncSort message output.
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
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 To Merge mutliple records into a sing... anandgbe DFSORT/ICETOOL 6 Wed Feb 22, 2017 8:49 am
No new posts Need help in building a logic Benchwarmer All Other Mainframe Topics 4 Wed Feb 22, 2017 2:49 am
No new posts Wildcard logic in COBOL dudenithy COBOL Programming 13 Thu Sep 01, 2016 7:36 pm
No new posts SQL Merge error -254 Robin Sulsona DB2 8 Wed Jun 01, 2016 8:28 pm


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