Page 1 of 1

changing a record before the sort

PostPosted: Wed Oct 22, 2014 11:49 pm
by migusd
Hi,
I have some garbage in some of the records that I would like to change.
But because it is a very large file, would like to select first the records I want to replace
So, I am assuming I can use only one IFTHEN-WHEN with several FINDREP.
but I am stuck with the IFTHEN. Got an ugly wer268.
here is the code
  INREC IFTHEN=(WHEN=(51,8,CH,EQ,C'ACTUALX3',OR,51,6,CH,EQ,C'VXY033'), 
                                                                                                                  *
        FINDREP=(ABSPOS=8,INOUT=(X'0T',X'40')),                       
        FINDREP=(ABSPOS=9,INOUT=(X'0T',X'40')),                       
        FINDREP=(ABSPOS=10,INOUT=(X'0T',X'40')),                       
        FINDREP=(ABSPOS=16,INOUT=(X'0T',X'40')))                       
   SORT FIELDS=(51,50,CH,A,1,50,CH,A)                                 
   SUM FIELDS=(102,8,ZD)                                               
   END


So, I changed it a bit like this one:
  INREC IFTHEN=(WHEN=(51,8,CH,EQ,C'ACTUALX3'),                     
                FINDREP=(IN,X'0D',OUT=X'40') STARTPOS=8,ENDPOS=16,
        IFTHEN=(WHEN=(51,6,CH,EQ,C'VXY033'),                       
                FINDREP=(IN,X'0D',OUT=X'40') STARTPOS=8,ENDPOS=16 
   SORT FIELDS=(51,50,CH,A,1,50,CH,A)                             
   SUM FIELDS=(102,8,ZD)                                           
   END 


...Still the same.
What am I missing ? don't get why it is complaing about the last comma at the end of the INREC line.

Thank

Miguel


I need to change a x'0T' to a space before the sort happens.

Code'd

Re: changing a record before the sort

PostPosted: Thu Oct 23, 2014 1:04 am
by migusd
Thank you guys,
at least is running now.

still don't know why it was wrong the INREC, but it is running now

Re: changing a record before the sort

PostPosted: Thu Oct 23, 2014 1:50 am
by BillyBoyo
X'0T' does not exist. Only 0-9 and A-F are valid hex digits.

You can only have one FINDREP per IFTHEN.

FINDREP runs within limits you provide, so maybe you'd not need multiples.

You need to fix up these, then post the full sysout including the message number and text and watch that the location of the "*" is correct, as that shows at what point an error was identified.

Re: changing a record before the sort

PostPosted: Thu Oct 23, 2014 2:22 am
by migusd
Thanks Billy,
I made a few errors, but still don't know what is wrong with this:

SYSIN :
INREC IFTHEN=(WHEN=(51,6,CH,EQ,C'VX033'),
*
FINDREP=(IN,X'0A',OUT=X'40'),STARTPOS=8,ENDPOS=16),
IFTHEN=(WHEN=(51,8,CH,EQ,C'ACTUALX3'),
FINDREP=(IN,X'0A',OUT=X'40'),STARTPOS=8,ENDPOS=16)
SORT FIELDS=(51,50,CH,A,1,50,CH,A)
SUM FIELDS=(102,8,ZD)
END
WER268A INREC STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE

Actually, the * is below the comma after VX033')
Couldn't figure out what was wrong, so I change it to this one instead, and worked fine:
SYSIN :
INREC IFTHEN=(WHEN=(51,5,CH,EQ,C'VX063',OR,51,8,CH,EQ,C'ACTUALX3'),
FINDREP=(INOUT=(X'0A',X'40'),
STARTPOS=8,ENDPOS=16))
SORT FIELDS=(51,50,CH,A,1,50,CH,A)
SUM FIELDS=(102,8,ZD)
END

Still would like to know what is wrong what I missed :)
the x'0t' is my mistake, I was switching back and fore with Character & Hex, so I posted the wrong value. But that is not the issue.

Thanks Billy

Re: changing a record before the sort

PostPosted: Thu Oct 23, 2014 2:34 am
by Terry Heinze
migusd,
Please learn to use Code tags for readability.

Re: changing a record before the sort

PostPosted: Thu Oct 23, 2014 2:37 am
by migusd
I will, Terry...
looking for Code tags... somewhere in here....:)

Thanks

Re: changing a record before the sort

PostPosted: Thu Oct 23, 2014 2:51 am
by Terry Heinze
Use POSTREPLY instead of Quick Reply, click Code, insert (paste) your code between the two tags that show up, click Preview to see what it will look like, click Submit when satisfied.

Re: changing a record before the sort

PostPosted: Thu Oct 23, 2014 3:05 am
by migusd
Ok... thanks Terry.
version with error...

 SYSIN :                                                             
   INREC IFTHEN=(WHEN=(51,5,CH,EQ,C'VX033'),                         
                                           *                         
                 FINDREP=(IN,X'0A',OUT=X'40'),STARTPOS=8,ENDPOS=16)),
         IFTHEN=(WHEN=(51,8,CH,EQ,C'ACTUALX3'),                       
                 FINDREP=(IN,X'0A',OUT=X'40'),STARTPOS=8,ENDPOS=16)   
    SORT FIELDS=(51,50,CH,A,1,50,CH,A)                               
    SUM FIELDS=(102,8,ZD)                                             
    END                                                               
 WER268A  INREC STATEMENT   : SYNTAX ERROR                           
 WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                       


and ... I believe that I now see the issue.
I used 'in,' when I should have used 'in=' in the following line....

Thank you guys

Miguel
and this is the one that worked.

  SYSIN :                                                             
    INREC IFTHEN=(WHEN=(51,5,CH,EQ,C'VX033',OR,51,8,CH,EQ,C'ACTUALX3'),
                  FINDREP=(INOUT=(X'0A',X'40'),                       
                  STARTPOS=8,ENDPOS=16))                               
     SORT FIELDS=(51,50,CH,A,1,50,CH,A)                               
     SUM FIELDS=(102,8,ZD)                                             
     END                                                               

Re: changing a record before the sort

PostPosted: Thu Oct 23, 2014 4:13 am
by BillyBoyo
Good spot. Often it is good to take a break, do something else. Then you see it when you start back. At times you have to go as far as forgetting everything you think you know about the problem before you can find out something you had assumed, and kept looking at, was actually different.

SORT is not designed to be the most helpful of language processors. That "*" sometimes means "I was OK up to that point, then lost the plot", so looking at the next line(s) can be useful. Now you know, it'll be easier next time.

I was going to suggest using INOUT. but you got there anyway.

The only remaining comment is to question the C'VX033'. If it is followed by three spaces, I code them. Saves a potential false hit sometime in the future. If you code it, the next along doesn't query it. If it is for matching leading characters of multiple values. include a comment.

If you want to look to take your SORT-writing further, consider how to use SORT symbols/SYMNAMES at some point.

Re: changing a record before the sort

PostPosted: Thu Oct 23, 2014 8:50 pm
by migusd
Thanks Billy,
interesting stuff about SYMNAME and the dictionary feature... will work on that...
... :) I have to work on other parts as well. I haven't really tried the PARSE... or the BUILD you mentioned in one of my previous posts.

Thanks for your suggestions and tips

Miguel