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
 

 

VER statement help sought

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> TSO/ISPF
View previous topic :: :: View next topic  
Author Message
David Sde

New User


Joined: 24 Apr 2011
Posts: 23
Location: USA

PostPosted: Mon May 05, 2014 9:51 pm    Post subject: VER statement help sought
Reply with quote

Hi,

I hope someone can help me. I'm having trouble figuring out to to use VER to validate an ISPF panel field. This is a 16-character field, defined with CAPS(ON), which must be of a particular format. The first n characters must be uppercase alphabetic (A-Z), followed by a single hyphen, followed by m numeric characters (0-9). Trailing blanks are okay, but embedded blanks are not.

E.g., these are okay:
    ABC-1234
    A-9
    ABCDEF-01234

These are invalid:
    ABC
    999
    AB-
    -99
I couldn't figure out how to write the VER statement to enforce these rules (or if it's even possible), because the number of alphabetic characters preceding the hyphen isn't fixed, nor is the number of digits following the hyphen. Can anyone provide any guidance?

Thanks so much,

David
Back to top
View user's profile Send private message

daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 669
Location: Pennsylvania

PostPosted: Mon May 05, 2014 10:08 pm    Post subject:
Reply with quote

What I have done when the VER statement does not suit my needs is pass the value to an instream Rexx process.
This Rexx can be as complex as you need it.

If it is valid I set my valid return value to the original, otherwise I set it to something else.

I do a simple VER when I return.

See a small example here:

Code:
ED = 'ABC-1234'
*REXX (ED,VALSW)
   IF ED = YADAYADA THEN VALSW = ED
   ELSE VALSW = 'XXXXX'
*ENDREXX
VER (ED,NB,LISTV,&VALSW,MSG=SPECMSG)
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10274
Location: italy

PostPosted: Mon May 05, 2014 11:12 pm    Post subject: Reply to: VER statement help sought
Reply with quote

here is a snippet to check for Your formats

Code:

 ****** ***************************** Top of Data ******************************
 000001 /*REXX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 000002 /*                                                                   */
 000003 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 000004 Trace "O"
 000005
 000006 line.1 = "ABC-123"
 000007 line.2 = "ABC"
 000008 line.3 = "123"
 000009 line.4 = "ABC-"
 000010 line.5 = "-123"
 000011 line.6 = "AB -123"
 000012 line.7 = "ABC- 23"
 000013 line.8 = "abc-123"
 000014 line.9 = "ABC-1"
 000015 line.0 = 9
 000016
 000017 do l = 1 to line.0
 000018    err = valid
 000019    do 1
 000020       if pos(" ", line.l) > 0 then do
 000021          err = "Embedded blanks"
 000022          leave
 000023       end
 000024
 000025       if pos("-", line.l) = 0 then do
 000026          err = "missing '-'"
 000027          leave
 000028       end
 000029
 000030       parse var line.l alf "-" num
 000031
 000032       if alf = ""  then do
 000033          err = "missing alf"
 000034          leave
 000035       end
 000036
 000037       if num = ""  then do
 000038          err = "missing num"
 000039          leave
 000040       end
 000041
 000042       if \datatype(alf,"U")  then do
 000043          err = "not upper case"
 000044          leave
 000045       end
 000046
 000047       if \datatype(num,"N")  then do
 000048          err = "not numeric"
 000049          leave
 000050       end
 000051
 000052    end
 000053
 000054    say right(l,2) left(line.l, 20) err
 000055
 000056 end
 000057
 000058 Exit 0
 000059
 ****** **************************** Bottom of Data ****************************



the result


Code:

  1 ABC-123              VALID
  2 ABC                  missing '-'
  3 123                  missing '-'
  4 ABC-                 missing num
  5 -123                 missing alf
  6 AB -123              Embedded blanks
  7 ABC- 23              Embedded blanks
  8 abc-123              not upper case
  9 ABC-1                VALID
 ***
Back to top
View user's profile Send private message
David Sde

New User


Joined: 24 Apr 2011
Posts: 23
Location: USA

PostPosted: Mon May 05, 2014 11:35 pm    Post subject: Reply to: VER statement help sought
Reply with quote

Many thanks to both of you; this is great!

David
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 -> TSO/ISPF All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts VALIDATE NULL VALUE IN DB2 CASE STATE... useit DB2 5 Thu Feb 09, 2017 4:34 pm
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts COBOL DB2 - CALL statement - high CPU... TS70363 DB2 15 Sun Sep 11, 2016 6:07 am
No new posts Converting NULL column into NOT NULL ... Raghu navaikulam DB2 5 Sat Aug 06, 2016 3:45 pm


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