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

Inspecting a record for all alphabets


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu May 20, 2010 4:52 pm
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu May 20, 2010 5:05 pm
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu May 20, 2010 5:42 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top