Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Combine 2 Files to produce the following result

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

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Wed Feb 07, 2007 9:20 am    Post subject: Combine 2 Files to produce the following result
Reply with quote

I have 2 files File-1 and File-2.I want to combine these 2 files such as after each 3 lines on File-1 one line from File-2 will be inserted.

e.g.
Code:
 
File-1     File-2            OUTPUT
   A           B                 A
   A           B                 A
   A           B                 A
   A           B                 B
   A                             A
   A                             A
   A                             A
   A                             B
   A                             A .... and so on
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: Wed Feb 07, 2007 9:33 pm    Post subject:
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for. I assumed your input files have RECFM=FB and LRECL=80 but the job can be changed appropriately for other attributes.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD *
F1 RECORD 01
F1 RECORD 02
F1 RECORD 03
F1 RECORD 04
F1 RECORD 05
F1 RECORD 06
F1 RECORD 07
F1 RECORD 08
F1 RECORD 09
F1 RECORD 10
F1 RECORD 11
F1 RECORD 12
F1 RECORD 13
/*
//IN2 DD *
F2 RECORD 01
F2 RECORD 02
F2 RECORD 03
F2 RECORD 04
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//TOOLIN   DD    *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T2) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(81:SEQNUM,8,ZD,START=10,INCR=10)
/*
//CTL2CNTL DD *
  INREC OVERLAY=(81:SEQNUM,8,ZD,START=31,INCR=30)
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN01 DD DSN=&&T1,DISP=(OLD,PASS)
//SORTIN02 DD DSN=&&T2,DISP=(OLD,PASS)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
  MERGE FIELDS=(81,8,ZD,A)
  OUTREC BUILD=(1,80)
/*


SORTOUT would have:

Code:

F1 RECORD 01   
F1 RECORD 02   
F1 RECORD 03   
F2 RECORD 01   
F1 RECORD 04   
F1 RECORD 05   
F1 RECORD 06   
F2 RECORD 02   
F1 RECORD 07   
F1 RECORD 08   
F1 RECORD 09   
F2 RECORD 03   
F1 RECORD 10   
F1 RECORD 11   
F1 RECORD 12   
F2 RECORD 04   
F1 RECORD 13   
Back to top
View user's profile Send private message
hsk

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Thu Feb 08, 2007 1:37 pm    Post subject:
Reply with quote

Thank you,
Looks gr8!!

But how this works and how can i modify it
(e.g. instade of 1 line from file 2 i want to insert 5 lines from file 2!!!)

especially
//CTL1CNTL DD *
INREC OVERLAY=(81:SEQNUM,8,ZD,START=10,INCR=10)

any link/document?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu Feb 08, 2007 2:09 pm    Post subject:
Reply with quote

hsk wrote:
But how this works and how can i modify it
(e.g. instade of 1 line from file 2 i want to insert 5 lines from file 2!!!)
Your previous example has only 4 records in file 2, is there more? Do you mean to have 5 from file 2 inserted after each line from file 1 or after every third line from file 1?
Quote:
especially
//CTL1CNTL DD *
INREC OVERLAY=(81:SEQNUM,8,ZD,START=10,INCR=10)
icon_question.gif
Quote:
any link/document?
DFSORT/ICETOOL Reference Material
Back to top
View user's profile Send private message
hsk

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Thu Feb 08, 2007 3:16 pm    Post subject:
Reply with quote

Yup .....

Just wanted to understand how it is coded, what parameters are specified


Thanks for the link
Back to top
View user's profile Send private message
hsk

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Thu Feb 08, 2007 4:07 pm    Post subject:
Reply with quote

Okey ............
Now i got little idea how it is working!
Insert a seq. number after from position 81...
Increment file 1 by 10 .......... 10,20,30 .........
Increment file 2 by 30 .......... 31,61,91 ..........

Then merge 2 files and take only 80 bytes ..........

Wooooh! Smart way !!!!!

This works gr88888888 .............

But again, how to change it if i want to insert 2 records from file 2 after 3 records from file 1

Output shud look like
Code:

F1 RECORD 01   
F1 RECORD 02   
F1 RECORD 03   
F2 RECORD 01
F2 RECORD 02 
F1 RECORD 04   
F1 RECORD 05   
F1 RECORD 06   
F2 RECORD 03 
F2 RECORD 04 
F1 RECORD 07
............. so on
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu Feb 08, 2007 4:18 pm    Post subject:
Reply with quote

hsk wrote:
But again, how to change it if i want to insert 2 records from file 2 after 3 records from file 1
Can you think of a sequencing method to get you what you want?
Have you looked at the manual and some of the smart sort tricks?
DFSORT/ICETOOL Reference Material
Back to top
View user's profile Send private message
hsk

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Thu Feb 08, 2007 5:12 pm    Post subject:
Reply with quote

Thanks
That helped a looooooooot
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: Thu Feb 08, 2007 9:22 pm    Post subject:
Reply with quote

hsk,

Did you figure it out or do you need more help? If you did figure it out, please post your solution to help others in the future who might look at this topic.
Back to top
View user's profile Send private message
hsk

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Fri Feb 09, 2007 4:38 pm    Post subject:
Reply with quote

Yup ...........
I could make it work ...........
Not sure if this THE BEST solution, rather this not the best solution .....

Following are the details @ my problem and the solution,
Problem:
I have 2 files File1 and File2
Code:

      File1                             File2
F1 RECORD 01      F2 RECORD 01
F1 RECORD 02      F2 RECORD 02
F1 RECORD 03      F2 RECORD 03
F1 RECORD 04      F2 RECORD 04
F1 RECORD 05      F2 RECORD 05
F1 RECORD 06      F2 RECORD 06
F1 RECORD 07      F2 RECORD 07
F1 RECORD 08      F2 RECORD 08
F1 RECORD 09      F2 RECORD 09
F1 RECORD 10      F2 RECORD 10
F1 RECORD 11      F2 RECORD 11
F1 RECORD 12      F2 RECORD 12
F1 RECORD 13      F2 RECORD 13

So on ........


Now i want to insert certain records from file2 in to file1 with specific order. Suppose e.g. i want to insert 5 records from file2 after 3 records from file1.
So output should look like
Code:

  output file
F1 RECORD 01
F1 RECORD 02
F1 RECORD 03
F2 RECORD 01
F2 RECORD 02
F2 RECORD 03
F2 RECORD 04
F2 RECORD 05
F1 RECORD 04
F1 RECORD 05
F1 RECORD 06
F2 RECORD 06
F2 RECORD 07
F2 RECORD 08
F2 RECORD 09
F2 RECORD 10
F1 RECORD 07
F1 RECORD 08
F1 RECORD 09
 so on ........


Solution:
Split File2 in to 5 files such as
Code:


    F1            F2         F3                   F4                F5
F2 RECORD 01      F2 RECORD 02      F2 RECORD 03      F2 RECORD 04      F2 RECORD 05
F2 RECORD 06      F2 RECORD 07      F2 RECORD 08      F2 RECORD 09      F2 RECORD 10
F2 RECORD 11      F2 RECORD 12      F2 RECORD 13      F2 RECORD 14      F2 RECORD 15
F2 RECORD 16      F2 RECORD 17      F2 RECORD 18      F2 RECORD 19      F2 RECORD 20
F2 RECORD 21      F2 RECORD 22      F2 RECORD 23      F2 RECORD 24      F2 RECORD 25
F2 RECORD 26      F2 RECORD 27      F2 RECORD 28      F2 RECORD 29      F2 RECORD 30
so on


Now i add SEQNUM in all files as follows
Increment file 1 by 10 .......... 10,20,30 .........
Increment file F1 by 30 .......... 31,61,91 ..........
Increment file F2 by 30 .......... 32,62,92 ..........
Increment file F3 by 30 .......... 33,63,93 ..........
Increment file F4 by 30 .......... 34,64,94 ..........
Increment file F5 by 30 .......... 35,65,95 ..........

Then merge all 6 files sorted on seqnum ......... it's done!!!!

Here is the jcl i used
Code:

//***** SPLIT FILE2 INTO 5 FILES ************
//S1    EXEC  PGM=ICEMAN                                   
//SYSOUT    DD  SYSOUT=*                                   
//SORTIN DD DISP=SHR,DSN=..............FILE2         
//F1  DD DSN=&&F1,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//F2  DD DSN=&&F2,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//F3  DD DSN=&&F3,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//F4  DD DSN=&&F4,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//F5  DD DSN=&&F5,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//SYSIN DD *                                               
  SORT FIELDS=COPY                                         
  OUTFIL FNAMES=(F1,F2,F3,F4,F5),SPLIT                     
/*                                                         
//******* ADD SEQNUM TO FILES ************
//S2    EXEC  PGM=ICETOOL                                 
//TOOLMSG DD SYSOUT=*                                     
//DFSMSG  DD SYSOUT=*                                     
//IN1 DD  DISP=SHR,DSN= ................. FILE1           
//IN2 DD DSN=&&F1,DISP=(OLD,PASS)                         
//IN3 DD DSN=&&F2,DISP=(OLD,PASS)                         
//IN4 DD DSN=&&F3,DISP=(OLD,PASS)                         
//IN5 DD DSN=&&F4,DISP=(OLD,PASS)                         
//IN6 DD DSN=&&F5,DISP=(OLD,PASS)                         
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//T3 DD DSN=&&T3,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//T4 DD DSN=&&T4,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//T5 DD DSN=&&T5,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//T6 DD DSN=&&T6,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//TOOLIN   DD    *                                       
COPY FROM(IN1) TO(T1) USING(CTL1)                         
COPY FROM(IN2) TO(T2) USING(CTL2)                         
COPY FROM(IN3) TO(T3) USING(CTL3)                         
COPY FROM(IN4) TO(T4) USING(CTL4)                         
COPY FROM(IN5) TO(T5) USING(CTL5)                         
COPY FROM(IN6) TO(T6) USING(CTL6)                         
/*                                               
//CTL1CNTL DD *                                   
   INREC OVERLAY=(81:SEQNUM,8,ZD,START=10,INCR=10)
/*                                               
//CTL2CNTL DD *                                   
   INREC OVERLAY=(81:SEQNUM,8,ZD,START=31,INCR=30)
/*                                               
//CTL3CNTL DD *                                   
   INREC OVERLAY=(81:SEQNUM,8,ZD,START=32,INCR=30)
/*                                               
//CTL4CNTL DD *                                   
   INREC OVERLAY=(81:SEQNUM,8,ZD,START=33,INCR=30)
/*                                               
//CTL5CNTL DD *                                   
   INREC OVERLAY=(81:SEQNUM,8,ZD,START=34,INCR=30)
/*                                               
//CTL6CNTL DD *                                   
   INREC OVERLAY=(81:SEQNUM,8,ZD,START=35,INCR=30)
/*                                               
//******** MERGE ALL FILES **********
//S2    EXEC  PGM=ICEMAN                       
//SYSOUT    DD  SYSOUT=*                       
//SORTIN01 DD DSN=&&T1,DISP=(OLD,PASS)         
//SORTIN02 DD DSN=&&T2,DISP=(OLD,PASS)         
//SORTIN03 DD DSN=&&T3,DISP=(OLD,PASS)         
//SORTIN04 DD DSN=&&T4,DISP=(OLD,PASS)         
//SORTIN05 DD DSN=&&T5,DISP=(OLD,PASS)         
//SORTIN06 DD DSN=&&T6,DISP=(OLD,PASS)         
//SORTOUT DD DSN=................... MERGED OUTPUT FILE
//           DISP=(NEW,CATLG,DELETE),         
//           UNIT=SYSDA,SPACE=(CYL,(5,2),RLSE),
//           DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)
//SYSIN    DD    *                             
  MERGE FIELDS=(81,8,ZD,A)                     
  OUTREC BUILD=(1,80)                         
/*                                             


Though it had worked for me ......... i am still searching for BETTER ALTERNATIVE !!!!
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: Fri Feb 09, 2007 9:59 pm    Post subject:
Reply with quote

This DFSORT/ICETOOL job is a beter alternative. icon_biggrin.gif

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/80)
//IN2 DD DSN=...  input file2 (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT  DD DSN=...  output file (FB/80)
//TOOLIN   DD    *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SORT FROM(T1) TO(OUT) USING(CTL3)
/*
//CTL1CNTL DD *
* Get seqnum as 0, 1, 2, 3, ...
* Divide by +3 to get 0, 0, 0, 1, ...
  INREC OVERLAY=(81:SEQNUM,8,ZD,START=0,
     81:81,8,ZD,DIV,+3,TO=ZD,LENGTH=8)
/*
//CTL2CNTL DD *
* Get seqnum as 0, 1, 2, 3, 4, 5, ...
* Divide by +5 to get 0, 0, 0, 0, 0, 1, ...
  INREC OVERLAY=(81:SEQNUM,8,ZD,START=0,
     81:81,8,ZD,DIV,+5,TO=ZD,LENGTH=8)
/*
//CTL3CNTL DD *
* Sort on divided number with EQUALS.
* The 3 0s from file1 will be followed by the
* 5 0s from file2.  Then the 3 1s from file1 will
* be followed by the 5 1s from file2 and so on.
  OPTION EQUALS
  SORT FIELDS=(81,8,ZD,A)
  OUTREC BUILD=(1,80)
/*


If you don't mind using two steps, you can do a MERGE instead of a SORT which would be more efficient:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/80)
//IN2 DD DSN=...  input file2 (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//TOOLIN   DD    *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T2) USING(CTL2)
/*
//CTL1CNTL DD *
* Get seqnum as 0, 1, 2, 3, ...
* Divide by +3 to get 0, 0, 0, 1, ...
  INREC OVERLAY=(81:SEQNUM,8,ZD,START=0,
     81:81,8,ZD,DIV,+3,TO=ZD,LENGTH=8)
/*
//CTL2CNTL DD *
* Get seqnum as 0, 1, 2, 3, 4, 5, ...
* Divide by +5 to get 0, 0, 0, 0, 0, 1, ...
  INREC OVERLAY=(81:SEQNUM,8,ZD,START=0,
     81:81,8,ZD,DIV,+5,TO=ZD,LENGTH=8)
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN01 DD DSN=&&T1,DISP=(OLD,PASS)
//SORTIN02 DD DSN=&&T2,DISP=(OLD,PASS)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
* Merge on divided number with EQUALS.
* The 3 0s from file1 will be followed by the
* 5 0s from file2.  Then the 3 1s from file1 will
* be followed by the 5 1s from file2 and so on.
  OPTION EQUALS
  MERGE FIELDS=(81,8,ZD,A)
  OUTREC BUILD=(1,80)
/*
Back to top
View user's profile Send private message
hsk

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Mon Feb 12, 2007 9:24 am    Post subject: Re: Combine 2 Files to produce the following result
Reply with quote

Gr888888, i guess this is most generic jcl and can be used for any sort of combination (x records from file1 and y records from file 2......)
I had thought of this seq. i.e. repeating the number 'n' number of times....but was not able to put it in the mathematical terms !!

This is fantastic!!!!!!!!! icon_biggrin.gif
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 Can we combine the rows with same key... V S Amarendra Reddy DB2 12 Fri Dec 01, 2017 10:29 pm
No new posts Compare VSAM files using DFSORT pshongal DFSORT/ICETOOL 5 Thu Nov 23, 2017 10:24 am
No new posts Split files upto certain limit based ... bubbu75 DFSORT/ICETOOL 5 Tue Nov 14, 2017 11:11 pm
No new posts Copy selected columns from 2 input fi... Poha Eater DFSORT/ICETOOL 3 Thu Nov 02, 2017 3:43 pm
No new posts Finding difference between two PS fil... Vignesh Sid SYNCSORT 5 Mon Oct 30, 2017 1:13 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us