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

Complex Merge Logic.


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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
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 Developer


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

PostPosted: Sat Nov 24, 2007 9:38 pm
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
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: 1436
Location: Bangalore,India

PostPosted: Mon Nov 26, 2007 12:42 pm
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
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: 496
Location: USA

PostPosted: Thu Nov 29, 2007 1:54 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
This topic is locked: you cannot edit posts or make replies. Merge 2 input files based on the reco... JCL & VSAM 2
No new posts Merge 2 input files after sort SYNCSORT 14
No new posts Finding faulty logic Subscript out of... COBOL Programming 5
No new posts Merge files with a key and insert a b... DFSORT/ICETOOL 6
Search our Forums:

Back to Top