Page 1 of 2

Building one output file from two input files

PostPosted: Mon Aug 23, 2010 3:26 am
by IRHamilton
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)                         
/*                                                                 
//*

Re: Building one output file from two input files

PostPosted: Mon Aug 23, 2010 9:59 pm
by skolusu
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

Re: Building one output file from two input files

PostPosted: Tue Aug 24, 2010 12:37 am
by IRHamilton
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.

Re: Building one output file from two input files

PostPosted: Tue Aug 24, 2010 12:44 am
by IRHamilton
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.

Re: Building one output file from two input files

PostPosted: Tue Aug 24, 2010 1:02 am
by dick scherrer
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.

Re: Building one output file from two input files

PostPosted: Tue Aug 24, 2010 1:32 am
by Frank Yaeger
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.

Re: Building one output file from two input files

PostPosted: Tue Aug 24, 2010 2:31 am
by IRHamilton
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.

Re: Building one output file from two input files

PostPosted: Tue Aug 24, 2010 2:49 am
by dick scherrer
Hello,

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

d

Re: Building one output file from two input files

PostPosted: Tue Aug 24, 2010 3:03 am
by Frank Yaeger
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)
/*

Re: Building one output file from two input files

PostPosted: Tue Aug 24, 2010 6:27 pm
by IRHamilton
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.