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

To count the no of capital letters and positions


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
swarnasuneel

New User


Joined: 20 Apr 2012
Posts: 20
Location: chennai

PostPosted: Tue May 22, 2012 3:55 pm
Reply with quote

In one of my file the field name is NAME.it contains all the names (with capital ,small letters) my req is count of capital letters and positions of the capital letters in the NAME..can any one help this
Back to top
View user's profile Send private message
Peter cobolskolan

Active User


Joined: 06 Feb 2012
Posts: 104
Location: Sweden

PostPosted: Tue May 22, 2012 4:05 pm
Reply with quote

Try Google INSPECT COBOL and/or take a look here: www.**BANNED***.com/tutorials/programming/cobol/cobol-inspect.html
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue May 22, 2012 5:09 pm
Reply with quote

having a little time on my hands:
Code:

05  ws-caps-count          pic s9(3) comp-3.
    88  no-caps-count      value zero.
05  LENGTH-OF-MOVE         PIC S9(4) BINARY.

05  ws-name-field          pic x(40).

05  ws-name-field-tab
    redefines
    ws-name-field.
    10  ws-name-fld-item   pic x(01)
                           occurs 40 times
                           indexed by name-idx.
        88  name-cap       values 'A' thru 'I'
                                  'J' thru 'R'
                                  'S' thru 'Z'.

05  ws-caps-tab.
    10  ws-caps-item       pic x(01)
                           occurs 40 times
                           indexed by caps-idx.
        15  ws-caps-pos    pic 9(2) DISPLAY.
        15  ws-caps-space  pic x(01).



MOVE <NAME field from record> TO ws-name-field
INITIALIZE WS-CAPS-TAB
           WS-CAPS-COUNT
SET CAPS-IDX        TO 1

PERFORM VARYING NAME-IDX
           FROM 1
             BY 1
          UNTIL NAME-IDX > 40
  IF NAME-CAP(NAME-IDX)   
  THEN
     SET WS-CAPS-POST        TO NAME-IDX
     ADD 1                   TO WS-CAPS-COUNT
     SET CAPS-IDX         UP BY 1
  END-IF
END-PERFORM

IF NO-CAPS-COUNT
THEN
   CONTINUE
ELSE
   COMPUTE LENGTH-OF-MOVE = WS-CAPS-COUNT * 5 END-COMPUTE
   DISPLAY 'RECORD NO: '
           NUM-OF-RECORDS             <<<<<<<<<<NEED A COUNTER ON READ RECORD!!!!
           'NUMBER OF CAPS: '
           WS-CAPS-COUNT       
           WS-CAPS-TAB(1:LENGTH-OF-MOVE)
END-IF
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue May 22, 2012 10:23 pm
Reply with quote

well, since the other 'related' topic is locked,
i will add my comment to this thread.

using A thru Z is a typical error.

refer to the ebcdic table at the bottom of this link.

notice there are 7 values between I & J (and i & J)
and 8 values between R & S (also r & s)

so, you only want to be looking for A thru I, J thru R and S thru Z
to properly address the 26 characters of the alphabet.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue May 22, 2012 10:55 pm
Reply with quote

Peter cobolskolan,

Why advertise a competitor site?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue May 22, 2012 10:59 pm
Reply with quote

this site does not offer tutorials - that's what membership here means,
tutoring rookies.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed May 23, 2012 12:09 am
Reply with quote

Hello,

The "other" topic has been unlocked - thanks to DBZ for the heads up!
Back to top
View user's profile Send private message
Peter cobolskolan

Active User


Joined: 06 Feb 2012
Posts: 104
Location: Sweden

PostPosted: Wed May 23, 2012 12:37 am
Reply with quote

Bill,
I just looked at the tutorial, and didn't see this as a competitor, but when I now look a bit more, I also found a forum.
Sorry for the mistake, but the tutorial is still useful.
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 To get the count of rows for every 1 ... DB2 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
No new posts Count the number of characters in a f... CA Products 1
Search our Forums:

Back to Top