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

Merging Datasets


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

Active User


Joined: 21 Jun 2009
Posts: 160
Location: Indore

PostPosted: Tue Feb 01, 2011 9:42 pm
Reply with quote

Hi All,

I have the following requirement
I have five datasets all having RECFM=FB and LRECL=213.
File has error description at first 30 bytes and rest of it is data.
ex
File1
Code:
Error1                            Record1
                                     Record2
                                     Record3
                                     Record4
Error2                            Record1
                                     Record2

File2
Code:
Error1                            Record5
                                     Record6
                                     Record7
                                     Record8
Error2                            Record7
                                     Record9

Output
Code:
Error1                            Record1
                                     Record2
                                     Record3
                                     Record4
                                     Record5
                                     Record6
                                     Record7
                                     Record8
Error2                            Record1
                                     Record2
                                     Record7
                                     Record9

There can be any number of errors.If any record is present in file 1 it will not be in file-2.

Can we do this using sort?

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

Active User


Joined: 21 Jun 2009
Posts: 160
Location: Indore

PostPosted: Tue Feb 01, 2011 9:52 pm
Reply with quote

All the records start at 32nd position.
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Tue Feb 01, 2011 9:53 pm
Reply with quote

rgupta71, a merge requires that all of the input datasets are already sorted in ascending order on the merging key, i.e. in your case the first 30 bytes. Then, the MERGE command combines all of the records based on that key. I have a suspicion that a MERGE is not what you're looking for here.
Back to top
View user's profile Send private message
rgupta71

Active User


Joined: 21 Jun 2009
Posts: 160
Location: Indore

PostPosted: Tue Feb 01, 2011 10:19 pm
Reply with quote

We can sort it based on error.It is not a problem.
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: Tue Feb 01, 2011 10:42 pm
Reply with quote

Hello,

Quote:
We can sort it based on error.It is not a problem.
If you can sort it on error, you can merge it. . .

You need to use the "Code" tag when posting. All you need is copy/paste frm the terminal and "Code" the info in the reply editor. Do not add spaces as this mis-aligns your data.
Back to top
View user's profile Send private message
rgupta71

Active User


Joined: 21 Jun 2009
Posts: 160
Location: Indore

PostPosted: Tue Feb 01, 2011 10:58 pm
Reply with quote

If I sort the data all the records which have blank in the first 30 byte will come at end.

How I will I determine that which record was for which error?
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: Tue Feb 01, 2011 11:53 pm
Reply with quote

Hello,

Quote:
If I sort the data all the records which have blank in the first 30 byte will come at end.

The blanks will be first not last - this is not a pc. . .

You said it was no problem and that you could sort it based on error. . .

A process is needed that propogates the "error" value to the uncoded records in both files, then merge these suppressing the error code in records 2 thru n for each output group.

What should happen if either/both iput files contain duplicates?
Back to top
View user's profile Send private message
rgupta71

Active User


Joined: 21 Jun 2009
Posts: 160
Location: Indore

PostPosted: Wed Feb 02, 2011 12:07 am
Reply with quote

Same error can be present in both the files but every record field will be only in one file.
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: Wed Feb 02, 2011 3:21 am
Reply with quote

If I understand what you're trying to do (and I'm not sure I do), here's a DFSORT job that will do it.

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=...  input file1 (FB/213)
//IN2 DD DSN=...  input file2 (FB/213)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=...   output file (FB/213)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'Error'),
    PUSH=(214:1,30))
/*
//CTL2CNTL DD *
  OPTION EQUALS
  SORT FIELDS=(214,30,CH,A)
  OUTREC IFOUTLEN=213,
    IFTHEN=(WHEN=GROUP,KEYBEGIN=(214,30),PUSH=(214:SEQ=8)),
    IFTHEN=(WHEN=(214,8,ZD,NE,1),OVERLAY=(1:30X))
/*
Back to top
View user's profile Send private message
rgupta71

Active User


Joined: 21 Jun 2009
Posts: 160
Location: Indore

PostPosted: Wed Feb 02, 2011 10:32 pm
Reply with quote

Hi Frank,
It is giving error
Code:

  OPTION EQUALS                                             
  SORT FIELDS=(214,30,CH,A)                                 
  OUTREC IFOUTLEN=213,                                       
    IFTHEN=(WHEN=GROUP,KEYBEGIN=(214,30),PUSH=(214:SEQ=8)), 
                       $                                     
OPERAND DEFINER ERROR                                       
    IFTHEN=(WHEN=(214,8,ZD,NE,1),OVERLAY=(1:30X))           
    $     
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Feb 02, 2011 10:54 pm
Reply with quote

rgupta71,

Looks like you don't have PTF H which supports keybegin keyword. Change the OUTREC statements to the following

Code:

  OUTREC IFOUTLEN=213,                                           
  IFTHEN=(WHEN=INIT,OVERLAY=(244:SEQNUM,8,ZD,RESTART=(214,30))),   
  IFTHEN=(WHEN=(244,8,ZD,NE,1),OVERLAY=(1:30X))                 
Back to top
View user's profile Send private message
rgupta71

Active User


Joined: 21 Jun 2009
Posts: 160
Location: Indore

PostPosted: Thu Feb 03, 2011 1:04 am
Reply with quote

It worked. icon_biggrin.gif
My input files also has header of 5 rows icon_sad.gif .Can we handle that by modifying the same sort or I should delete the data before using this sort?

Thank you all for your support.
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: Thu Feb 03, 2011 1:51 am
Reply with quote

Sigh. That depends on which input file has the header rows and what they look like. Give details and show an example.

It would have saved time if you had described your requirement completely in the first place.
Back to top
View user's profile Send private message
rgupta71

Active User


Joined: 21 Jun 2009
Posts: 160
Location: Indore

PostPosted: Thu Feb 03, 2011 1:54 am
Reply with quote

Sorry Frank icon_redface.gif .
Both the input files have header of 5 rows. The example is same as above the only difference is that it has header of 5 rows.
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: Thu Feb 03, 2011 2:02 am
Reply with quote

If you need to remove the first 5 records from each input file, change CTL1CNTL to:

Code:

//CTL1CNTL DD *
  OPTION SKIPREC=5
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'Error'),
    PUSH=(214:1,30))
/*
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 Merging 2 datasets into one DFSORT/ICETOOL 1
No new posts PL/I, VB Datasets and the RDW PL/I & Assembler 4
No new posts how to get list of all VSAM/non-VSAM ... JCL & VSAM 13
No new posts define 1 DCB parms for multiple outpu... JCL & VSAM 9
No new posts FTP datasets to server CLIST & REXX 13
Search our Forums:

Back to Top