View previous topic :: View next topic
Author
Message
Aneesh New User Joined: 30 Sep 2006Posts: 60
Hi,
I have a file that has the data in the following format:
Code:
Id Pos Num Comment (Heading not part of file)
-------------------------------------------------------
Id1 Pos1 N1 Id1-Comment
Id1 Pos2 N2 Id1-Comment
Id1 Pos3 N3 Id1-Comment
Id2 Pos1 N1 Id2-Comment
Id2 Pos3 N2 Id2-Comment
Id3 Pos1 N1 Id3-Comment
Id3 Pos2 N5 Id3-Comment
Id4 Pos3 N6 Id4-Comment
The input file is FB of 80 bytes. The fields are:
ID 9(13)
Pos 9(4)
Num 9(5)
Comment X(58)
I need to reformat this file such that the data for a particular id is a single record with the data for the 3 positions concatenated.
Required Output
Code:
Pos1 Pos2 Pos3
Id1 N1 N2 N3 Id1-Comment
Id2 N1 N2 Id2-Comment
Id3 N1 N5 Id3-Comment
Id4 N6 Id4-Comment
I will have only 3 values of Pos in the input file - Pos1, Pos2 and Pos3.
Can this be done using splice?
Aneesh.
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
Aneesh,
The following DFSORT JCL will give you the desired results. I assumed that pos field actually contains a number 1 ,2, 3 to designate the number
Code:
//STEP0100 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=YOUR INPUT FILE,
// DISP=SHR
//SORTOUT DD DSN=your output file,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(X,Y),RLSE)
//SYSIN DD *
OPTION EQUALS
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:16X'00')),
IFTHEN=(WHEN=(14,4,ZD,EQ,1),OVERLAY=(82:18,5)),
IFTHEN=(WHEN=(14,4,ZD,EQ,2),OVERLAY=(87:18,5)),
IFTHEN=(WHEN=(14,4,ZD,EQ,3),OVERLAY=(92:18,5))
SORT FIELDS=(01,13,CH,A)
SUM FIELDS=(81,8,89,8),FORMAT=BI
OUTFIL BUILD=(1,13,82,15,23,58)
/*
Hope this helps...
Cheers
Back to top
Aneesh New User Joined: 30 Sep 2006Posts: 60
Thanks a lot.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
You can now do this kind of thing with the new SELECT WITHANY function of DFSORT's ICETOOL available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//OUT DD DSN=... output file
//TOOLIN DD *
SPLICE FROM(IN) TO(OUT) ON(1,13,CH) WITHANY KEEPNODUPS -
WITH(14,5) WITH(19,5) WITH(24,5) USING(CTL1)
/*
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=(14,4,ZD,EQ,1),
BUILD=(1,13,14:18,5,29:23,58)),
IFTHEN=(WHEN=(14,4,ZD,EQ,2),
BUILD=(1,13,19:18,5,29:23,58)),
IFTHEN=(WHEN=(14,4,ZD,EQ,3),
BUILD=(1,13,24:18,5,29:23,58))
/*
For complete details on the new WITHANY function and the other new functions available with PTF UK90013, see:
Use [URL] BBCode for External Links
Back to top
Please enable JavaScript!