|
View previous topic :: View next topic
|
| Author |
Message |
Magna
New User
Joined: 30 Oct 2006 Posts: 24
|
|
|
|
I have a file with header,trailer and detial record.
I need to change the first three position of these records with different values.
and the syntax am using for this in syncsort is
SORT FIELDS=COPY
OUTREC FIELDS=(1,3,CHANGE=(3,C'xxx',C'yyy',
C'aaa',C'bbb',
C'ccc',C'ddd'),4,157)
Here in header I have XXX which I'm changinf to YYY
and in detail i have AAA which I'm changing to BBB
and in trailer i have ccc and i'm changing that to ddd
I need to add one more condition
where i need to change the 7th position(that field is of length 13)
in my header and trailer to some other value of same length.
I need to include this condition in the same sort card.
Could someone tell me the syntax for that in syncsort.
The file length is 160. |
|
| Back to top |
|
 |
priyesh.agrawal
Senior Member

Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Use syntax like below for all your conditions to replace first 3 chars...
| Code: |
SORT FIELDS = COPY
OUTREC = (1:1,3,
CHANGE=(3,C'TTT',C'YYY',C'AAA',C'BBB',C'CCC',C'DDD'),NOMATCH=(1,3),
4:4,157) |
To replace 13 chars starting at 7th position in Header & Trailer, do you have any specific values coming into that field.? |
|
| Back to top |
|
 |
Magna
New User
Joined: 30 Oct 2006 Posts: 24
|
|
|
|
Yes I have a value for that 13 length field which is
POST POSITION
and i need to change it to
POST ACTIVITY |
|
| Back to top |
|
 |
priyesh.agrawal
Senior Member

Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
okay... then use the below mentioned SORT CARD...
| Code: |
SORT FIELDS = COPY
OUTREC = (1:1,3,
CHANGE=(3,C'TTT',C'YYY',C'AAA',C'BBB',C'CCC',C'DDD'),NOMATCH=(1,3),
4:4,3,
7:7,13,
CHANGE=(13,C'POST POSITION',C'POST ACTIVITY',NOMATCH=(7,13),
20:20,141) |
Note: Any of your DETAIL records containing "POST POSITION" at 7-13 positions would also be converted to "POST ACTIVITY". So make sure you dont have any such record in DETAIL Records before running the query.
To resolve this; what else is there in positions 4-6 in your HEADER & TRAILER records. |
|
| Back to top |
|
 |
Magna
New User
Joined: 30 Oct 2006 Posts: 24
|
|
|
|
I may get a value of 001 or 002 or 003 or 004 in the position 4-6
but i don't want to change that position... would that create any problem...
The condition u gave worked fine...
Thanks a lot.... |
|
| Back to top |
|
 |
priyesh.agrawal
Senior Member

Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
| Quote: |
I may get a value of 001 or 002 or 003 or 004 in the position 4-6
but i don't want to change that position... would that create any problem... |
No that would not create a problem... I asked to make conditions more specific.
| Quote: |
The condition u gave worked fine...
Thanks a lot.... |
Thats fine... but did you notice the note made in my earlier reply. If that is not the case, this SORT is perfact, otherwise we may need to update the SORT CARD. |
|
| Back to top |
|
 |
Magna
New User
Joined: 30 Oct 2006 Posts: 24
|
|
|
|
nope I'll not get that value in the position 7 in my detail records.
but if am going to get it how can we handle that condition? |
|
| Back to top |
|
 |
priyesh.agrawal
Senior Member

Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
| Quote: |
| nope I'll not get that value in the position 7 in my detail records. |
Then we are fine with the code given above.
| Quote: |
| but if am going to get it how can we handle that condition? |
I would put two different SORT CARDS for DETAIL and HEADER/TRAILER.
| Code: |
SORT FIELDS = COPY
OUTREC = (1:3,
CHANGE=(3,C'AAA',C'BBB',NOMATCH=(1,3),
4:4,157) |
| Code: |
SORT FIELDS = COPY
OUTREC = (1:19,
CHANGE=(19,C'TTT001POST POSITION',C'YYY001POST ACTIVITY',
C'TTT002POST POSITION',C'YYY002POST ACTIVITY',
C'TTT003POST POSITION',C'YYY003POST ACTIVITY',
C'TTT004POST POSITION',C'YYY004POST ACTIVITY',
C'CCC001POST POSITION',C'DDD001POST ACTIVITY',
C'CCC002POST POSITION',C'DDD002POST ACTIVITY',
C'CCC003POST POSITION',C'DDD003POST ACTIVITY',
C'CCC004POST POSITION',C'DDD004POST ACTIVITY',
NOMATCH=(1,19),
20:20,141) |
|
|
| Back to top |
|
 |
Magna
New User
Joined: 30 Oct 2006 Posts: 24
|
|
|
|
| Oh thats really useful... Thanks... |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|