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 get alphabet count in variable

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

New User


Joined: 05 Oct 2010
Posts: 9
Location: Chandigarh

PostPosted: Wed Nov 27, 2013 8:31 pm    Post subject: To get alphabet count in variable
Reply with quote

Hi ,

I have one variable WS-TEST PIC X(10) VALUE 'ABC1D67892'
I want to get the count of leading alphabets i.e it should give me '3' in above case or if it is 'ABCD123456' it should give me count as '4'

how can i use Inspect verbin this case
Back to top
View user's profile Send private message

Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Wed Nov 27, 2013 8:36 pm    Post subject:
Reply with quote

What do you expect

when

Code:
"0BCD123456"
" BCD123456"
"A 123456"
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 Nov 27, 2013 9:03 pm    Post subject:
Reply with quote

Hello,

Is there some particular reason to use INSPECT?
Back to top
View user's profile Send private message
rupeshgullu

New User


Joined: 05 Oct 2010
Posts: 9
Location: Chandigarh

PostPosted: Wed Nov 27, 2013 9:24 pm    Post subject: Reply to: To get alphabet count in variable
Reply with quote

Actually I have verified that data will be like 'ABCD123456' or 'ABC1D56789' it won't be as specified.

I want to use the count which comes while inspecting for processing down the line in program . That's why I want to use inspect
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Wed Nov 27, 2013 9:26 pm    Post subject:
Reply with quote

Ok so the count would be atleast 3 and max of 4?
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Nov 27, 2013 10:07 pm    Post subject: Reply to: To get alphabet count in variable
Reply with quote

Give this a try (Only desk checked) -

Code:

           03  WS-TEST             PIC X(10) VALUE 'ABC1D67892'.       
           03  WS-ALPHA-KTR        PIC 9(08) COMP.                     
      *                                                                 
           MOVE ZERO                   TO WS-ALPHA-KTR.                 
           MOVE ZERO                   TO TALLY.                       
      *                                                                 
           PERFORM UNTIL TALLY > LENGTH OF WS-TEST                     
               IF (WS-TEST (TALLY:1) ALPHABETIC                         
               AND WS-TEST (TALLY:1) NOT = SPACE)                       
                   ADD  1               TO WS-ALPHA-KTR                 
               END-IF                                                   
               ADD  1                   TO TALLY                       
           END-PERFORM.                                                 

Once the PERFORM completes, WS-ALPHA-KTR will equal 4.

HTH....
Back to top
View user's profile Send private message
rupeshgullu

New User


Joined: 05 Oct 2010
Posts: 9
Location: Chandigarh

PostPosted: Wed Nov 27, 2013 10:30 pm    Post subject: Reply to: To get alphabet count in variable
Reply with quote

Sure will try and let u know.. count will be max upto 5 but i need to confirm... will post the result shortly
Back to top
View user's profile Send private message
rupeshgullu

New User


Joined: 05 Oct 2010
Posts: 9
Location: Chandigarh

PostPosted: Thu Nov 28, 2013 12:30 pm    Post subject: Reply to: To get alphabet count in variable
Reply with quote

It has given count of num of alphabets. what I want is that if I have alphanumeric values upto 5 bytes then it should give me count as 5

so that i can get all numeric values after 5 digits
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1717
Location: UK

PostPosted: Thu Nov 28, 2013 2:05 pm    Post subject:
Reply with quote

So why not adjust the code? You did take the time to understand what the code is doing, didn't you?
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Thu Nov 28, 2013 3:30 pm    Post subject: Re: To get alphabet count in variable
Reply with quote

that is even not what you asked :
rupeshgullu wrote:
... 'ABC1D67892' ... should give me '3'
... 'ABCD123456' ... should give me '4'
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Thu Nov 28, 2013 3:47 pm    Post subject:
Reply with quote

If I wanted the trailing numeric value of a field , this is how I would do it
(also not compiled on this end):
Code:
03  ws-input pic x(10) value 'ABC1D67892'.
03  ws-numX.
    05  ws-num9  pic 9(10).
   
move ws-input to ws-numX
PERFORM varying Ix from 10 by -1
  until ix < 1
     or WS-numX(Ix:1) ALPHABETIC                         
        continue
END-PERFORM
if ix > 0             
   move all '0' to WS-numX (1:ix)
end-if
Back to top
View user's profile Send private message
rupeshgullu

New User


Joined: 05 Oct 2010
Posts: 9
Location: Chandigarh

PostPosted: Thu Nov 28, 2013 4:14 pm    Post subject: Reply to: To get alphabet count in variable
Reply with quote

I have modified the code as below:


Code:
MOVE ZEROS TO WS-SPACE-COUNTER3.                       
MOVE ZEROS TO WS-SPACE-COUNTER4.                       
MOVE ZEROS TO TALLY.                                   
PERFORM UNTIL TALLY > LENGTH OF WS-ORDER-NO-REV       
   ADD 1 TO WS-SPACE-COUNTER3                         
   IF (WS-ORDER-NO-REV (TALLY:1) IS ALPHABETIC         
       AND WS-ORDER-NO-REV (TALLY:1) NOT = SPACES)     
       MOVE WS-SPACE-COUNTER3 TO WS-SPACE-COUNTER4     
   END-IF                                             
   ADD 1 TO TALLY                                     
END-PERFORM.           


Code'd
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1717
Location: UK

PostPosted: Thu Nov 28, 2013 4:44 pm    Post subject:
Reply with quote

rupeshgullu,
Why do you not use the code tags to present your code in a readable manner with proper indentation as other people have done?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Fri Nov 29, 2013 2:10 am    Post subject: Reply to: To get alphabet count in variable
Reply with quote

rupeshgullu,

You have to bear in mind that we don't know what you want, but you do.

You have told us, with some contradictions, how you want to do what you want, but we don't know what you are trying to achieve.

Have you tested your solution with A1B2C12345?

With Bill's solution, why don't you just stop after looking at five bytes or when you find a numeric?

With GuyC's, just start from five and wind down.

If you are going to attempt to use what you end up with for some calculation, please check it for NUMERIC first.

Rather than ALPHABETIC or SPACE, why not NOT NUMERIC? It'll be less of a strain on the old CPU and more directly describe what you are doing - perhaps, because we don't know.
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: Mon Dec 02, 2013 5:51 am    Post subject:
Reply with quote

Hello,

It appears that there may not be an actual requirement. Just some wonder about "what if I have . . . ".

Suggest rupeshgullu explain what kind of data this would support.
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 Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts OPC JCL Variable passion_sujesh IBM Tools 5 Fri Jul 01, 2016 4:21 am


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