View previous topic :: View next topic
Author
Message
scdinesh New User Joined: 06 Sep 2006Posts: 44 Location: United States
Hi All..
Please find the below question and help me out on this
First file layout is xxxx20091115xxxxx(only one record would be there ..contains date).
second file layout is 768899999999999978908887565
767899000667777777777777778
768899999999999978908887565
767899000667777777777777778
i want to insert date record (20091115) from first file to all records of second file to get third file using sort
Expected Output:
20091115768899999999999978908887565
20091115 767899000667777777777777778
20091115768899999999999978908887565
20091115767899000667777777777777778
if u find some time could you pls send me the Sort syntax
Thanks
Dinesh
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
scdinesh,
The following DFSORT JCL will give you the desired results
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
XXXX20091115XXXXX
//SORTOUT DD DSN=&&S1,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//SYSIN DD *
SORT FIELDS=COPY,STOPAFT=1
INREC BUILD=(C'FVALUE,C''',5,8,C'''',80:X)
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=SHR
//SORTIN DD *
768899999999999978908887565
767899000667777777777777778
768899999999999978908887565
767899000667777777777777778
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC BUILD=(FVALUE,1,80)
//*
With z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707, you can use the Joinkeys function like shown below to get the desired results. Since both files don't have a common key we add an extra byte at pos 81 using INREC for each file via JNF1CNTL and JNF2CNTL and use that as a key for matching
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD *
768899999999999978908887565
767899000667777777777777778
768899999999999978908887565
767899000667777777777777778
//SORTJNF2 DD *
XXXX20091115XXXXX
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
JOINKEYS FILE=F1,FIELDS=(81,1,A),SORTED,NOSEQCK
JOINKEYS FILE=F2,FIELDS=(81,1,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F2:5,8,F1:1,80)
//JNF1CNTL DD *
INREC BUILD=(1,80,X)
//JNF2CNTL DD *
INREC BUILD=(1,80,X)
//*
Back to top
Escapa Senior Member Joined: 16 Feb 2007Posts: 1399 Location: IL, USA
This is one more solution for it.
Code:
//S1 EXEC PGM=SORT
//SORTIN DD *
XXXX20091115XXXXX
/*
// DD *
768899999999999978908887565
767899000667777777777777778
768899999999999978908887565
767899000667777777777777778
//SORTOUT DD DSN=outptut dataset,LRECL=88
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'XXXX'),
PUSH=(81:5,8))
OUTFIL BUILD=(81,8,1,80),OMIT=(1,4,CH,EQ,C'XXXX')
/*
Back to top
Please enable JavaScript!