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
 

 

confusion with alphanumeric characters

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

New User


Joined: 16 Jan 2006
Posts: 53
Location: pune

PostPosted: Mon Apr 10, 2006 8:28 pm    Post subject: confusion with alphanumeric characters
Reply with quote

Hi all,

If var1 start with a numeric and rest contains any non numeric characters then display 'warning'

If var1(1:1) is numeric and ?

If var1 start with other than alphanumeric character then display 'invalid'.

var1 pic x(9)

Pls help to code above two conditions.

Thanks,
Dipanshu G.
Back to top
View user's profile Send private message

DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Apr 11, 2006 12:48 am    Post subject: Re: confusion with alphanumeric characters
Reply with quote

dipanshu,

Quote:

If var1 start with other than alphanumeric character then display 'invalid'.


The assumption is that you meant numeric, not alphanumeric above.

Code:


    05  VAR1             PIC X(9).


    IF VAR1(1:1) NOT NUMERIC
    THEN
        DISPLAY 'INVALID'
    ELSE
        IF VAR1(2:8) NOT NUMERIC
        THEN
            DISPLAY 'WARNING'
        END-IF
    END-IF
       


Dave
Back to top
View user's profile Send private message
dipanshu

New User


Joined: 16 Jan 2006
Posts: 53
Location: pune

PostPosted: Tue Apr 11, 2006 9:09 am    Post subject:
Reply with quote

Hi,

Thanks dave, But I am seeking for the condition to test alphanumeric character.

As per my perception alphanumeric character set includes :-
numeric + alphabet + national characters.

Is there any shortcut and what are the characters included in national character?

Thanks,
Dipanshu G.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1232
Location: Israel

PostPosted: Tue Apr 11, 2006 7:10 pm    Post subject:
Reply with quote

Try the following:

In the ENVIRONMENT DIVISION add

Code:
CONFIGURATION SECTION.
SPECIAL-NAMES.
    CLASS NATCHARSET IS 'A' THROUGH 'I' 'J' THROUGH 'R'
                        'S' THROUGH 'Z' '0' THROUGH '9'
                        '$%&()<>/?=+-_'.

(place as many national characters as you want, add also lowercase if you wish and don't forget to add QUOTE if you need to).

Then you can just ask:

Code:
IF VAR1(1:1) IS NUMERIC THEN
    DISPLAY 'WARNING'
ELSE
    IF VAR1(1:1) NOT NATCHARSET THEN
        DISPLAY 'INVALID'
    ELSE
        DISPLAY 'OK'
    END-IF
END-IF
Back to top
View user's profile Send private message
dipanshu

New User


Joined: 16 Jan 2006
Posts: 53
Location: pune

PostPosted: Tue Apr 11, 2006 8:10 pm    Post subject:
Reply with quote

many thanks to u.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1232
Location: Israel

PostPosted: Wed Apr 12, 2006 11:57 am    Post subject:
Reply with quote

The only drawback with this method is that the defined CLASS(es) can be used only with IF statements, not with EVALUATE.
Back to top
View user's profile Send private message
ap_mainframes

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Mon Apr 17, 2006 3:10 pm    Post subject: Re: confusion with alphanumeric characters
Reply with quote

Hey marso,

What are these classes and where and when are they used ( apart from the example given).
Can you throw some light on this??
If you can provide some document on this then it would be best.

Thanks for all the information you can provide.

Ap_mainframes.
Back to top
View user's profile Send private message
bhgh
Warnings : 1

New User


Joined: 18 Mar 2006
Posts: 21
Location: delhi

PostPosted: Mon Apr 17, 2006 4:52 pm    Post subject: Re: confusion with alphanumeric characters
Reply with quote

Hi dave,
explain about Var1(1:1) ,
while executing the program how it will check this condition.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Mon Apr 17, 2006 11:16 pm    Post subject:
Reply with quote

bhgh,,

I think the link below to reference modification will answer your question.

REFERENCE MODIFICATION

Var1(1:1) is the alphanumeric substring of Var1 starting at char position 1 with a length of 1.

If you do not understand, Please come back and I will try to explain differently,

Dave
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1232
Location: Israel

PostPosted: Tue Apr 25, 2006 12:10 pm    Post subject:
Reply with quote

A CLASS is a set of specific characters. Here are more samples:

Code:
CONFIGURATION SECTION.
SPECIAL-NAMES.
    CLASS HEXADECIMAL IS '0123456789ABCDEF'
    CLASS BINARY IS '01'.

Note: if you define more than one class, put only one dot after the last, not between.

Classes defined in this way can be used only in a "class condition", which means the only thing you can do is ask:

Code:
01  MY-FIELD1   PIC X(8)    VALUE '003AC968'.
01  MY-FIELD2   PIC X(8)    VALUE '01101011'.

IF MY-FIELD1 IS HEXADECIMAL THEN
    ...
IF MY-FIELD2 IS NOT BINARY THEN
    ...
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 Remove junk values in a file and rite... KP1125 DFSORT/ICETOOL 2 Wed Jan 25, 2017 9:58 pm
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
This topic is locked: you cannot edit posts or make replies. Alphanumeric to Numeric move on UNIX mistah kurtz COBOL Programming 16 Wed Jul 27, 2016 8:47 pm
No new posts Remove Special Characters from Mainfr... Rodger Zhang All Other Mainframe Topics 6 Wed Jul 06, 2016 1:12 am
No new posts alphanumeric sequence generation sivaprasad.gadhi COBOL Programming 6 Wed Mar 30, 2016 3:03 am


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