IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Can someone help me in understanding this logic ?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sun Jan 30, 2011 6:59 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Finding faulty logic Subscript out of... COBOL Programming 5
This topic is locked: you cannot edit posts or make replies. Need assistance in job scheduling logic. Mainframe Interview Questions 2
No new posts Rexx Logic error while adding seperat... CLIST & REXX 3
No new posts PL/1 Callback address logic in z/OS C... PL/I & Assembler 1
No new posts Sync logic between VSAM files and DB2... COBOL Programming 9
Search our Forums:

Back to Top