View previous topic :: View next topic
|
Author |
Message |
Gopalakrishnan V
Active User
Joined: 28 Jun 2010 Posts: 102 Location: chennai
|
|
|
|
I have a field of 2 byte in cics map which should take numeric value only otherwise should thru error message. Initially that field having cursor in map to enter the value
Since it is an alphanumeric value it may contain spaces or low-values and sometimes '_' initially. I have coded like
Code: |
WS-NUM PIC X(02) VALUE SPACES
IF WS-NUM IS NUMERIC
MOVE WS-NUM TO WS-VAL
ELSE
MOVE 'ENTER THE NUMERIC VALUE' TO ERR-MSG
END-IF
|
If i enter single digit it thru above error message because another byte having spaces or low-values. Please suggest solution for this issue
Thanks in advance. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
Please suggest solutions as soon as possible. |
people reply on their own time and free of charge,
putting pressure on people will usually lower the chances of getting good answers
if You have time constraints a forum is not the best place to ask for help |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I'd use much better data-names to make it much clearer, but...
Code: |
01 WS-NUM VALUE SPACES.
05 WS-NUM-BYTE-1 PIC X.
88 WS-NUM-BYTE-1-VALID VALUE "0" THRU "9".
05 WS-NUM-BYTE-2 PIC X.
88 WS-NUM-BYTE-2-VALID-NUMERIC VALUE "0" THRU "9".
88 WS-NUM-BYTE-2-VALID-NOT-NUMERIC VALUE SPACE, LOW-VALUES.
EVALUATE TRUE
WHEN ( WS-NUM-BYTE-1-VALID
AND WS-NUM-BYTE-2-VALID-NUMERIC )
MOVE WS-NUM TO WS-VAL
WHEN ( WS-NUM-BYTE-1-VALID
AND WS-NUM-BYTE-2-VALID-NOT-NUMERIC )
MOVE WS-NUM-BYTE-1 TO WS-NUM-BYTE-2
MOVE ZERO TO WS-NUM-BYTE-1
MOVE WS-NUM TO WS-VAL
OTHERWISE
MOVE 'ENTER THE NUMERIC VALUE' TO ERR-MSG
END-EVALUATE
|
|
|
Back to top |
|
|
Gopalakrishnan V
Active User
Joined: 28 Jun 2010 Posts: 102 Location: chennai
|
|
|
|
Thanks a lot Bill Woodger. Your method working fine.. |
|
Back to top |
|
|
|