Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Delete spaces in a string

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Aravind Kumar. S

New User


Joined: 28 Apr 2005
Posts: 26

PostPosted: Mon Jul 04, 2005 10:09 am    Post subject: Delete spaces in a string
Reply with quote

Hi,

I want to delete the embedded spaces in a string. plz. tell me how to do that .


Thanks,

Aravind. S
Back to top
View user's profile Send private message

priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Mon Jul 04, 2005 10:17 am    Post subject: Re: Delete spaces in a string
Reply with quote

Hi Aravind,

It will be better if you can give an I/P & O/P string.

Regards,

Priyesh.
Back to top
View user's profile Send private message
Aravind Kumar. S

New User


Joined: 28 Apr 2005
Posts: 26

PostPosted: Mon Jul 04, 2005 10:27 am    Post subject:
Reply with quote

hI Priyesh,

can u explain me in detail.

Thanks,
Aravind
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Mon Jul 04, 2005 10:30 am    Post subject: Re: Delete spaces in a string
Reply with quote

You want to delete embedded Spaces....... means the spaces are located at specific position or.......... whereever see two contiguous spaces we have to delete them......

For example you can give your Input String & Output String ....

Regards,

Priyesh.
Back to top
View user's profile Send private message
Aravind Kumar. S

New User


Joined: 28 Apr 2005
Posts: 26

PostPosted: Mon Jul 04, 2005 11:12 am    Post subject:
Reply with quote

Hi,

Thanks for ur reply.

here's another scenario,

Search string = abcd
IN-STRING = memberabcd

I want to Compare first character of Search string with the characters in IN-STRING until match is found.
If a character is matching, then read the next character in Search string and compare it with the character following the matching character in IN-STRING.
If end of the field in-string is reached and no matching character found display errror.

plz help me to get the solution.

Thanks,
Aravind
Back to top
View user's profile Send private message
Aravind Kumar. S

New User


Joined: 28 Apr 2005
Posts: 26

PostPosted: Mon Jul 04, 2005 11:12 am    Post subject:
Reply with quote

Hi,

Thanks for ur reply.

here's another scenario,

Search string = abcd
IN-STRING = memberabcd

I want to Compare first character of Search string with the characters in IN-STRING until match is found.
If a character is matching, then read the next character in Search string and compare it with the character following the matching character in IN-STRING.
If end of the field in-string is reached and no matching character found display errror.

plz help me to get the solution.

Thanks,
Aravind
Back to top
View user's profile Send private message
Aravind Kumar. S

New User


Joined: 28 Apr 2005
Posts: 26

PostPosted: Mon Jul 04, 2005 1:56 pm    Post subject:
Reply with quote

hi,
regarding that deletion,

input string - main f r ames

o/p string - mainframes (delete all the spaces in between the string)


Thanks,
Aravind
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Mon Jul 04, 2005 2:06 pm    Post subject: Re: Delete spaces in a string
Reply with quote

Quote:

here's another scenario,

Search string = abcd
IN-STRING = memberabcd

I want to Compare first character of Search string with the characters in IN-STRING until match is found.
If a character is matching, then read the next character in Search string and compare it with the character following the matching character in IN-STRING.
If end of the field in-string is reached and no matching character found display errror.


Firstly You should have started a new seperate post for this query....As currently two queries are going in this single post.

Well, for this one I'll not write Code, but will give you an idea to go ahead.

Code:
PERFORM PROCESS UNTILL STR-FILE-END.

PROCESS.
MOVE ZERO TO A
READ STR-FILE INTO STR-REC.
INSPECT STR-REC TALLYING I FOR CHARACTERS BEFORE ' '.
READ CMP-FILE INTO CMP-REC.
INSPECT CMP-REC TALLYING J FOR CHARACTERS BEFORE ' '.
EXIT.

PERFORM COMPARE J TIMES.

COMPARE.
IF A=J                               
       DISPLAY 'NOT MATCHED'         
ELSE                                 
       ADD 1 TO A.                   
       IF STR-REC = CMP-REC(A:I)
       DISPLAY 'RECORD MATCHED'     
END-IF.                             
        EXIT.


You may need to format the code before running, as its a rough sketch.

Regards,

Priyesh.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Mon Jul 04, 2005 2:08 pm    Post subject: Re: Delete spaces in a string
Reply with quote

For above code...

PERFORM COMPARE J TIMES. ....this line will be in PROCESS PARA.

Regards,

Priyesh.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Mon Jul 04, 2005 2:52 pm    Post subject: Re: Delete spaces in a string
Reply with quote

I think this was the original query for what this post was intended...Well....

Quote:
hi,
regarding that deletion,

input string - main f r ames

o/p string - mainframes (delete all the spaces in between the string)


Code:
MOVE 'MAIN F RAME' TO WS-XY.                       
INSPECT WS-XY TALLYING I FOR CHARACTERS BEFORE '  '.
DISPLAY 'LENGTH 'I.                                 
PERFORM MATCH I TIMES. 
DISPLAY 'O/P 'WS-YZ.   

MATCH.                                       
     IF WS-XY(K:1) NOT = ' '                 
              MOVE WS-XY(K:1) TO WS-YZ(Z:1) 
              ADD 1 TO K Z                   
     ELSE                                   
              ADD 1 TO K.                   
     EXIT.     


Arvind, Its not very difficult to bend these stmts acc to your requirements.......the only need is to understand the concept of INSPECT, STRING, UNSTRING verb........

I'll suggest you to go thru thses verbs thoroughly....& then try urself for these queries........You wont find it too difficult......

Regards,

Priyesh.
Back to top
View user's profile Send private message
shobam

New User


Joined: 18 Jul 2005
Posts: 34
Location: CN

PostPosted: Wed Jul 20, 2005 10:12 am    Post subject:
Reply with quote

Hi,

Sorry for the late reply. There is a option called REPLACE in INSPECT.
Did you try that for the removal of spaces in a string.

INSPECT variable REPLACING ALL " " BY ""

Please correct me if I am wrong.

Thanks & Regards
Shobam
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Sort numeric fields with trailing spaces sancraig16 SYNCSORT 7 Tue Apr 03, 2018 1:21 am
No new posts Find & Replace string in CA-SORT mrgnndhmk CA Products 1 Fri Mar 30, 2018 12:58 am
No new posts Find a string in PS file opened in br... mukkas CLIST & REXX 3 Sat Feb 24, 2018 2:15 pm
No new posts load and delete table through JCL wit... ram_vizag JCL & VSAM 9 Thu Feb 01, 2018 12:47 am
No new posts Inefficient BUILD - VB records paddin... Daniel Prosser SYNCSORT 9 Thu Dec 14, 2017 3:52 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us