Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 10308
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: 7315

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 Working with hex values in Filemanage... Emile Straker IBM Tools 0 Tue Sep 12, 2017 1:42 am
No new posts DB2 NULL Values display V S Amarendra Reddy DB2 3 Thu Sep 07, 2017 6:59 pm
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts BI,TO=ZD Changing Values Tyler Dunbar DFSORT/ICETOOL 4 Tue Jul 25, 2017 12:12 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us