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
 

 

Can someone help me in understanding this logic ?

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

New User


Joined: 25 Nov 2010
Posts: 70
Location: Sivakasi, India

PostPosted: Sun Jan 30, 2011 5:19 pm    Post subject: Can someone help me in understanding this logic ?
Reply with quote

This is the program :

Code:
WORKING-STORAGE SECTION.                                       
01 WS-WHOLE PIC IS X(60).                                     
01 WS-COUNTER PIC IS 9(2) VALUE IS 0.                         
PROCEDURE DIVISION.                                           
   MOVE 'SYKFTSSSSSINF FO FEFK KHE KEFT CASES TO' TO WS-WHOLE.
   INSPECT WS-WHOLE TALLYING WS-COUNTER                       
           FOR LEADING 'S' AFTER INITIAL 'T'.                 
   DISPLAY WS-COUNTER.                                         

output for this was :

05

How it scans and take the total count.
I couldnt find it out with the discussion that i had with other people.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8055
Location: East Dubuque, Illinois, USA

PostPosted: Sun Jan 30, 2011 6:59 pm    Post subject:
Reply with quote

Click on Manuals at the top of the page, find the COBOL Language Reference manual, and read chapter 6.2.21 on INSPECT and 6.2.21.3 on the BEFORE and AFTER specifically.

Although I haven't tested on a machine, I would expect that WS-COUNTER would be 05. The initial 'T' is in byte 5 of the varaible. There are 5 characters 'S' immediately after that 'T' that would qualify as leading.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Mon Jan 31, 2011 7:02 pm    Post subject:
Reply with quote

That is just plain english:
initial 'T' => search first 'T'
after => starting on next position
leading 'S' => count all 'S' until you encounter something else
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 Need help in building a logic Benchwarmer All Other Mainframe Topics 4 Wed Feb 22, 2017 2:49 am
No new posts Need Help in understanding what is th... mainakdalal PL/I & Assembler 9 Mon Oct 03, 2016 8:03 pm
No new posts Wildcard logic in COBOL dudenithy COBOL Programming 13 Thu Sep 01, 2016 7:36 pm
No new posts Sort Logic to extract data scorp_rahul23 DFSORT/ICETOOL 13 Tue Mar 01, 2016 1:22 am
No new posts Need a logic to validate the data in ... sandeep kumar302 COBOL Programming 17 Mon Feb 01, 2016 3:30 pm


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