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

How to trim spaces or low-values in an alphanumeric value?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Gopalakrishnan V

Active User


Joined: 28 Jun 2010
Posts: 102
Location: chennai

PostPosted: Tue Jun 12, 2012 11:17 am
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Jun 12, 2012 11:22 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jun 12, 2012 1:01 pm
Reply with quote

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
View user's profile Send private message
Gopalakrishnan V

Active User


Joined: 28 Jun 2010
Posts: 102
Location: chennai

PostPosted: Tue Jun 12, 2012 5:57 pm
Reply with quote

Thanks a lot Bill Woodger. Your method working fine.. icon_biggrin.gif
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
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 leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
Search our Forums:

Back to Top