View previous topic :: View next topic
|
Author |
Message |
Bhargav_1058
New User
Joined: 13 Dec 2008 Posts: 53 Location: New York
|
|
|
|
Hi,
My input file will Key delimited by '|' numerics delimited by '|' amount as shown below. Is there a way to omit the numerics in input file using sort and write an output with Key delimited by '|' and amount? (LRECL=80 and its an FB file).
Input
Code: |
ABCD|05|-1
ABED|1|-2
ADCD|004|15.00
ABCD|0003|-2 |
Required Output
Code: |
ABCD|-1
ABED|-2
ADCD|15.00
ABCD|-2 |
Please suggest if this could be achieved. |
|
Back to top |
|
|
elango_K
New User
Joined: 18 Aug 2011 Posts: 44 Location: India
|
|
|
|
This is certainly possible using 'PARSE' command in DFSORT.
Code: |
//SORTIN DD *
ABCD|05|-1
ABED|1|-2
ADCD|004|15.00
ABCD|0003|-2
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC PARSE=(%01=(ENDBEFR=C'|',FIXLEN=9),%02=(ENDBEFR=C'|',FIXLEN=9),
%03=(FIXLEN=9)),
BUILD=(%01,C'|',%03,80:X)
OUTREC BUILD=(1,80,SQZ=(SHIFT=LEFT))
/*
|
Output
Code: |
ABCD|-1
ABED|-2
ADCD|15.00
ABCD|-2
|
|
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
bhargav_1058,
Use the following DFSORT JCL. I assumed your Key to be 4 bytes and the other data is 75 bytes. key of 4 bytes+delimiter+75=80 bytes
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ABCD|05|-1
ABED|1|-2
ADCD|004|15.00
ABCD|0003|-2
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC PARSE=(%01=(ENDAT=C'|',FIXLEN=5),%=(ENDAT=C'|'),
%02=(FIXLEN=75)),BUILD=(%01,%02)
//* |
|
|
Back to top |
|
|
Bhargav_1058
New User
Joined: 13 Dec 2008 Posts: 53 Location: New York
|
|
|
|
Both sorts gave the desired output. Thanks to both of you for your help Skolusu and Elango...
If I understand correctly...
The %01 parsed field is used to extract the first variable field into an 5-byte fixed parsed field.
The % parsed field is used to skip the second variable field without extracting anything for it, since we don't want this field in the output record. And build the output file with %01 and %02.
I'm glad ... I learned something new today.
This information can also be found here http://publib.boulder.ibm.com/infocenter/zos/v1r11/index.jsp?topic=/com.ibm.zos.r11.iceg200/ice1cg4028.htm |
|
Back to top |
|
|
|