Page 1 of 2

Need help sort

PostPosted: Thu May 16, 2013 7:27 pm
by shailaja85
Hi,

Can some one help me please?

need to check first 3 digits, if it is non-zero(NZ) then in output it has NZ, if it is zero(ZE) then at end of the record it has to display ZE


my i/p is like below

111 AAA
222 BBB
000 CCC
333 DDD
000 EEE


Expected output
111 AAA NZ
222 BBB NZ
000 CCC ZE
333 DDD NZ
000 EEE ZE

Re: Need help sort

PostPosted: Thu May 16, 2013 8:21 pm
by BillyBoyo
Have you tried anything? Have you a access to a SyncSort manual? If not, you should get one.

You can find a lot of example code here. You're going to need OPTION COPY (or SORT FIELDS=COPY), INREC IFTHEN=(WHEN=condition and OVERLAY. Have a crack at it. Let us know if you get stuck.

Re: Need help sort

PostPosted: Thu May 16, 2013 9:18 pm
by shailaja85
I have tried with the below
 SORT FIELDS=COPY,             
     IFTHEN=(WHEN=(1,3,EQ,0)),
     OVERLAY=(30:C'ZE')   


I am getting below error

SORT FIELDS=COPY,                       
    IFTHEN=(WHEN=(1,3,EQ,0)),           
    *                                   
    OVERLAY=(30:C'ZE')                 
R268A  SORT STATEMENT    : SYNTAX ERROR

Re: Need help sort

PostPosted: Thu May 16, 2013 9:26 pm
by enrico-sorichetti
if You had just searched the forum You would have found the right syntax without asking.

Re: Need help sort

PostPosted: Fri May 17, 2013 12:52 am
by shailaja85
SORT FIELDS=COPY                 
INREC IFTHEN=(WHEN=(1,3,ZD,EQ,0),
BUILD=(1,39,40:C'ZE'))   


********************************* TOP OF D
111 AAA                                   
222 BBB                                   
000 CCC                                ZE
333 DDD                                   
******************************** BOTTOM OF


How I can write one more condition to come NZ(not eq zero)

Re: Need help sort

PostPosted: Fri May 17, 2013 12:59 am
by Akatsukami
shailaja85 wrote:
SORT FIELDS=COPY                 
INREC IFTHEN=(WHEN=(1,3,ZD,EQ,0),
[code]    BUILD=(1,39,40:C'ZE'))   


********************************* TOP OF D
111 AAA                                   
222 BBB                                   
000 CCC                                ZE
333 DDD                                   
******************************** BOTTOM OF




how i can writre one more condition to come NZ(not eq zero)

You are jesting, yes?

Re: Need help sort

PostPosted: Fri May 17, 2013 1:05 am
by BillyBoyo
You can try by just adding another IFTHEN. The IFTHEN is part of the INREC, so you'll need a "continuation" for your existing IFTHEN (a comma after the final closing-bracket).

Another was is with IFTHEN=(WHEN=INIT, which goes first and which is executed for every record. On that you can set to NZ, with the zero condition overwriting the value later.

There is also IFTHEN=(WHEN=NONE, which goes after the IFTHEN=(WHEN=(condition, and is executed for records which have not had a true test against them.

Best thing is to read up in the manual, look at some examples, ensure you understand them, experiment until you do, and then choose one of the above methods.

Re: Need help sort

PostPosted: Sat May 18, 2013 9:57 am
by shailaja85
Hi,

Could you please provide links/documents/examples of IFTHEN=(WHEN=INIT.
many thanks for your anticipated help.

Re: Need help sort

PostPosted: Sat May 18, 2013 10:16 am
by enrico-sorichetti

Re: Need help sort

PostPosted: Sat May 18, 2013 12:19 pm
by BillyBoyo
If you see the Search box at the start of your topic, put INIT in there and see what you can find.