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
 
Inspecting a record for all alphabets

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Sudhanshu Shekhar

New User


Joined: 23 Jul 2008
Posts: 27
Location: City of Joy

PostPosted: Thu May 20, 2010 4:45 pm    Post subject: Inspecting a record for all alphabets
Reply with quote

HI,

i have a record with several amount fields.
Code:
AMT1  PIC S9(13)V99


I want to check if any of these fields contain any alphabet.

I want to write it to an exception file in that case.

I am using inspect but dont want to inspect the code 26 times with each alphabet.
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu May 20, 2010 4:48 pm    Post subject:
Reply with quote

IF AMT1 NOT NUMERIC
it's an error
END-IF.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8165
Location: East Dubuque, Illinois, USA

PostPosted: Thu May 20, 2010 4:52 pm    Post subject:
Reply with quote

Your requirement is not at all clear. If these fields are USAGE DISPLAY, and AMT1 has the value +10.75, it will be stored as 00000000000107E -- so how do you distinguish the legitimate, valid sign overlays from invalid alphabetic characters? If the fields are not USAGE DISPLAY, the problem is worse since both COMP-3 and COMP variables can have valid data fields that appear to be alphabetic characters (for example, -97994 stored as a PIC S9(05) COMP-3 value is 'pr(').

There is a link to the manuals at the top of this page. Click on it, find the COBOL Language Reference and Programming Guide manuals and read up in them on how COBOL stores data internally. Once you have done this, and can reformulate your question in a way that actually makes sense, we should be able to help you.
Back to top
View user's profile Send private message
Sudhanshu Shekhar

New User


Joined: 23 Jul 2008
Posts: 27
Location: City of Joy

PostPosted: Thu May 20, 2010 4:57 pm    Post subject:
Reply with quote

Yesh i guess the requirement was not put corretly.

AMT1 is PIC X(10).

I Use the AMT = FUNCTION NUMVAL(AMT1) to extract the numeric value.

But if AMT1 contains any alphabet/non numeric chars the job abends, so i want to have a check before going to the intrinsic function and write those records(containing alphabets or special chars) to an exception file instead of performing the NUMVAL.

Sincere apologies ....
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8165
Location: East Dubuque, Illinois, USA

PostPosted: Thu May 20, 2010 5:05 pm    Post subject:
Reply with quote

A PIC X(10) and PIC S9(13)V99 have a different number of digits -- so you're still not explaining yourself very well.

Why not just say
Code:
IF  AMT1 NUMERIC
    COMPUTE AMT = FUNCTION NUMVAL(AMT1)
Back to top
View user's profile Send private message
Sudhanshu Shekhar

New User


Joined: 23 Jul 2008
Posts: 27
Location: City of Joy

PostPosted: Thu May 20, 2010 5:16 pm    Post subject:
Reply with quote

@ Robert,

If AMT is say '9999fff763'

Will the above still work?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8165
Location: East Dubuque, Illinois, USA

PostPosted: Thu May 20, 2010 5:42 pm    Post subject:
Reply with quote

Is it so hard for you to test? Code:
Code:
       01  WS-VARIABLES.
           10  AMT1                    PIC X(10) VALUE '9999FFF763'.
           10  AMT2                    PIC S9(13)V99.

       LINKAGE SECTION.
      /
       PROCEDURE DIVISION.
       S1000-MAIN       SECTION.
           IF  AMT1 NUMERIC
               COMPUTE AMT2 = FUNCTION NUMVAL (AMT1)
               DISPLAY 'AMT2 OK -- ' AMT2
           ELSE
               DISPLAY 'AMT1 FAILED NUMERIC TEST'
           END-IF.
           MOVE '1234567890'           TO  AMT1.
           IF  AMT1 NUMERIC
               COMPUTE AMT2 = FUNCTION NUMVAL (AMT1)
               DISPLAY 'AMT2 OK -- ' AMT2
           ELSE
               DISPLAY 'AMT1 FAILED NUMERIC TEST'
           END-IF.
           GOBACK.
produces output of
Code:
 AMT1 FAILED NUMERIC TEST
 AMT2 OK -- 00012345678900{
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 Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Repeat part of record multiple times Learncoholic DFSORT/ICETOOL 4 Tue Aug 29, 2017 11:33 am
No new posts Read two inputs and write into output... murali.andaluri DFSORT/ICETOOL 6 Wed Jul 26, 2017 7:35 pm
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am

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