IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search Log in to check your private messages Log in
 

Count Trailing Spaces in variable string after a constant S


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

New User


Joined: 26 Aug 2015
Posts: 55
Location: India

PostPosted: Thu Feb 02, 2017 12:23 pm
Reply with quote

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

Global Moderator


Joined: 10 May 2007
Posts: 2432
Location: Hampshire, UK

PostPosted: Thu Feb 02, 2017 3:54 pm
Reply with quote

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

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Feb 02, 2017 7:17 pm
Reply with quote

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

Active Member


Joined: 29 Apr 2008
Posts: 879
Location: Maryland

PostPosted: Thu Feb 02, 2017 9:52 pm
Reply with quote

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

PostPosted: Thu Feb 02, 2017 10:46 pm
Reply with quote

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

New User


Joined: 26 Aug 2015
Posts: 55
Location: India

PostPosted: Fri Feb 03, 2017 10:02 am
Reply with quote

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

PostPosted: Fri Feb 03, 2017 12:37 pm
Reply with quote

See here.
Back to top
View user's profile Send private message
Virendra Shambharkar

New User


Joined: 26 Aug 2015
Posts: 55
Location: India

PostPosted: Fri Feb 03, 2017 1:32 pm
Reply with quote

Thanks , we were able to figure out how to do this using SORT.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Fri Feb 03, 2017 7:58 pm
Reply with quote

Quote:
See here.

Ah, an exercise in recursion. icon_smile.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

PostPosted: Fri Feb 03, 2017 8:20 pm
Reply with quote

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

New User


Joined: 26 Aug 2015
Posts: 55
Location: India

PostPosted: Mon Feb 06, 2017 8:56 am
Reply with quote

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
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

 

Search our Forum:

Similar Topics
Topic Forum Replies
No new posts FILE STATUS - 39 ON VARIABLE LENGTH V... COBOL Programming 1
No new posts Need to split single line into two li... DFSORT/ICETOOL 7
No new posts how to get total count from numeric d... SYNCSORT 9
No new posts Creating a single-record file with CO... DFSORT/ICETOOL 8
No new posts Unable to display comp variable COBOL Programming 4

Back to Top