Building one output file from two input files



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Building one output file from two input files

Postby IRHamilton » Mon Aug 23, 2010 3:26 am

I'm new to DFSORT and what I want to do should be simple but I'm doing something wrong.
I have one file that has one record in it and I want to take data from a certain position and add it to every record in a second file that has multiple records but I only want some data from the second file.
Basically I'm building output records from the two files.

This is what I have from my last try at it, I'm getting all the data I want from the multi record second file but I'm loosing the one piece of data from the first file.
I’ve tried several different combinations and have searched a lot through your site and looked through many manuals.

Please advise me of my mistake(s). Thanks very much.

//STEP001   EXEC  PGM=ICETOOL                                     
//TOOLMSG   DD  SYSOUT=*                                           
//DFSMSG    DD  SYSOUT=*                                           
//** FIXED LENGTH RECORD OF 80 (1 RECORD)                         
//INDT DD  DSN=DAS.TEST.FILE1,DISP=SHR       
//** FIXED LENGTH RECORDS OF 165 (SEVERAL RECORDS)                 
//INFL DD  DSN=DAS.TEST.FILE2,DISP=SHR           
//*                                                               
//TEMP1  DD DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=WORK
//OUT1 DD DSN=DAS.TEST.OUTPUT,                         
//            DISP=(,CATLG,DELETE),                             
//            UNIT=TEST,                                           
//            SPACE=(TRK,(5,1),RLSE)                               
//**                                                               
//TOOLIN   DD *                                                     
 COPY FROM(INDT) TO(TEMP1) USING(CTL1)                             
 COPY FROM(INFL) TO(TEMP1) USING(CTL2)                             
/*                                                                 
//**                                                               
//**                                                               
//CTL1CNTL DD *                                                     
  OUTFIL FNAMES=OUT1,BUILD=(123X,31,2,61X)                         
/*                                                                 
//**                                                               
//CTL2CNTL DD *                                                     
  OUTFIL FNAMES=OUT1,OVERLAY=(1:1,90,91:+0,TO=PD,LENGTH=6,          << This was my last desperate attempt
                            97:91,6,103:103,4,107:+1,TO=ZD,LENGTH=3,                    going field by field & skipping over
                            110:107,6,116:113,3,119:116,3,                                        the position from the first file.
                            122:2X,126:61X)                         
/*                                                                 
//*
IRHamilton
 
Posts: 6
Joined: Mon Aug 23, 2010 2:53 am
Has thanked: 0 time
Been thanked: 0 time

Re: Building one output file from two input files

 

Re: Building one output file from two input files

Postby skolusu » Mon Aug 23, 2010 9:59 pm

It is difficult to guess as to what you are doing. Here is a job which would give you the desired results based on the following assumptions.

1. You have 1 record 80 byte file1 which has a constant value in pos 1 for length of 5 bytes. ex the job shows you have 12345 as constant at pos 1

2. You want to add that value to every record in file2 to the value in pos 10 for a length of 5 bytes. we will add constant 12345 to every record in file 2.

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                             
12345                                                       
//SORTOUT  DD DSN=&&S1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE) 
//SYSIN    DD *                                             
  OPTION COPY,STOPAFT=1                                     
  OUTREC BUILD=(C'NUMCON,+',1,5,80:X)                       
//*                                                         
//STEP0200 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SYMNAMES DD DSN=&&S1,DISP=SHR                             
//SORTIN   DD *                                             
A        00001                                             
B        00002                                             
C        00003                                             
D        00004                                             
E        00005                                             
F        00006                                             
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                             
  OPTION COPY                                               
  OUTREC OVERLAY=(10:10,5,ZD,ADD,NUMCON,M11,LENGTH=5)       
//*   


The output from this job is

A        12346
B        12347
C        12348
D        12349
E        12350
F        12351


If that is not what you want please show us a sample input and desired output
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: Building one output file from two input files

Postby IRHamilton » Tue Aug 24, 2010 12:37 am

Sorry I guess I was not too clear, put it down to being new at this.
This should be easy but maybe I’m not using the Temp area properly.


File 1 (record length 80) only has one record.
I want the data from position 31,2 CH (example below has value of 15)

********************************* Top of Data **********************************
2010-08-012010-08-152010-08-1515................................................
******************************** Bottom of Data ********************************



File 2 contains several records and is too hard to show because of all the packed fields, so I will just try to layout what the output content should be . . .

Output  (record length 186)             File 2 input  (record length 165)

position     1,90  CH                       position  1, 90 CH
           91,6   PD                             <constant value of +0>
           97,6   PD                             91,6 PD
           103,4   PD                            103,4 PD
           107,3   ZD                             <constant value of +1>
           110,6   PD                            107,6 PD
           116,3   CH                            113,3 CH
           119,3   ZD                            116,3 ZD
           122,2   CH                            <constant value of blanks>
           124,2   CH                            ** constant value from File 1 **
           126,61  CH                            <constant value of blanks>


Thanks very much for your help and I hope this is a little easier to understand.
IRHamilton
 
Posts: 6
Joined: Mon Aug 23, 2010 2:53 am
Has thanked: 0 time
Been thanked: 0 time

Re: Building one output file from two input files

Postby IRHamilton » Tue Aug 24, 2010 12:44 am

Boy after you post it the format sure does not look the same (seems to get rid of the spacing). :?
The first position and set of values is for the output and the second set is the input.
IRHamilton
 
Posts: 6
Joined: Mon Aug 23, 2010 2:53 am
Has thanked: 0 time
Been thanked: 0 time

Re: Building one output file from two input files

Postby dick scherrer » Tue Aug 24, 2010 1:02 am

Hello,

Boy after you post it the format sure does not look the same (seems to get rid of the spacing).
To preserve alignment, use the "Code" tag (your entries have been "Code'd" - i didn't re-align).

Also, use Preview to see your post as it will appear to the forum (rather than the Reply Editor). When it appears as as you want it, Submit.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Building one output file from two input files

Postby Frank Yaeger » Tue Aug 24, 2010 1:32 am

Thanks very much for your help and I hope this is a little easier to understand.


Not to me - I can't figure out what fields apply to which files. I don't know if you're trying to keep the same layout from file2 for output, or change the layout of file2 completely for output.

Please show the layout of input2 and output separately in that order and in a consistent way that we can understand - for example:

Input file2

Positions 1-90 - characters
Positions 91-92 - PD 0
...

Output file

Positions 1-90 - file2 positions 1-90
...


But, of course, fill in the right stuff.

We need to know what should appear in each field of the output record and where it should come from.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

Re: Building one output file from two input files

Postby IRHamilton » Tue Aug 24, 2010 2:31 am

Sorry again... I was trying to layout what the output would be.

Output file (record length 186)

position     1,90  CH                       file 2 - position  1, 90 CH
           91,6   PD                             <constant value of +0>
           97,6   PD                            file 2 - position 91,6 PD
           103,4   PD                           file 2 - position 103,4 PD
           107,3   ZD                             <constant value of +1>
           110,6   PD                            file 2 - position 107,6 PD
           116,3   CH                            file 2 - position 113,3 CH
           119,3   ZD                            file 2 - position 116,3 ZD
           122,2   CH                            <constant value of blanks>
           124,2   CH                            ** constant value from File 1 - position 31,2 CH **
           126,61  CH                            <constant value of blanks>
"Code'd"

Thanks very much for your time and patience.
IRHamilton
 
Posts: 6
Joined: Mon Aug 23, 2010 2:53 am
Has thanked: 0 time
Been thanked: 0 time

Re: Building one output file from two input files

Postby dick scherrer » Tue Aug 24, 2010 2:49 am

Hello,

It works better if you Preview before Submit. . . :)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Building one output file from two input files

Postby Frank Yaeger » Tue Aug 24, 2010 3:03 am

IRHamilton,

Here's a DFSORT job that will do what you asked for:

//S1 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=...  input file1
//SORTOUT  DD DSN=&&S1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//SYSIN    DD *
  OPTION COPY,STOPAFT=1
  INREC BUILD=(C'NUMCON,''',31,2,C'''',80:X)
//*
//S2 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=SHR
//SORTIN   DD DSN=...  input file2
//SORTOUT  DD DSN=...  output file (FB/186)
//SYSIN    DD *
  OPTION COPY
  INREC BUILD=(1:1,90,
    91:+0,TO=PD,LENGTH=6,
    97:91,6,
   103:103,4,
   107:+1,TO=ZD,LENGTH=3,
   110:107,6,
   116:113,3,
   119:116,3,
   124:NUMCON,
   186:X)
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

Re: Building one output file from two input files

Postby IRHamilton » Tue Aug 24, 2010 6:27 pm

Thank you gentlemen for your help.

I'll have to try and find some more information about the Temp area, I thought I could use it as an area to build the records but I guess not.

Dick, I did use the preview but I guess I misunderstood the "Code" tag thing.

Frank, with a few adjustments to the JCL for our site here the code worked great.
IRHamilton
 
Posts: 6
Joined: Mon Aug 23, 2010 2:53 am
Has thanked: 0 time
Been thanked: 0 time

Next

Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post