|
View previous topic :: View next topic
|
| Author |
Message |
SORTQUERY
New User
Joined: 14 Jul 2010 Posts: 13 Location: United States
|
|
|
|
I have an Input file with group names. Some group names might have corresponding asociation name. Following is a sample
City of Joy - > Group name without an association.
AAA/City of sorrow - > Group name with the association name AAA
Assocation name is usually 3 - 6 bytes.
Requirement is to remove the assoction name and keep only teh Group name.
Any suggestions on how I can achieve this?
Thanks |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
It's not clear what you want to do or what your data actually looks like.
Are the fields in fixed positions, or are they delimited in some way.
Please show a better example of the records in your input file and what you expect for output. Explain the rules for getting from input to output. Give the RECFM and LRECL of the input file. Give the starting position, length and format of the relevant fields, or explain how the fields are delimited if appropriate. |
|
| Back to top |
|
 |
SORTQUERY
New User
Joined: 14 Jul 2010 Posts: 13 Location: United States
|
|
|
|
Input file is Lrecl- 70. It has Group name - position 1,70.
Few Group are associated with an association and have the association initials at the beginning of the name seperated by '/'.
Following is an example.
GROUP NAME 1
GROUP NAME 2
AAAA/GROUP NAME 3
BBB/GROUP NAME 4
CC/GROUP NAME 5
GROUP NAME 6
.
.
.
My output should be of lrecl = 70
GROUP NAME 1
GROUP NAME 2
GROUP NAME 3
GROUP NAME 4
GROUP NAME 5
GROUP NAME 6
.
.
.
I came up with the following -
| Code: |
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(2,1,CH,EQ,C'/'),
BUILD=(1:3,68,C' ')),
IFTHEN=(WHEN=(3,1,CH,EQ,C'/'),
BUILD=(1:3,67,C' ')),
IFTHEN=(WHEN=(4,1,CH,EQ,C'/'),
BUILD=(1:5,66,C' ')),
IFTHEN=(WHEN=(5,1,CH,EQ,C'/'),
BUILD=(1:6,65,C' ')),
IFTHEN=(WHEN=(6,1,CH,EQ,C'/'),
BUILD=(1:7,64,C' ')), |
But this is with an assumption that the association Initials can be of max 6 bytes. This is true for almost all the cases os of now, but there is no check on the length, hence wanted a generic soln.
Let me know if more details are needed. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
use the following DFSORT JCL
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=your input 70 byte FB file,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(1,70,SS,EQ,C'/'),
PARSE=(%=(ENDBEFR=C'/'),%1=(FIXLEN=70)),BUILD=(%1))
//* |
|
|
| Back to top |
|
 |
SORTQUERY
New User
Joined: 14 Jul 2010 Posts: 13 Location: United States
|
|
|
|
Thanks Kolusu, this worked.
My original requirement was a bit different then what I have posted. Posting the origianl requirement for others to refer.
Following is my exact requirement -
Input File - Lrecl - 1100
I need 3 fields in my output file -
Group Number - position , 1050,9
Section - position 1058.4
Group name - position 33,70.
From the Group name - Remove certain special characters.
Following is the sort parm i developed with the forums help, which seems to be working fine.
| Code: |
INREC IFTHEN=(WHEN=(33,70,SS,EQ,C'/'),
PARSE=(%=(ENDBEFR=C'/'),%1=(FIXLEN=70)),
BUILD=(1:1050,9,10:1059,4,14:%1)),
IFTHEN=(WHEN=NONE,
BUILD=(1:1050,9,10:1059,4,14:33,70))
SORT FIELDS=COPY
OUTFIL FINDREP=(INOUT=(C'/',C' ',C'\',C'-',C'$',C' ',
C':',C' ',C'.',C' ',C',',C' ',
C'*',C' ',C'"',C' ',C'=',C'-',
C'?',C' ',C'!',C' ',C'|',C' ',
C'>',C' ',C'<',C' ',C';',C' '))
|
Thanks |
|
| Back to top |
|
 |
SORTQUERY
New User
Joined: 14 Jul 2010 Posts: 13 Location: United States
|
|
|
|
| Is there a way to apply the parsing for '/' only for the first 10 bytes of the Name field? |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
SORTQUERY,
Change your IFTHEN statement to just look for first 10 bytes instead of 70 bytes. |
|
| Back to top |
|
 |
SORTQUERY
New User
Joined: 14 Jul 2010 Posts: 13 Location: United States
|
|
|
|
Thanks Again,  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|