IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Write record twice based on condition in SYNCSORT


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kris_madras

New User


Joined: 04 Jul 2005
Posts: 42

PostPosted: Wed May 14, 2025 4:47 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2209
Location: USA

PostPosted: Wed May 14, 2025 4:55 pm
Reply with quote

Please, read about the statement OUTFIL, and parameters IFTHEN=
Back to top
View user's profile Send private message
kris_madras

New User


Joined: 04 Jul 2005
Posts: 42

PostPosted: Wed May 14, 2025 5:06 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2209
Location: USA

PostPosted: Wed May 14, 2025 5:29 pm
Reply with quote

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
View user's profile Send private message
kris_madras

New User


Joined: 04 Jul 2005
Posts: 42

PostPosted: Wed May 14, 2025 5:52 pm
Reply with quote

Thanks sergeyken,

The solution worked perfect.
So we need to check first negative condition and then use NONE condition.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2209
Location: USA

PostPosted: Wed May 14, 2025 6:03 pm
Reply with quote

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
View user's profile Send private message
kris_madras

New User


Joined: 04 Jul 2005
Posts: 42

PostPosted: Thu May 15, 2025 2:49 pm
Reply with quote

Thanks sergeyken,

We took this second solution.
Because the negative condition code sometimes misinterpreted by others.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2209
Location: USA

PostPosted: Thu May 15, 2025 4:13 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Setting RC using NULLOFL/NOTMTOFL for... SYNCSORT 6
No new posts Create a specific record/file based o... SYNCSORT 8
No new posts Sort to insert record in an empty file. DFSORT/ICETOOL 5
No new posts Syncsort help SYNCSORT 3
No new posts Copy only TEXT or String from a record SYNCSORT 4
Search our Forums:


Back to Top