View previous topic :: View next topic |
Author |
Message |
suma Beginner
Joined: 23 Jan 2006 Posts: 65 Topics: 29
|
Posted: Wed Sep 09, 2009 7:05 am Post subject: STRING and UNSTRING |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12380 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
suma Beginner
Joined: 23 Jan 2006 Posts: 65 Topics: 29
|
Posted: Fri Sep 11, 2009 7:43 am Post subject: |
|
|
Thanks Kolusu for providing the useful links
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 |
|
Back to top |
|
 |
|
|