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
 

 

To count the no of capital letters and positions

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: To count the no of capital letters and positions
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    Post subject: Reply to: To count the no of capital letters,positions in a
Reply with quote

Try Google INSPECT COBOL and/or take a look here: http://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    Post subject:
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue May 22, 2012 10:55 pm    Post subject: Reply to: To count the no of capital letters,positions in a
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    Post subject:
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

Site Director


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

PostPosted: Wed May 23, 2012 12:09 am    Post subject:
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    Post subject: Reply to: To count the no of capital letters,positions in a
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    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 abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Update the Sortout file with record c... karthik_sripal SYNCSORT 8 Tue May 17, 2016 8:52 pm
No new posts CQM : Exec count is 0 but getpages &g... soundarr DB2 1 Thu Mar 17, 2016 10:08 pm
No new posts File matching with PD key on differen... hiravibk DFSORT/ICETOOL 2 Wed Feb 17, 2016 11:40 pm


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