View previous topic :: View next topic
|
Author |
Message |
amardeep_sahoo
New User
Joined: 21 Oct 2008 Posts: 4 Location: India
|
|
|
|
Hi! I have a problem related to SORT utility. I want to check certain conditions while copying from sortin to sortout.
If the condition satisfies, then i need a particular character constant in a particular position of the output rec. If the condition is not satisfied, then it should copy the input rec as it is as per the position specified in the outrec.
Could anyone help me on this? |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
You need to post sample input data with file specification like LRECL, RECFM and also expected output. |
|
Back to top |
|
|
amardeep_sahoo
New User
Joined: 21 Oct 2008 Posts: 4 Location: India
|
|
|
|
Input data I have is as below:
2008103018500313502008103022595379PAL00015612632FE
2008103018500313502008103022595379PAL01023277632FE
2008103018500313502008103022595379PAL04016452632FE
In the output dataset, I want
1. At the first 9 positions in the output file, I want the 9 characters from position 37 of the input file.
2. I want the records to be copied into the output file starting from the 22nd record in the output file.
2. At the end, I want to have a ')' symbol in the output file.
The file should look like this:
.
.
.
.
L00015612 (This should be the 22nd record in the outputfile)
L01023277
L04016452
) |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Does output dataset is already present and have 21 records?
or it has many records and you want to insert your records starting from 22nd record? |
|
Back to top |
|
|
amardeep_sahoo
New User
Joined: 21 Oct 2008 Posts: 4 Location: India
|
|
|
|
The output dataset is already present and already has 21 records.
I want to start inserting from the 22nd record. |
|
Back to top |
|
|
keyarika
New User
Joined: 24 May 2008 Posts: 10 Location: bangalore
|
|
|
|
Hi,
Have you treid anything!! |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
Quote: |
I want to check certain conditions while copying from sortin to sortout.
|
Can you elaborate on this ?
Gerry |
|
Back to top |
|
|
amardeep_sahoo
New User
Joined: 21 Oct 2008 Posts: 4 Location: India
|
|
|
|
I have just tried
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1:37,9)
SUM FIELDS=NONE
/*
This only copies the fields starting from position 37 till 9 characters into the output file.
But I need the sort to start writing from record 22 in the output file and at the end of the list I need it to insert a ')' symbol. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
I assume you need first 21 lines of output file as blank records and then required records and last record as '('
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//INP1 DD *
2008103018500313502008103022595379PAL00015612632FE
2008103018500313502008103022595379PAL01023277632FE
2008103018500313502008103022595379PAL04016452632FE
/*
//INP2 DD *
DUMMY RECORD
/*
//OUT1 DD DSN=outputfilename,DISP=(MOD,CATLG,DELETE),
// LRECL=80,RECFM=FBA
//TOOLIN DD *
COPY FROM(INP2) TO(OUT1) USING(CTL1)
COPY FROM(INP1) TO(OUT1) USING(CTL2)
/*
//CTL1CNTL DD *
OPTION COPY
OUTFIL FNAMES=OUT1,REPEAT=21,BUILD=(80X)
/*
//CTL2CNTL DD *
INREC FIELDS=(37,9,80:X)
OUTFIL FNAMES=OUT1,REMOVECC,TRAILER1=('(')
/*
|
|
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
You can do this kind of thing quite easily and efficiently with the new DATASORT function of DFSORT available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this. The first 21 records are copied as is and starting from 22nd record we take 9 bytes from pos 37 and sort and remove the duplicates and append a ')' at the end of the list.
Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
RECORD 01
RECORD 02
RECORD 03
RECORD 04
RECORD 05
RECORD 06
RECORD 07
RECORD 08
RECORD 09
RECORD 10
RECORD 11
RECORD 12
RECORD 13
RECORD 14
RECORD 15
RECORD 16
RECORD 17
RECORD 18
RECORD 19
RECORD 20
RECORD 21
2008103018500313502008103022595379PAL00015612632FE
2008103018500313502008103022595379PAL00015612632FE
2008103018500313502008103022595379PAL01023277632FE
2008103018500313502008103022595379PAL01023277632FE
2008103018500313502008103022595379PAL04016452632FE
//OUT DD SYSOUT=*
//TOOLIN DD *
DATASORT FROM(IN) TO(OUT) HEADER(21) USING(CTL1)
//CTL1CNTL DD *
INREC BUILD=(37,9,80:X)
SORT FIELDS=(1,9,CH,A)
SUM FIELDS=NONE
OUTFIL FNAMES=OUT,REMOVECC,TRAILER1=(')')
/*
|
The output from this job is
Code: |
RECORD 01
RECORD 02
RECORD 03
RECORD 04
RECORD 05
RECORD 06
RECORD 07
RECORD 08
RECORD 09
RECORD 10
RECORD 11
RECORD 12
RECORD 13
RECORD 14
RECORD 15
RECORD 16
RECORD 17
RECORD 18
RECORD 19
RECORD 20
RECORD 21
L00015612
L01023277
L04016452
)
|
For complete details on the new DATASORT and the other new functions available with PTF UK90013, see:
Use [URL] BBCode for External Links
Hope this helps...
Cheers |
|
Back to top |
|
|
|