IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Valid Values for a field should be A-Z or 0-9


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
suryamtechcse
Warnings : 1

New User


Joined: 28 Apr 2006
Posts: 9
Location: Chennai

PostPosted: Fri Jan 08, 2010 9:45 pm
Reply with quote

Hi,

I am in need to write an assembler code:

I want to give valid values for a field called ACTATTR.

The valid values should be only A-Z or 0-9.

Code:
ACTATRTN   ------------Main Routine
CLI  ACTATTR,C'A'
BL   Error-routine
CLI  ACTATTR,C'Z'
BNH Exit-routine
BNE ACTAt09

ACTAT09  DS 0H
CLI  ACTATTR,C'0'
BL   Error-routine
CLI  ACTATTR,C'9'
BNH Exit-routine
BNE ACTAt09



Could you please provide me an Assembler code for this?

Thanks
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Fri Jan 08, 2010 9:53 pm
Reply with quote

Probably the fastest way would be to use the TRT instruction. Googling assembler trt instruction returns 175,000 hits with plenty of examples on how to use it.
Back to top
View user's profile Send private message
suryamtechcse
Warnings : 1

New User


Joined: 28 Apr 2006
Posts: 9
Location: Chennai

PostPosted: Fri Jan 08, 2010 10:03 pm
Reply with quote

Hi Robert,

I am a beginner in Assembler. Could you please provide me exact code?

Thanks
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Fri Jan 08, 2010 10:22 pm
Reply with quote

This is a help forum, not a DO-YOUR-JOB-FOR-YOU forum. Most of the people who monitor this forum are paid for their professional work product (such as assembler code). Unless you're willing to pay the appropriate amount for professional assistance (rates of USD 1000 per day are fairly typical), please do not ask for code. If you code it up on your own and have trouble, there's plenty of people willing to help you fix it. But unless you show some initiative by coding on your own, you're probably not going to see much support here.

You are expected to be able to research things, read manuals, and figure out things on your own.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Fri Jan 08, 2010 10:51 pm
Reply with quote

A warning is in order here - MANY have erred in thinking that all values between 'A' and 'Z' ( inclusive ) are alphabetic. In fact, they are NOT. In EBCDIC, the letter 'A' is hex 'C1' (x'C1') and the letter 'Z' is hex 'E9' (x'E9'). But between x'C1' and x'E9' there are values ( i.e. x'CA', x'CB', x'CC', x'CD', x'CE', x'CF', x'D0', x'DA', x'DB', x'DC', x'DE', x'DF', x'E0', and x'E1' ) which are NOT alphabetic. Do NOT neglect to account for these if you test individual bytes to determine if they are "alphabetic".
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Fri Jan 08, 2010 11:07 pm
Reply with quote

Yes, you must heed this warning and this is why a TRT table is your best choice for validating this data.

TRT's are issued (under the covers) by COBOL on a regular basis, such as -

IF field IS NUMERIC

IF field IS ALPHABETIC-UPPER AND field IS NOT = SPACE

The above tests will check field for 0-9 and A-Z characters.

To generate the Assembler expansion of a COBOL program which issue these tests, compile the program using the compile options LIST,NOOFFSET (normal default is NOLIST, OFFSET).

Bill
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Fri Jan 08, 2010 11:27 pm
Reply with quote

One additional caution is now indicated.

It is never a good idea to test a ONE-BYTE field to see if it is NUMERIC or ALPHABETIC.

Why? Well, because if the value is x'C1' it will qualify as BOTH. That is, the value x'C1' is both a valid (signed) number ( value +1 ) AND a valid alphabetic character ( letter 'A' ).
To test a 1-byte field, either test the actual hex representation in accordance with your requirements, or move it to the last byte of a larger field that has been pre-filled with valid values (according to your requirements), and then test that larger field.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Sat Jan 09, 2010 12:34 pm
Reply with quote

Thats true Ronald, but i guess the TS is talking about characters, not the numeric values of 0-9, e.g. x'F0' - x'F9'.
But nevertheless TRT would do the job.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
Search our Forums:

Back to Top