Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Inspect verb usage

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

New User


Joined: 18 Feb 2009
Posts: 8
Location: pune

PostPosted: Thu Feb 26, 2009 9:36 am    Post subject: Inspect verb usage
Reply with quote

HI,

I have the following requirement

I have an input string as ABC XYZ ABC ZZZ

I want the ouput string to be ABC XYZ ZZZ

How can i eliminate the repeating ABC in the above input string using inspect verb

TIA,
PS
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Feb 26, 2009 10:35 am    Post subject:
Reply with quote

Hello and welcome to the forum,

Quote:
How can i eliminate the repeating ABC in the above input string using inspect verb
Inspect is probably not going to do what you want.

You need to post a more clear definition of what is needed.

Will all of the "pieces" always be 3 bytes? Is there something special about ABC or should all duplicates in a line be removed? What if there are other duplicates? There may be other considerations, but only you would know them.
Back to top
View user's profile Send private message
Priti_S

New User


Joined: 18 Feb 2009
Posts: 8
Location: pune

PostPosted: Thu Feb 26, 2009 1:17 pm    Post subject:
Reply with quote

ABC is just an example... u can consider another string as

scott michelle v scott bond scott....

basically i want to count the number of scott repitting in the string...

to be more specific i want to count the number of occurences of the first word(in this case scott) in a string.
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Thu Feb 26, 2009 3:07 pm    Post subject: Reply to: Inspect verb usage
Reply with quote

Priti_S,
there is lot of difference in the suggested requirements in your two posts. Going by
Quote:
to be more specific i want to count the number of occurences of the first word(in this case scott) in a string.

You can try the following code - assuming the length of the input string be 50 bytes.
Code:
Working storage.

 01 PT1 PIC 9(02) VALUE ZEROES.                               
 01 PTEMP-ONE  PIC X(50) VALUE SPACES.                         
 01 PTEMP.                                                     
   02 PTEMP-TWO PIC X(1) OCCURS 1 TO 50 TIMES DEPENDING ON PT1.
 01 SPACE-STATUS   PIC X(1) VALUE 'N'. 
   88 NO-SPACE             VALUE 'N'. 
   88 SPACES-FOUND         VALUE 'Y'.
 
Procedure Division.
PERFORM UNTIL SPACES-FOUND OR I= LENGTH OF PTEMP-ONE
IF PTEMP-ONE(I:1)= SPACES                           
   SET SPACES-FOUND TO TRUE                         
ELSE                                               
   MOVE I TO PT1                                   
   MOVE PTEMP-ONE(I:1)  TO PTEMP-TWO(I)             
END-IF                 
COMPUTE I = I + 1   
END-PERFORM         
INSPECT PTEMP-ONE TALLYING N FOR ALL PTEMP(1:PT1)

N should give you the number of occurrences of the first word. You can work around the code two make it more efficient.

Hope it helps,
WTF
Back to top
View user's profile Send private message
Priti_S

New User


Joined: 18 Feb 2009
Posts: 8
Location: pune

PostPosted: Thu Feb 26, 2009 5:05 pm    Post subject:
Reply with quote

Thanks ..... bit of changes in the above code... solved my purpose.... icon_smile.gif
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 )SEL and )ENDSEL usage cvnlynn TSO/ISPF 4 Thu Jun 15, 2017 1:15 am
No new posts Need inputs on Space requirement and... ashek15 IMS DB/DC 0 Sat Apr 01, 2017 8:26 am
No new posts Inspect statement spoorni COBOL Programming 5 Mon Jun 06, 2016 9:53 pm
No new posts How can amount of the Storage Usage b... esduman61 CICS 6 Wed Mar 09, 2016 1:19 pm
No new posts Controlling usage of resources by tasks raja1128 CICS 3 Fri Nov 06, 2015 9:53 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us