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 

STRING and UNSTRING

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


Joined: 23 Jan 2006
Posts: 65
Topics: 29

PostPosted: Wed Sep 09, 2009 7:05 am    Post subject: STRING and UNSTRING Reply with quote

Hi all,


I have a data which is shown below, Here I want to remove spaces between ',' which is there before zip 07962 and NJ
Code:

MORRISTOWN,    NJ        ,07962

is there any simple way to remove spaces between zip and state?



thanks in advance


suma
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Sep 09, 2009 8:33 am    Post subject: Reply with quote

suma,

Please search before posting. Check this link

http://mvsforums.com/helpboards/viewtopic.php?t=4658&highlight=spaces

http://mvsforums.com/helpboards/viewtopic.php?t=10348&highlight=spaces


Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
suma
Beginner


Joined: 23 Jan 2006
Posts: 65
Topics: 29

PostPosted: Fri Sep 11, 2009 7:43 am    Post subject: Reply with quote

Thanks Kolusu for providing the useful links Smile


I had one more requiremnt to remove spaces between New York and NY, and spaces between , and zip 30348...

Code:
New York                                         NY ,                       30348


for this condition I have changed the code like
Code:

INITIALIZE RECEIVING-FLD
MOVE +1 TO PTR2
MOVE LENGTH OF RECEIVING-FLD TO RECEIVING-FLD-L
MOVE LENGTH OF SENDING-FLD   TO SENDING-FLD-L

PERFORM VARYING PTR1 FROM +1 BY +1
        UNTIL PTR1 > SENDING-FLD-L

  IF PTR2 <= RECEIVING-FLD-L
    IF SENDING-FLD(PTR1:1) NOT = SPACE
      MOVE 'N' TO WS-ONE-SPACE 
      MOVE SENDING-FLD(PTR1:1) TO RECEIVING-FLD(PTR2:1)
      ADD +1 to PTR2
    ELSE
          IF WS-ONE-SPACE  NOT = 'Y'
              MOVE SENDING-FLD(PTR1:1) TO RECEIVING-FLD(PTR2:1)
              ADD +1 to PTR2
              MOVE 'Y' TO WS-ONE-SPACE 
    END-IF
  END-IF

END-PERFORM

so output will be
Code:

New York NY , 30348



regards
Suma
Quote:
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 -> Application Programming 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