View previous topic :: View next topic
|
Author |
Message |
Virendra Shambharkar
New User
Joined: 26 Aug 2015 Posts: 55 Location: India
|
|
|
|
We are trying to explore if we can count the trailing spaces in a variable string after a string constant using syncsort.
If we have below situations :-
1) Position of Constant String ‘AAAAAAA’ is fixed then can we count the trailing spaces using sort.
‘xxxxxxxxxxxxxxxxxxxxxxAAAAAAA ‘
‘xxxxxxxxxxxxx AAAAAAA ‘
‘x AAAAAAA ‘
2) Position of Constant String ‘AAAAAAA’ is not fixed then can we count the trailing spaces using sort.
‘xxxxxxxxxxxxxxxxxxxxxxAAAAAAA ‘
‘xxxxxxxxxxxxxxAAAAAAA ‘
‘xAAAAAAA ‘
If somebody knows a sample sort card that can be used in this it will be helpful.
Thanks in advance. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Well, the way you posted the data, there is ONE space in each case. You know you should use the code tags to present your data. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
I believe this should be doable, but why do you want to take the trouble of counting it! Do you mind explaining a bit more on what you are trying to achieve by this. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2010 Location: USA
|
|
|
|
The only useful operation that could be done on the trailing spaces when RECFM=VB is: truncation of all of them.
It can be done easily by SYNCSORT parameters/options, just RTFM.
Any other desire to count the number of trailing spaces via SYNCSORT, as I can guess, just reminds an attempt to play a new unexplored computer game. What could be the purpose of it??? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
It can be done. You need to provide the explanation Arun has asked for, and provide things like RECFM, LRECL, maximum that the field can be, does data follow the field, and provide representative sample data and expected output. |
|
Back to top |
|
|
Virendra Shambharkar
New User
Joined: 26 Aug 2015 Posts: 55 Location: India
|
|
|
|
Thanks for responding , our purpose is to calculate the actual lenght of the string and the valid lenght of the string is only until AAAAAAA. If we need to count the lenght of variable until this point where the postion of AAAAAAA can vary then can it be done using syncsort. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
Back to top |
|
|
Virendra Shambharkar
New User
Joined: 26 Aug 2015 Posts: 55 Location: India
|
|
|
|
Thanks , we were able to figure out how to do this using SORT. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Ah, an exercise in recursion. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Yes, the questions hadn't been answered.
Virendra Shambharkar,
Would you mind sharing the code? I'm impressed you got it, and some more examples are always useful. Thanks. |
|
Back to top |
|
|
Virendra Shambharkar
New User
Joined: 26 Aug 2015 Posts: 55 Location: India
|
|
|
|
Below are the sort cards one of our colleagues suggested and it works. We tested it on a 900 byte string
Code: |
SORT FIELDS=COPY
INREC PARSE=(%00=(ENDAT=C'AAAAAAA',FIXLEN=900)),
BUILD=(%00)
OUTFIL INCLUDE=(1,900,SS,EQ,C'AAAAAAA'),FTOV,VLTRIM=C' '
SORT FIELDS=COPY
OUTFIL VTOF,BUILD=(1,2,BI,SUB,+11,EDIT=(IIIIIT),30:X),
REMOVECC |
|
|
Back to top |
|
|
|