View previous topic :: View next topic
|
Author |
Message |
kris_madras
New User

Joined: 04 Jul 2005 Posts: 42
|
|
|
|
I have input data like this.
Code: |
----+----1--
ABC 0
DEF
GHI 0
JKL 0
MNO
PQR 0 |
I need to write output data like this
Code: |
----+----1
ABC 0
ABC 9
DEF
GHI 0
GHI 9
JKL 0
JKL 9
MNO
PQR 0
PQR 9 |
When there is '0' at column 10, change value to '9' and write along with original record.
When there is no '0' at column 10, write record as is.
Please help me how to do this in SYNCSORT. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2209 Location: USA
|
|
|
|
Please, read about the statement OUTFIL, and parameters IFTHEN= |
|
Back to top |
|
 |
kris_madras
New User

Joined: 04 Jul 2005 Posts: 42
|
|
|
|
Hi,
I tried below code. I searched our forum and came to know / is used to write next record in the BUILD statement.
Code: |
OUTFIL IFTHEN=(WHEN=(10,1,CH,EQ,C'0'),
BUILD=(1,9,10:C'9'),HIT=NEXT),
IFTHEN=(WHEN=ANY,BUILD=(1,9,10:C'9',/,1,10)) |
but I am getting different output
Code: |
----+----1
ABC 9
ABC 9
DEF
GHI 9
GHI 9
JKL 9
JKL 9
MNO
PQR 9
PQR 9 |
sergeyken wrote: |
Please, read about the statement OUTFIL, and parameters IFTHEN= |
|
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2209 Location: USA
|
|
|
|
This is a very primitive logic:
Code: |
OUTFIL IFTHEN=(WHEN=(10,1,CH,NE,C'0'), without '0'
BUILD=(1,10)), write a single line
IFTHEN=(WHEN=NONE, otherwise
BUILD=(1,10, write two lines
/,1,9,C'9')) mandatory '9' in the second one
|
|
|
Back to top |
|
 |
kris_madras
New User

Joined: 04 Jul 2005 Posts: 42
|
|
|
|
Thanks sergeyken,
The solution worked perfect.
So we need to check first negative condition and then use NONE condition. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2209 Location: USA
|
|
|
|
kris_madras wrote: |
Thanks sergeyken,
The solution worked perfect.
So we need to check first negative condition and then use NONE condition. |
Yes, assuming that the negative condition occurs more often, than positive one.
But it can be done also in opposite order.
Code: |
OUTFIL IFTHEN=(WHEN=(10,1,CH,EQ,C'0'), when '0'
BUILD=(1,10, write two lines
/,1,9,C'9')), mandatory '9' in the second one
IFTHEN=(WHEN=NONE, otherwise
BUILD=(1,10)) write a single line
|
|
|
Back to top |
|
 |
kris_madras
New User

Joined: 04 Jul 2005 Posts: 42
|
|
|
|
Thanks sergeyken,
We took this second solution.
Because the negative condition code sometimes misinterpreted by others. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2209 Location: USA
|
|
|
|
kris_madras wrote: |
Thanks sergeyken,
We took this second solution.
Because the negative condition code sometimes misinterpreted by others. |
Yes, the second one may be more useful, especially when there are other “special types” of records besides “type ‘0’” |
|
Back to top |
|
 |
|
|