MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Vertical Merge - NOT Omitting any Rows

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Fri Oct 26, 2007 6:04 am    Post subject: Vertical Merge - NOT Omitting any Rows Reply with quote

Input File #1

Position 01 thru 18 => Account Number (Length : 18 )
Position 19 thru 20 => Pay Day (Length : 02)

Code:

----+----1----+----2----+----3----+----4----+----5----+----6
********************************* Top of Data **************
001500751530022852 1                                       
001500751530022853 1                                       
001500751530022854 1                                       
001500751530022855 1                                       
001500751530022856 1                                       
001500751530022857 1                                       
00151002153000064316                                       
00151002153000064416                                       
00151002153000064516                                       
001510021530014752 2                                       
001510021530015239 1                                       
001510021530017287 1                                       
001510021530024101 1                                       
001510021530024602 7                                       
00151002153002912114                                       
00151002153004990910     


Input File #2

Position 01 thru 18 => Account Number (Length : 18 )
Position 19 thru 28 => Interest (Length : 09)
Position 29 thru 38 => Date 1 (Length : 10)
Position 39 thru 48 => Date 2 (Length : 10)

Code:

----+----1----+----2----+----3----+----4----+----5----+----6
********************************* Top of Data **************
001500751530022852000000000 NA        NA                   
001500751030000062010390560 NA        NA                   
001500751030000130000000000 NA        NA                   
001500751030000130009752040 NA        NA                   
001500751030000229000000000 NA        NA                   
001500751030000229010390560 NA        NA                   
001510021530000643000000000 NA        NA                   
001500751030000372008092920 NA        NA                   
001500751030000400010208520 NA        NA                   
001500751030000402000000000 NA        NA                   
001500751030000402008463840 NA        NA                   
001500751030000406000000000 NA        NA                   
001500751030000406009568920 NA        NA                   
001500751030000408006408360 NA        NA                   
001500751030000415000000000 NA        NA                   
001510021530049909005651280 NA        NA                   


Expected Output File

Expecetd Data SHOULD BE in Position 49 thru 50 column wise. This is a Vertical Merge. When the first 18 position in Input File #1 and Input File #2 matches, the value in position 19 and 20 from (Input File #1) is written to output file in position 49,50. If there is NO match then write as NA. I made Position 01 thru 18 in rows 1, 7 and 16 to match and hence the value (position 18 and 19 column) in these rows from Input File #1 are written to the output file. Note that 1st Row in the Output File, position 49 and 50 is 01 and not 1, wanted to add that this postion should always be put with a leading 0 if this is a single digit.

Code:

----+----1----+----2----+----3----+----4----+----5----+----6
********************************* Top of Data **************
001500751030000062000000000 NA        NA        01                   
001500751030000062010390560 NA        NA        NA                                       
001500751030000130000000000 NA        NA        NA                                       
001500751030000130009752040 NA        NA        NA                                       
001500751030000229000000000 NA        NA        NA                                       
001500751030000229010390560 NA        NA        NA                                       
001500751030000372000000000 NA        NA        16                                       
001500751030000372008092920 NA        NA        NA                                       
001500751030000400010208520 NA        NA        NA                                       
001500751030000402000000000 NA        NA        NA                                       
001500751030000402008463840 NA        NA        NA                                       
001500751030000406000000000 NA        NA        NA                                       
001500751030000406009568920 NA        NA        NA                                       
001500751030000408006408360 NA        NA        NA                                       
001500751030000415000000000 NA        NA        NA                                       
001500751030000415005651280 NA        NA        10         



I have not experienced doing a vertical merge before. So please help me out to achieve this using SORT technique. I came across http://www-304.ibm.com/jct01004c/systems/support/storage/software/sort/mvs/tricks/pdf/sorttrck.pdf this documentation which I believe can be tweaked but I had NO success to achieve what I am looking for.

Please Share your valuable thoughts!
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Oct 26, 2007 3:18 pm    Post subject: Reply with quote

Your output doesn't seem to match your input or rules. For example, I see the following match on an account number in input file1 and file2:

Code:

acct--------------
00151002153000064316
001510021530000643000000000 NA        NA


and I would expect an output record for that account with the 16 vertically merged in as follows:

Code:

001510021530000643000000000 NA        NA        16


But instead you have:

Code:

001500751030000372000000000 NA        NA        16


which is a different record. Why?

You need to clear up the confusion.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Mon Oct 29, 2007 4:00 am    Post subject: Reply with quote

sakreg,

I know you have asked for a solution thru SORT. You can get the desired results using below EZT solution.
Code:
//EZT01   EXEC PGM=EZTPA00
//SYSPRINT  DD SYSOUT=*
//SYSSNAP   DD SYSOUT=*
//SYSOUT    DD SYSOUT=*
//SYSUDUMP  DD SYSOUT=D
//EZTVFM    DD UNIT=SYSDA,SPACE=(CYL,(5,1))
//*
//IN1       DD *
001500751530022852 1                                       
001500751530022853 1                                       
001500751530022854 1                                       
001500751530022855 1                                       
001500751530022856 1                                       
001500751530022857 1                                       
00151002153000064316                                       
00151002153000064416                                       
00151002153000064516                                       
001510021530014752 2                                       
001510021530015239 1                                       
001510021530017287 1                                       
001510021530024101 1                                       
001510021530024602 7                                       
00151002153002912114                                       
00151002153004990910
//IN2       DD *
001500751530022852000000000 NA        NA                   
001500751030000062010390560 NA        NA                   
001500751030000130000000000 NA        NA                   
001500751030000130009752040 NA        NA                   
001500751030000229000000000 NA        NA                   
001500751030000229010390560 NA        NA                   
001510021530000643000000000 NA        NA                   
001500751030000372008092920 NA        NA                   
001500751030000400010208520 NA        NA                   
001500751030000402000000000 NA        NA                   
001500751030000402008463840 NA        NA                   
001500751030000406000000000 NA        NA                   
001500751030000406009568920 NA        NA                   
001500751030000408006408360 NA        NA                   
001500751030000415000000000 NA        NA                   
001510021530049909005651280 NA        NA
//OUT1      DD DSN=A.B.C,DISP=SHR
//SYSIN     DD *
  FILE IN1
    IN1-AC-NBR           001 018 N
    IN1-PAY-DAY                  019 002 N

  FILE IN2
    IN2-AC-NBR           001 018 N
    IN2-INTEREST               019 009 N
    IN2-DATE1           029 010 N
    IN2-DATE2           039 010 N

  FILE OUT1
    OUT1-AC-NBR           001 018 N
    OUT1-INTEREST             019 009 N
    OUT1-VALUE1                 029 002 A
    OUT1-VALUE2                 039 002 A
    OUT1-VALUE3                 049 002 A

JOB INPUT (IN1 KEY (IN1-AC-NBR)  +
            IN2 KEY (IN2-AC-NBR))

   IF MATCHED
   OUT1-AC-NBR = IN2-AC-NBR
      OUT1-INTEREST = IN2-INTEREST
      OUT1-VALUE3 = IN1-PAY-DAY
                OUT1-VALUE1 = 'NA'
                OUT1-VALUE2 = 'NA'
   ELSE
       OUT1-AC-NBR = IN2-AC-NBR
      OUT1-INTEREST = IN2-INTEREST
      OUT1-VALUE3 = 'NA'
                OUT1-VALUE1 = 'NA'
                OUT1-VALUE2 = 'NA'
   END-IF
/*
Back to top
View user's profile Send private message Send e-mail
vivek1983
Intermediate


Joined: 20 Apr 2006
Posts: 222
Topics: 24

PostPosted: Mon Oct 29, 2007 4:44 am    Post subject: Reply with quote

sakreg,

The following job will get u the desired results:

Code:


//STEP0100 EXEC PGM=ICETOOL               
//TOOLMSG  DD SYSOUT=*                   
//DFSMSG   DD SYSOUT=*                   
//IN1      DD *                           
001500751530022852 1                     
001500751530022853 1                     
001500751530022854 1                     
001500751530022855 1                     
001500751530022856 1                     
001500751530022857 1                     
00151002153000064316                     
00151002153000064416                     
00151002153000064516                     
001510021530014752 2                     
001510021530015239 1                     
001510021530017287 1                     
001510021530024101 1                     
001510021530024602 7                     
00151002153002912114                     
00151002153004990910                     
//IN2      DD *                         
001500751530022852000000000 NA        NA
001500751030000062010390560 NA        NA
001500751030000130000000000 NA        NA
001500751030000130009752040 NA        NA
001500751030000229000000000 NA        NA
001500751030000229010390560 NA        NA
001510021530000643000000000 NA        NA
001500751030000372008092920 NA        NA
001500751030000400010208520 NA        NA
001500751030000402000000000 NA        NA
001500751030000402008463840 NA        NA
001500751030000406000000000 NA        NA
001500751030000406009568920 NA        NA
001500751030000408006408360 NA        NA
001500751030000415000000000 NA        NA                               
001510021530049909005651280 NA        NA                               
//T1       DD DSN=&T1,DISP=(MOD,PASS),UNIT=SYSDA,SPACE=(CYL,(5,5),RLSE)
//T2       DD DSN=&T2,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(5,5),RLSE)   
//OUT      DD SYSOUT=*                                                 
//TOOLIN   DD *                                                       
  COPY FROM(IN1) TO(T1) USING(CTL1)                                   
  COPY FROM(IN2) TO(T1) USING(CTL2)                                   
  SPLICE FROM(T1) TO(T2) ON(101,8,PD) WITH(21,65) USING(CTL3)         
  SORT FROM(T2) TO(OUT) USING(CTL4)                                   
//CTL1CNTL DD *                                                       
  OUTREC FIELDS=(1:1,20,101:SEQNUM,8,PD)                               
//CTL2CNTL DD *                                                       
  OUTREC FIELDS=(21:1,65,101:SEQNUM,8,PD)                             
//CTL3CNTL DD *                                                       
  OUTFIL FNAMES=T2,OUTREC=(1,80)                                       
/*                                                                     
//CTL4CNTL DD *                                                       
  SORT FIELDS=COPY                                                     
  INREC IFTHEN=(WHEN=INIT,                                             
       OVERLAY=(71:C'NA')),                       
        IFTHEN=(WHEN=(1,18,CH,EQ,21,18,CH),       
       OVERLAY=(71:19,2,ZD,EDIT=(TT)))           
  OUTREC FIELDS=(1:21,60)                         
/*                                               

 



Cannot think of a solution with less no of passes. Sad
_________________
Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay)
Back to top
View user's profile Send private message
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Mon Oct 29, 2007 7:09 am    Post subject: Reply with quote

vivek1983,

That works like a charm. Thank you very much.
Back to top
View user's profile Send private message
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Mon Oct 29, 2007 7:10 am    Post subject: Reply with quote

Frank Yaeger wrote:
Your output doesn't seem to match your input or rules. For example, I see the following match on an account number in input file1 and file2:

and I would expect an output record for that account with the 16 vertically merged in as follows:

Code:

001510021530000643000000000 NA        NA        16




Frank,

You are right.
Back to top
View user's profile Send private message
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Mon Oct 29, 2007 7:11 am    Post subject: Reply with quote

vkphani,

Thank you for your EZT solution. I know this works in our shop. But I have NOT worked with EZT before. But the solution is more understandable. I will give a try with EZT as well.
Back to top
View user's profile Send private message
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Mon Oct 29, 2007 11:05 am    Post subject: Reply with quote

vivek1983

I have some difficulty when trying to use with files instead of instream data. Maybethe postion is what matters.

Input File #1 is FB, LRECL = 20
Input File #2 is FB, LRECL = 50

Output File is FB, LRECL = 50

I am quite confused on the positions that were used in various control cards.

CTL1 - Writes from IN1 to a T1 (Temp File) from positions 1 till 20. I am NOT clear on the usage of 101:SEQNUM,8,PD

CTL2 - Writes from IN2 to a T2 (Temp File) from positions 21 till 65. I am NOT clear on the usage of 101:SEQNUM,8,PD. Instead of 65 I used 50 which is the actual length of file.

CTL3 - Splice and Create a File T2. Instead of
Code:

SPLICE FROM(T1) TO(T2) ON(101,8,PD) WITH(21,65) USING(CTL3)

I used
Code:

SPLICE FROM(T1) TO(T2) ON(101,8,PD) WITH(21,48) USING(CTL3)
48 is the exact column till where we have the data from Input File #2.
CTL4 - I believe 71 is a position used to hold either NA or the actual value from Input File #1. And we then write to OUT file. I used 49 instead of 71.

But the output does not comes as it comes with the instream data. Crying or Very sad
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Oct 29, 2007 12:21 pm    Post subject: Reply with quote

sakreg,

As I said previously, your output doesn't seem to match your input for your example.

If you want MY help (and maybe you don't), please show the correct expected output records for your example input records.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vivek1983
Intermediate


Joined: 20 Apr 2006
Posts: 222
Topics: 24

PostPosted: Tue Oct 30, 2007 2:52 am    Post subject: Reply with quote

sakreg,

Quote:

I have some difficulty when trying to use with files instead of instream data. Maybethe postion is what matters.

Input File #1 is FB, LRECL = 20
Input File #2 is FB, LRECL = 50

Output File is FB, LRECL = 50

I am quite confused on the positions that were used in various control cards.


Quote:

CTL1 - Writes from IN1 to a T1 (Temp File) from positions 1 till 20. I am NOT clear on the usage of 101:SEQNUM,8,PD



The sort cards deals with Temp files and hence the lengths of the temp files are used for work-around purpose. The actual length is to be dealt with the CTL4 which uses the actual output file.

Make the following changes in the CTL4:
1. Instead of 71 give 69. (Coz the output u require should have 'NA' in position 49. )
2. Change the outrec fields = (1:21,50). (This will write the output file which is length 50, starting from position 21 from the temp file).

By making these changes you can achieve the output u require.


There are lots of examples on the usage of temp files in sort techniques. You could use them as a reference.


But then.. I would suggest you provide the actual input and the matching desired output so that you can get improved solutions to the actual problem.
_________________
Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay)
Back to top
View user's profile Send private message
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Tue Oct 30, 2007 4:16 am    Post subject: Reply with quote

vivek1983,

I got what I want. I would be happy if you can explain the usage of overlay. I thought I should use 49, Why are we using 69 to get the actual output at 49?

Thank You
SAK.
Back to top
View user's profile Send private message
vivek1983
Intermediate


Joined: 20 Apr 2006
Posts: 222
Topics: 24

PostPosted: Tue Oct 30, 2007 4:27 am    Post subject: Reply with quote

sakreg,

Quote:

I would be happy if you can explain the usage of overlay.



http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA20/3.8?SHELF=&DT=20060615185603&CASE=

Quote:

thought I should use 49, Why are we using 69 to get the actual output at 49?


In the temp file (after the 3rd pass), the actual or desired output will be after the 20th position. We will be just extracting from this temp file after excluding the first 20 characters to the output file.

The quick manuals link at the top of this page will be very useful to learn the various applications of SORT techniques.
_________________
Vivek G
--------------------------------------
A dream is just a dream. A goal is a dream with a plan and a deadline. (Harvey Mackay)
Back to top
View user's profile Send private message
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Tue Oct 30, 2007 4:35 am    Post subject: Reply with quote

Thank You for your time vivek1983.

I am all set now Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group