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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: How to trim spaces or low-values in an alphanumeric value?
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10231
Location: italy

PostPosted: Tue Jun 12, 2012 11:22 am    Post subject: Reply to: How to trim spaces or low-values in an alphanumeri
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7306

PostPosted: Tue Jun 12, 2012 1:01 pm    Post subject: Re: How to trim spaces or low-values in an alphanumeric valu
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    Post subject:
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    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 Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am
No new posts To display values of multiple rows in... vinu78 DB2 2 Thu Mar 09, 2017 1:20 pm
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts setting new limit Key values for inde... srilata83 DB2 1 Fri Feb 10, 2017 9:24 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm


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