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: 10211
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: 7251

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 SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts To trim spaces in a pipe delimited da... Nish84 COBOL Programming 16 Mon Oct 10, 2016 1:54 pm


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