MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Removes spaces between a text string and a delimiter

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
hisabarinath
Beginner


Joined: 25 Apr 2008
Posts: 36
Topics: 8
Location: Baltimore, USA

PostPosted: Wed Apr 22, 2009 10:45 am    Post subject: Removes spaces between a text string and a delimiter Reply with quote

How to remove spaces between a text String and the Pipe ('|') delimiter. I have the input file like below. The Input file is a 80 byte FB record.

Input file
Code:
AAA   |CCCC  |56789 |RRRR|
AAATT   |XXCCCC  |589   |WERRRR|
AAA   |CCCC  |56789 |RRRTTT  |
R |zzzCC|5556789|RR   |


After removing spaces between Pipe and the String the file should be like below-
Code:
AAA|CCCC|56789|RRRR|
AAATT|XXCCCC|589|WERRRR|
AAA|CCCC|56789|RRRTTT|
R|zzzCC|5556789|RR|
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Apr 22, 2009 10:56 am    Post subject: Reply with quote

hisabarinath,

The following DFSORT JCL will give you the desired results. I assumed that your input is FB and 80 bytes LRECL

Code:

//STEP0100 EXEC PGM=SORT             
//SYSOUT   DD SYSOUT=*               
//SORTIN   DD *                       
AAA   |CCCC  |56789 |RRRR|           
AAATT   |XXCCCC  |589   |WERRRR|     
AAA   |CCCC  |56789 |RRRTTT  |       
R |ZZZCC|5556789|RR   |               
//SORTOUT  DD SYSOUT=*               
//SYSIN    DD *                       
  SORT FIELDS=COPY                   
  INREC BUILD=(1,80,SQZ=(SHIFT=LEFT))
/*                                   

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
hisabarinath
Beginner


Joined: 25 Apr 2008
Posts: 36
Topics: 8
Location: Baltimore, USA

PostPosted: Wed Apr 22, 2009 11:36 am    Post subject: Reply with quote

Great Kolusu.. Thanks.

But the problem is, if there is any spaces in between the field1's or Field2's.. String that is also removed from your Code, But we dont want to remove any space between the Strings or Leading Strings For example-
Code:
A  AA   |CCCC  |56789 |RRRR|
AA   ATT   |XXCCCC  |589   |WERRRR|



The Output should be like below,
Code:
A AA|CCCC|56789|RRRR|
AA ATT|XXCCCC|589|WERRRR|


We need to remove only trailing spaces between Strings and the Delimiter ('|'). Thanks again Kolusu.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Apr 22, 2009 12:12 pm    Post subject: Reply with quote

hisabarinath,

If you want to preserve the spaces then use FINDREP, I just coded removing up to 10 spaces and the delimiter. You can change it according to your needs

Code:

//SYSIN    DD *                               
  SORT FIELDS=COPY                           
  INREC FINDREP=(IN=(C' |',                   
                     C'  |',                 
                     C'   |',                 
                     C'    |',               
                     C'     |',               
                     C'      |',             
                     C'       |',             
                     C'        |',           
                     C'         |'),OUT=C'|')
/*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
hisabarinath
Beginner


Joined: 25 Apr 2008
Posts: 36
Topics: 8
Location: Baltimore, USA

PostPosted: Wed Apr 22, 2009 1:18 pm    Post subject: Reply with quote

Kolusu - I'm unable to get the solution. By using this logic FINDREP

Going back to your simple logic
INREC BUILD=(1,80,SQZ=(SHIFT=LEFT))

Are there any way that i can skip the first filed by using the SQZ logic. Since the first field's String only have the spaces in between the words all other fields are NOT having any spaces inbetween or leading.

So, is there any way that i can use the STARTPOS=NNN when build the output file.
NNN - would be the starting postion of the SHIFT
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Apr 22, 2009 1:23 pm    Post subject: Reply with quote

hisabarinath wrote:
Kolusu - I'm unable to get the solution. By using this logic FINDREP


What do you mean by that? Are you getting a syntax error? or does it not work?

hisabarinath wrote:
Going back to your simple logic
INREC BUILD=(1,80,SQZ=(SHIFT=LEFT))

Are there any way that i can skip the first filed by using the SQZ logic. Since the first field's String only have the spaces in between the words all other fields are NOT having any spaces inbetween or leading.

So, is there any way that i can use the STARTPOS=NNN when build the output file.
NNN - would be the starting postion of the SHIFT


yes you can , use the following control cards

Code:

//SYSIN   DD *
  SORT FIELDS=COPY
  INREC OVERLAY=(p:p,m,SQZ=(SHIFT=LEFT))
//*
//*  p = starting position from where you want to strip the spaces
//*  m = length of string you want to strip the spaces

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
hisabarinath
Beginner


Joined: 25 Apr 2008
Posts: 36
Topics: 8
Location: Baltimore, USA

PostPosted: Wed Apr 22, 2009 1:39 pm    Post subject: Reply with quote

Thanks Kolusu. This way the output file that we are getting from position 'p' but i need the entire 80 byte record NOT from starting position 'p'
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Wed Apr 22, 2009 2:08 pm    Post subject: Reply with quote

can't wait for the next 'undisclosed' requirement.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Apr 22, 2009 2:19 pm    Post subject: Reply with quote

hisabarinath wrote:
Thanks Kolusu. This way the output file that we are getting from position 'p' but i need the entire 80 byte record NOT from starting position 'p'


What makes you think that you are not getting the entire file? I used OVERLAY. Did you even run the job before you made that statement?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
hisabarinath
Beginner


Joined: 25 Apr 2008
Posts: 36
Topics: 8
Location: Baltimore, USA

PostPosted: Wed Apr 22, 2009 2:53 pm    Post subject: Reply with quote

Yes, i run with OVERLAY=(Start Positioin, Length,SQZ...) But the output record writes only starts from Starting Postion, NOT the entire 80 Byte record length.
Back to top
View user's profile Send private message
hisabarinath
Beginner


Joined: 25 Apr 2008
Posts: 36
Topics: 8
Location: Baltimore, USA

PostPosted: Wed Apr 22, 2009 2:54 pm    Post subject: Reply with quote

The SYSIN i have used..

Code:
//SYSIN     DD *                                     
  SORT FIELDS=COPY                                   
  INREC OVERLAY=(10,70,SQZ=(SHIFT=LEFT))             
//*
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Apr 22, 2009 3:02 pm    Post subject: Reply with quote

hisabarinath,

bonk Pay attention to the control cards I posted

Quote:
INREC OVERLAY=(p:p,m,SQZ=(SHIFT=LEFT))


You are missing the bold part in your control cards
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
hisabarinath
Beginner


Joined: 25 Apr 2008
Posts: 36
Topics: 8
Location: Baltimore, USA

PostPosted: Wed Apr 22, 2009 3:10 pm    Post subject: Reply with quote

Kolusu - You always Great... I have to find another vocabulary to prize/proud you. Thank you so much.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group