View previous topic :: View next topic
|
Author |
Message |
sasikumar1984
Active User
Joined: 02 Jul 2007 Posts: 109 Location: Chennai - India
|
|
|
|
Hi,
My input file is something like this.
Code: |
ABCD XY.TEST.JCL
ACF XYZ.TEST.JCL
ABYT T54VSES.TEST.LIB
|
My output file should be as below
Code: |
ABCD XY.TEST.JCL XY
ACF XYZ.TEST.JCL XYZ
ABYT T54VSES.TEST.LIB T54VSES
|
There is a library name starts at 20th position in the input file, so i need only the high level qualifier of that library at end of each record in my output file. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Try this
Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ABCD XY.TEST.JCL
ACF XYZ.TEST.JCL
ABYT T54VSES.TEST.LIB
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
PARSE=(%01=(ABSPOS=1,ENDAT=C' ',FIXLEN=7),
%02=(ABSPOS=8,FIXLEN=8,ENDBEFR=C'.')),
BUILD=(1:1,50,51:%02)) |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Have a look at PARSE with the option to start from a particular colmn (20), end before your ".", and then use OVERLAY to locate the PARSEd field in the desired position. |
|
Back to top |
|
|
sasikumar1984
Active User
Joined: 02 Jul 2007 Posts: 109 Location: Chennai - India
|
|
|
|
Thanks Pandora and Bill...
i changed the code as below and it is working fine for me....
Code: |
OPTION COPY
OUTREC PARSE=(%01=(ABSPOS=10,ENDBEFR=C'.',FIXLEN=8)),
BUILD=(1:1,50,51:%01)
|
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Code: |
BUILD=(1:1,50,51:%01) |
Whenever BUILD executes it makes a new copy of the current data record, which contains only the fields specified on the BUILD.
Whenever OVERLAY within the length of the existing record executes, it only amends data at the column positions specified in the OVERLAY, all other data remains the same one the same current record.
OVERLAY is a better "fit" to describe what you are doing. OVERLAY will generally require fewer resources.
Where OVERLAY extends an existing record, a new copy of the current data record is created, exactly as with BUILD, but there is no danger of "losing" any of the original input, as you don't have to type the fields, DFSORT is doing it.
When selecting fields from a record, use BUILD. When changing some data in the same position(s)/length(s) on a record or adding a field(s) as an extension to a fixed-length record, use OVERLAY. If OVERLAY wasn't useful, it wouldn't be there.
These are my Rules of Opposable Digits. So as I don't make a ROD for my own back, I can change them if I feel like it. |
|
Back to top |
|
|
|