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

file combine (variable output length


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
atanwc

New User


Joined: 26 Jul 2006
Posts: 24

PostPosted: Sat Sep 13, 2008 9:02 am
Reply with quote

Hi
I need some help.I want to merge two files. The first 3 bytes are sort key.

File 1
ABC 123
DEF 234

File 2
ABC aaa
ABC bbb
ABC ccc
DEF zzz

Output file
ABC 123 aaa bbb ccc
DEF 234 zzz

I cannot to use SAS or COBOL, but I can use JCL sort or ICETOOL. But I try and it is not working!!! Please help!
Thanks!
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Sep 13, 2008 11:22 am
Reply with quote

Hello,

Quote:
But I try and it is not working!!! Please help!
How can anyone help. . . icon_confused.gif

You joined the forum over 2 years ago and surely have seen how to receive help.

You need to post your jcl and control statements as well as any error messages presented by your test (make sure to include the message ids along with the text). When posting these, use the "Code" tag at the top of the reply panel for readability. When you have entered your post, use Preview so you can see your post the way it will appear to the forum, rather than how it looks in the reply editor. When you are satisfied with how your post looks, Submit.

If your test ran but did not produce the desired results, you need to post the output received.

You need to post any processing rules. For example what if there were a million records with ABC in file 2? What about duplicates in file 1? What if there is a "key" in file 2 that is not in file 1? Anything else you might think of that will prevent some surprise later?
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Sat Sep 13, 2008 3:55 pm
Reply with quote

Hi,

Probably you can try this, I don't have access to mainframe just now so couldn't test but it should work -

Code:
//STEP050  EXEC PGM=ICETOOL,REGION=4096K                             
//TOOLMSG  DD SYSOUT=*                                               
//SSMSG    DD SYSOUT=*                                               
//*                                                                 
//IN   DD DSN=...file1                                                         
//      DD DSN=...file2     
//OUT  DD  DSN=....OUTPUT,                                       
//         DISP=(NEW,CATLG,CATLG),                                   
//         DSORG=PS,                                                 
//         RECFM=FB,                                                 
//         DATACLAS=LARGE,                                           
//         UNIT=SYSDA                                               
//TOOLIN   DD    *                                                   
SPLICE FROM(IN) TO(OUT) ON(1,3,CH) KEEPNODUPS -                     
 WITHEACH WITH(12,3) WITH(16,3) WITH(20,3) WITH(24,3) WITH(28,3) -
 USING(CTL1)   
/*                                                                   
//CTL1CNTL DD *                                                     
  INREC IFOUTLEN=80,                                                 
    IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,3))),       
    IFTHEN=(WHEN=(81,8,ZD,EQ,1),BUILD=(1,3,8:11,3)),                 
    IFTHEN=(WHEN=(81,8,ZD,EQ,2),BUILD=(1,3,12:11,3)),               
    IFTHEN=(WHEN=(81,8,ZD,EQ,3),BUILD=(1,3,16:11,3)),               
    IFTHEN=(WHEN=(81,8,ZD,EQ,4),BUILD=(1,3,20:11,3)),               
    IFTHEN=(WHEN=(81,8,ZD,EQ,5),BUILD=(1,3,24:11,3))                 
    IFTHEN=(WHEN=(81,8,ZD,EQ,6),BUILD=(1,3,28:11,3))                 

/*                                                                   
//SYSPRINT DD  SYSOUT=*                                             
//SYSUDUMP DD  SYSOUT=*                                             
//CEEDUMP  DD  SYSOUT=*     

However,I've restricted the output LRECL to 80.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Sat Sep 13, 2008 3:58 pm
Reply with quote

Please put a "," (comma) after this line of code
Code:
IFTHEN=(WHEN=(81,8,ZD,EQ,5),BUILD=(1,3,24:11,3))                 
anyhow I missed it in previous post.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Sat Sep 13, 2008 10:58 pm
Reply with quote

Anuj.D wrote:
Probably you can try this, I don't have access to mainframe just now so couldn't test but it should work


No the JCL posted by anuj will NOT work. Once you concatenate the 2 datasets your data is not sorted on the key fields and INREC is processed before the SORT,so the sequencing of the records will be wrong.

He is also missing DFSMSG dd statement and you really dont need SYSPRINT, SYSUDUMP & CEEDUMP dd statements

The following DFSORT/ICETOOL JCL will give you the desired results. I assumed that at any time you can have a max of 11 duplicates (1 from file + 10 duplicates from file 2)

Code:

//STEP0100 EXEC PGM=ICETOOL                                 
//TOOLMSG  DD SYSOUT=*                                       
//DFSMSG   DD SYSOUT=*                                       
//IN       DD DSN=your file 1,DISP=SHR
//         DD DSN=your file 2,DISP=SHR                       
//T1       DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)   
//OUT      DD DSN=your output file,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
/*
//TOOLIN   DD *                                             
  SORT FROM(IN) USING(CTL1)                                 
  SPLICE FROM(T1) TO(OUT) ON(1,3,CH) KEEPNODUPS -           
  WITHEACH WITH(09,4) WITH(13,4) WITH(17,4) -               
  WITH(21,4) WITH(25,4) WITH(29,4) WITH(33,3) WITH(37,4)     
//CTL1CNTL DD *                                             
  SORT FIELDS=(1,3,CH,A)                                     
  OUTREC IFOUTLEN=80,                                       
  IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,3))),
  IFTHEN=(WHEN=(81,8,ZD,EQ,01),BUILD=(1,4,5,4)),             
  IFTHEN=(WHEN=(81,8,ZD,EQ,02),BUILD=(1,4,04X,5,4)),         
  IFTHEN=(WHEN=(81,8,ZD,EQ,03),BUILD=(1,4,08X,5,4)),         
  IFTHEN=(WHEN=(81,8,ZD,EQ,04),BUILD=(1,4,12X,5,4)),         
  IFTHEN=(WHEN=(81,8,ZD,EQ,05),BUILD=(1,4,16X,5,4)),         
  IFTHEN=(WHEN=(81,8,ZD,EQ,06),BUILD=(1,4,20X,5,4)),         
  IFTHEN=(WHEN=(81,8,ZD,EQ,07),BUILD=(1,4,24X,5,4)),         
  IFTHEN=(WHEN=(81,8,ZD,EQ,08),BUILD=(1,4,28X,5,4)),         
  IFTHEN=(WHEN=(81,8,ZD,EQ,09),BUILD=(1,4,32X,5,4)),         
  IFTHEN=(WHEN=(81,8,ZD,EQ,10),BUILD=(1,4,36X,5,4)),         
  IFTHEN=(WHEN=(81,8,ZD,EQ,11),BUILD=(1,4,40X,5,4))         
  OUTFIL FNAMES=T1                                           
/*   


Hope this helps...

Cheers
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Sep 15, 2008 6:48 am
Reply with quote

Hi Kolusu,
Quote:
Once you concatenate the 2 datasets your data is not sorted on the key fields and INREC is processed before the SORT,so the sequencing of the records will be wrong.
Thanks for getting me corrected. I think the code of my post might have worked for the records of type
Code:
ABC 123
ABC aaa
ABC bbb
ABC ccc
DEF zzz
DEF 234

Please advice. I don't have access to Mainframes to these days, so can't check icon_cry.gif .


-Ad
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Mon Sep 15, 2008 9:07 pm
Reply with quote

Anuj D,

Your solution would work if the records are already sorted on the key field. Btw I did NOT edit your posts

Kolusu
Back to top
View user's profile Send private message
atanwc

New User


Joined: 26 Jul 2006
Posts: 24

PostPosted: Tue Sep 16, 2008 6:14 am
Reply with quote

Thanks all!

I could not connect to mainframe at home during last weekend so I just tried your JCL code today at my office. I fond it worked!!! Thanks!

However, I needed to use a sort step before the ICETOOL step to combine the two files into one first. It only worked in one file.

Anyway, I did not know ICETOOL could do this type of output format before. Now I learned it.

I also told my manager about this FORUM.

Thank you all!
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Sep 16, 2008 7:41 am
Reply with quote

Quote:
I also told my manager about this FORUM.
Beware..!!! Your internet ID is gonna be blocked now.. icon_lol.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Sep 16, 2008 7:55 am
Reply with quote

Hi,
atanwc wrote:
..I needed to use a sort step before the ICETOOL step to combine the two files into one first. It only worked in one file.
Yup, you need that as Skolusu has said (Thanks Kolusu)
Quote:
..solution would work if the records are already sorted on the key field

BTW, I've already been scolded for that.. icon_sad.gif .. still remember that red text..

Quote:
Anyway, I did not know ICETOOL could do this type of output format before.
There are much more complex things which can be done using ICETOOL, just search around to explore more. Good Luck..
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Sep 18, 2008 10:11 pm
Reply with quote

You can do this kind of thing more easily and efficiently with the new WHEN=GROUP function of DFSORT available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this

Code:

//STEP0100 EXEC PGM=ICEMAN             
//SYSOUT   DD SYSOUT=*                 
//SORTIN   DD *                       
ABC 123                               
DEF 234   
//  DD *                           
ABC AAA                               
ABC BBB                               
ABC CCC                               
ABC DDD                               
ABC EEE                               
ABC FFF                               
ABC GGG                               
ABC HHH                               
ABC III                               
DEF ZZZ                               
//SORTOUT  DD SYSOUT=*                 
//SYSIN    DD *                                                   
  OPTION EQUALS                                                   
  INREC BUILD=(1,4,81:5,4)                                         
  SORT FIELDS=(1,3,CH,A)                                           
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(85:SEQNUM,2,ZD,RESTART=(1,3))),
  IFTHEN=(WHEN=GROUP,RECORDS=2,BEGIN=(85,2,ZD,EQ,01),             
  PUSH=(05:81,04)),                                               
  IFTHEN=(WHEN=GROUP,RECORDS=2,BEGIN=(85,2,ZD,EQ,02),             
  PUSH=(05:5,04,81,04)),                                           
  IFTHEN=(WHEN=GROUP,RECORDS=2,BEGIN=(85,2,ZD,EQ,03),             
  PUSH=(05:5,08,81,04)),                                           
  IFTHEN=(WHEN=GROUP,RECORDS=2,BEGIN=(85,2,ZD,EQ,04),             
  PUSH=(05:5,12,81,04)),                                           
  IFTHEN=(WHEN=GROUP,RECORDS=2,BEGIN=(85,2,ZD,EQ,05),             
  PUSH=(05:5,16,81,04)),                                           
  IFTHEN=(WHEN=GROUP,RECORDS=2,BEGIN=(85,2,ZD,EQ,06),             
  PUSH=(05:5,20,81,04)),                                           
  IFTHEN=(WHEN=GROUP,RECORDS=2,BEGIN=(85,2,ZD,EQ,07),             
  PUSH=(05:5,24,81,04)),                                           
  IFTHEN=(WHEN=GROUP,RECORDS=2,BEGIN=(85,2,ZD,EQ,08),             
  PUSH=(05:5,28,81,04)),                                           
  IFTHEN=(WHEN=GROUP,RECORDS=2,BEGIN=(85,2,ZD,EQ,09),             
  PUSH=(05:5,32,81,04)),                                           
  IFTHEN=(WHEN=GROUP,RECORDS=2,BEGIN=(85,2,ZD,EQ,10),             
  PUSH=(05:5,36,81,04))                                           

  OUTFIL REMOVECC,NODETAIL,BUILD=(80X),                           
  SECTIONS=(1,4,TRAILER3=(1,80))                                   
/*                                                                 


The output from this job would be

Code:

ABC 123 AAA BBB CCC DDD EEE FFF GGG HHH III
DEF 234 ZZZ                               


For complete details on the WHEN=GROUP function and the other new functions available with PTF UK90013, see:

Use [URL] BBCode for External Links


Hope this helps...

Cheers
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: Fri Sep 19, 2008 1:03 am
Reply with quote

Here's another variation on Kolusu's clever idea for using WHEN=GROUP for this situation.

This one has the advantage of doing one PUSH for each 4-byte field rather than a PUSH for the combined fields. On the other hand, for a different max, it would require changing the RECORDS values in the IFTHEN clauses whereas Kolusu's version doesn't. Either version will produce the same results, so use whichever one you prefer.

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
ABC 123
DEF 234
GHI 456
//  DD *
ABC AAA
ABC BBB
ABC CCC
ABC DDD
ABC EEE
ABC FFF
ABC GGG
ABC HHH
ABC III
DEF ZZZ
GHI AAA
GHI BBB
GHI CCC
GHI DDD
GHI EEE
//SORTOUT DD SYSOUT=*
//SYSIN    DD *
  OPTION EQUALS
  INREC BUILD=(1,4,81:5,4)
  SORT FIELDS=(1,3,CH,A)
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(85:SEQNUM,2,ZD,RESTART=(1,3))),
  IFTHEN=(WHEN=GROUP,BEGIN=(85,2,ZD,EQ,1),RECORDS=10,
    PUSH=(5:81,4)),
  IFTHEN=(WHEN=GROUP,BEGIN=(85,2,ZD,EQ,2),RECORDS=9,
    PUSH=(9:81,4)),
  IFTHEN=(WHEN=GROUP,BEGIN=(85,2,ZD,EQ,3),RECORDS=8,
    PUSH=(13:81,4)),
  IFTHEN=(WHEN=GROUP,BEGIN=(85,2,ZD,EQ,4),RECORDS=7,
    PUSH=(17:81,4)),
  IFTHEN=(WHEN=GROUP,BEGIN=(85,2,ZD,EQ,5),RECORDS=6,
    PUSH=(21:81,4)),
  IFTHEN=(WHEN=GROUP,BEGIN=(85,2,ZD,EQ,6),RECORDS=5,
    PUSH=(25:81,4)),
  IFTHEN=(WHEN=GROUP,BEGIN=(85,2,ZD,EQ,7),RECORDS=4,
    PUSH=(29:81,4)),
  IFTHEN=(WHEN=GROUP,BEGIN=(85,2,ZD,EQ,8),RECORDS=3,
    PUSH=(33:81,4)),
  IFTHEN=(WHEN=GROUP,BEGIN=(85,2,ZD,EQ,9),RECORDS=2,
    PUSH=(37:81,4)),
  IFTHEN=(WHEN=(85,2,ZD,EQ,10),OVERLAY=(41:81,4))   
  OUTFIL REMOVECC,NODETAIL,BUILD=(80X),
    SECTIONS=(1,4,TRAILER3=(1,80))
/*
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 TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top