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
 

 

CHecking for lower case in a string

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

New User


Joined: 09 Mar 2006
Posts: 36
Location: hyderabad,A.P

PostPosted: Tue Jul 15, 2008 7:50 pm    Post subject: CHecking for lower case in a string
Reply with quote

I have a requirement where I need to check for the occurence of a lower case letter in any position in a 25 byte field.

I tried it using inspect but it is converting it into upper case from lower and also tried using the hex values for lower case with inspect but it didn't work.

Regards
Rohit
Back to top
View user's profile Send private message

ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Tue Jul 15, 2008 8:33 pm    Post subject:
Reply with quote

is it that you want to check whether atleast one lower char is present ??
do you need the position ??? do you need which character is that ??

if there are more than 1 lower case then ??
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Jul 15, 2008 8:39 pm    Post subject:
Reply with quote

depending upon your verison of cobol, you can do several things, but I normally generate 88 levels attatched to a pic x(01) that I float thru the field with an index (you can use a subscript if you don't care about efficiency). The 88 levels I define as either x'....' range or if some idiot has already caused the source program to be upper and lower case - caps off as apposed to caps on, then I set it up as ranges

'a' thru 'i', 'j' thru 'r', 's' thru 'z'.
you can also use class condition.

If I have to enter lower case letters, I put it into a copybook so that I can keep my source program CAPS ON.
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: Tue Jul 15, 2008 9:24 pm    Post subject: Re: CHecking for lower case in a string
Reply with quote

Issue an in-line PERFORM and check each byte using ALPHABETIC-LOWER and then save each position in a position-array for each lower-case character found.

The position-array should be large enough to house the number of bytes associated with the target field, with each position defined as a binary-halfword (2 bytes).

Bill
Back to top
View user's profile Send private message
rohit jaiswal
Warnings : 2

New User


Joined: 09 Mar 2006
Posts: 36
Location: hyderabad,A.P

PostPosted: Wed Jul 16, 2008 6:26 pm    Post subject: Reply to: CHecking for lower case in a string
Reply with quote

Hi Ashimer

I just want to know whethere there is a lower case letter in it or not thats it and i m not concerned abt the position. even if it is one then its fine with me, if i get so then i need to convert it into upper case which i can do using inspect.
Back to top
View user's profile Send private message
rohit jaiswal
Warnings : 2

New User


Joined: 09 Mar 2006
Posts: 36
Location: hyderabad,A.P

PostPosted: Wed Jul 16, 2008 6:31 pm    Post subject: Reply to: CHecking for lower case in a string
Reply with quote

hi Bill O'Boyle

can u provide me with more information on the alphabetic-lower function.

regards
rohit
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Jul 16, 2008 6:53 pm    Post subject:
Reply with quote

APLHABETIC-LOWER is a class condition not a function and is covered in the COBOL Language Reference for the version of COBOL you are using.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed Jul 16, 2008 6:54 pm    Post subject:
Reply with quote

You can do this couple of ways ...

Code:


01 ws-name     pic x(25) value 'AsHIMER'.
01 ws-count    pic s9(4) comp value 1.

01 ws-alpha       PIC X(01).
      88 ws-lower   VALUE 'a' thru 'z'.

perform until ws-count >= length of ws-name
  or ws-lower
  move ws-name(ws-count:1) to ws-alpha
    if ws-lower
       then display 'lower char present'
       display 'position=' ws-count
       exit
    end-if
    compute ws-count = ws-count + 1
end-perform



and

Code:


inspect ws-name converting
"abcdefghijklmnopqrstuvwxyz"
to
"@@@@@@@@@@@@@@@@@@@@@@@@@@"

inspect ws-name tallying ws-count for '@'
if ws-count > 0 then
  lower char present
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: Wed Jul 16, 2008 7:30 pm    Post subject:
Reply with quote

I beg to remind everyone that the english alphabet is not one (1) range but 3:

'a' thru 'i', 'j' thru 'r', 's' thru 'z'. whether upper or lower. the ranges between i and j and r and s are not a part of the english alphabet.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed Jul 16, 2008 7:40 pm    Post subject:
Reply with quote

Thanks for that Dick. I really appreciate.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Wed Jul 16, 2008 8:11 pm    Post subject: Re: Reply to: CHecking for lower case in a string
Reply with quote

rohit jaiswal wrote:
Hi Ashimer

I just want to know whethere there is a lower case letter in it or not thats it and i m not concerned abt the position. even if it is one then its fine with me, if i get so then i need to convert it into upper case which i can do using inspect.

Anyways you are going to convert that charactar to upper case, then why look for it?
directly use function UPPER-CASE or INSPECT on that field? Let me know if I misinterpreted your requirement.
Back to top
View user's profile Send private message
rohit jaiswal
Warnings : 2

New User


Joined: 09 Mar 2006
Posts: 36
Location: hyderabad,A.P

PostPosted: Thu Jul 17, 2008 7:01 pm    Post subject: Reply to: CHecking for lower case in a string
Reply with quote

Hi All

Thanks for the quick response and the solutions in solving my problem, i have ran the job and getting the perfect output.

Regards
rohit
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Jul 17, 2008 7:03 pm    Post subject:
Reply with quote

Cool icon_cool.gif
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 Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts VALIDATE NULL VALUE IN DB2 CASE STATE... useit DB2 5 Thu Feb 09, 2017 4:34 pm
No new posts Checking Current date vickey_dw DFSORT/ICETOOL 1 Wed Feb 08, 2017 11:14 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts Summing on Mixed Case Literals Roy Ware SYNCSORT 3 Tue Jan 03, 2017 10:18 pm


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