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
 

 

Handeling function error

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

New User


Joined: 04 May 2007
Posts: 6
Location: Brussel

PostPosted: Tue May 27, 2008 7:06 pm    Post subject: Handeling function error
Reply with quote

Hi.

Is there anyway to handel to error caused by a function call ?

I am using the NUMVAL-C function, but it happened that the string contains some digit after the first space. So it cause a U4038 abend :

Unlimited : < N > (Y/N)
Amount : < 1 15,00 > <-- encoded value

This is the message found in the IMS region :

A non-digit character other than a decimal point, comma, space or sign
(+,-,CR,DB) was found in argument-1 for the NUMVAL/NUMVAL-C function.

The IBM message that corresponds to the condition is:

IGZ0152S Invalid character 5 was found in column 17 in argument-1 for
function NUMVAL-C in program GUF71 at displacement X'5D46'.

Thanks for your answer.
Back to top
View user's profile Send private message

yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Tue May 27, 2008 7:34 pm    Post subject: Re: Handeling function error
Reply with quote

eric henken wrote:
Hi.

Is there anyway to handel to error caused by a function call ?



I think there is no Error Handling for function call in COBOL. There are very few Error Handling available in COBOL, like ON SIZE ERROR.

We can convert only Numeric Values(Including Spaces, decimal Point, currency sign) present in alphanumeric variables to Numeric using NUMVAL-C function.

Look at NUMVAL-C Details
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue May 27, 2008 7:37 pm    Post subject:
Reply with quote

NUMVAL (and -C) obviously have limitations. according to the documentation, there are some restrictions.

you can not use it on a garbage field. it was designed to take x-type input and convert to numeric. if you have digit-space-digit-digit you have two fields

so, a little cleanup is necessary.

declaratives will stop the error going to mvs.
you clean up the field or use reference modfication to define you source for the NUMVAL Function.
Back to top
View user's profile Send private message
eric henken

New User


Joined: 04 May 2007
Posts: 6
Location: Brussel

PostPosted: Tue May 27, 2008 8:12 pm    Post subject:
Reply with quote

Thanks for your answer.

I was trying to do this without to have to clean up the field icon_cry.gif

I have already define a SPECIAL NAME CLASS :
Code:
SPECIAL-NAMES.                               
    CLASS TEST-NUM-E '0' THRU '9' ',' '.' ' '


to be able to validate the contents of the field before to use the function, but in a class we can't say where the spaces must be placed.

I am going to eliminate the spaces and move the result to another variable.

Regards,

Eric.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue May 27, 2008 8:40 pm    Post subject: Re: Handeling function error
Reply with quote

A brilliant move on IBM's part would have been to create an "LE" (Language Environment) version of NUMVAL and NUMVAL-C, which would then allow the Caller to check the feedback-code halfword for validity and successful completion.

Unfortunately, unlike (as an example) many of the COBOL Date FUNCTIONS which have corresponding "LE" Callable Service routines, they didn't do that and the Caller is forced to ensure data-validation before using either of these FUNCTIONS and others as well.

Regards,

Bill
Back to top
View user's profile Send private message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Wed May 28, 2008 7:53 am    Post subject:
Reply with quote

eric henken wrote:

I am going to eliminate the spaces and move the result to another variable.


You can use INSPECT,Reference Modification to eliminate SPACES in your alphanumeric variable.
Back to top
View user's profile Send private message
eric henken

New User


Joined: 04 May 2007
Posts: 6
Location: Brussel

PostPosted: Wed May 28, 2008 3:00 pm    Post subject:
Reply with quote

Thank all !

I solved my problem with the following solution.
Code:
     
              MOVE 0 TO J-IND     
              MOVE SPACES TO WS-AMOUNT-X       
              PERFORM VARYING I-IND FROM 1 BY 1
                  UNTIL I-IND > 20                           
                  IF GUF71-AMOUNT (I-IND:1) > SPACES
                       ADD 1 TO J-IND
                       MOVE GUF71-AMOUNT (I-IND:1) TO WS-AMOUNT-X (J-IND:1)
                  END-IF

              END-PERFORM
              MOVE WS-AMOUNT-X TO GUF71-AMOUNT                       

So I can shift all digits to the left and call the function without any spaces between digit !

I hope that IBM will develop tools to help us to be more efficient in the handling of error !

Regards,

Eric.
Back to top
View user's profile Send private message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Wed May 28, 2008 3:05 pm    Post subject: Reply to: Handeling function error
Reply with quote

Thanks Eric for writing your solution here.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed May 28, 2008 3:52 pm    Post subject:
Reply with quote

eric,

I wonder why there was a space between the 1 and the 15,00?

IBM provides in its instruction-set commands necessary to process business data.

the commands available, had they been properly used during creation of this x-type field, would have made it a very easy NUMVAL to extract the data. But, the field was populated in an unprofessional manner. spilting up a number with spaces intersperced is really bad. are you sure that it is 115,00 and not 15,00. I assume your environment is COMMA IS DECIMAL. you could be heading for a 100 point error.

Don't hold your breath waiting for IBM to build an instruction to take care of poorly generated data.
Back to top
View user's profile Send private message
eric henken

New User


Joined: 04 May 2007
Posts: 6
Location: Brussel

PostPosted: Wed May 28, 2008 4:26 pm    Post subject:
Reply with quote

Hi Dick,

The data is coming from an input field of a screen.
I develop application with a tool and it doesn’t work well with numeric field!

The value must be displayed in a edited format PIC Z.ZZZ.ZZZ.ZZZ.ZZ9,99 thus allow spaces, digits, points and comma. The user can introduce what he wants and I must validate that what he give is correct.

I can't modify the MFS generated by the tools, so I can't say to IMS that the input field is numeric and the output field is char.

So I have searched other solution to be able to manipulate this field without writing a lot of Cobol Instruction.

Eric.

I have found the NUMVAL and NUMVAL-C function and hope that it was possible to handle the error before the program dump ! I was dreaming....

This is the reason why the input field can be fill in the improper way.
Back to top
View user's profile Send private message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Wed May 28, 2008 4:37 pm    Post subject: Reply to: Handeling function error
Reply with quote

Eric, in your case can user enters values like 1150BB where B is for BLANK?

If user can enter like this, then you will be in trouble & again have to take help of INSPECT & Reference Modification.

I had worked with similar kind of task before, where I had to take care of all probable cases.
Back to top
View user's profile Send private message
eric henken

New User


Joined: 04 May 2007
Posts: 6
Location: Brussel

PostPosted: Wed May 28, 2008 5:43 pm    Post subject:
Reply with quote

Yes, the user can introduce 1150BB !

But, if you take a look at the NUMVAL-C function, you see that the input string can contain spaces.

To test this, I have make the following test
Code:

SPECIAL-NAMES.                                       
    CLASS TEST-ERIC '0' THRU '9' '.' ','  ' '       

DATA DIVISION.                             
FILE SECTION.                               
FD  PARMCARD                               
    LABEL RECORDS ARE OMITTED               
    RECORDING MODE IS F                     
    RECORD CONTAINS 80                     
    BLOCK  CONTAINS 0                       
    DATA RECORD IS REC-PARMCARD.           
01  REC-PARMCARD.                           
    05  FUNC-REC                PIC X(10). 
    05  DATAS                     PIC X(70). 

WORKING SECTION.
01  I-IND                       PIC S9(04) COMP.
01  J-IND                       PIC S9(04) COMP.
01  I-CTR                       PIC S9(04) COMP.
01  WS-TESTX                    PIC X(10).       
01  WS-TEST2                    PIC 9(10)V9(02). 
01  WS-TEST2-EDT                PIC ZZ.ZZZ.ZZ9,99.
 

PROCEDURE DIVISION

    MOVE 0 TO I-CTR                                             
    INSPECT  DATAS(1:10)                                         
        TALLYING I-CTR FOR ALL ','                               
    IF I-CTR > 1                                                 
       DISPLAY 'GUTSTEH' ' - ' 'DATA NOT TEST-ERIC COMPLIANT'   
           DATAS(1:10)                                           
    ELSE                                                         
       MOVE 0 TO J-IND                                           
       MOVE SPACES TO WS-TESTX                                   
       PERFORM VARYING I-IND FROM 1 BY 1                         
           UNTIL I-IND > 10                                     
          IF DATAS(I-IND:1) > SPACES AND DATAS(I-IND:1) NOT = '.'
             COMPUTE J-IND = J-IND + 1                           
             MOVE DATAS(I-IND:1) TO WS-TESTX (J-IND:1)           
          END-IF                                                 
/* Ending: IF DATAS(I-IND:1) > SPACES AND DATAS(I-IND:1) NOT =...
       END-PERFORM                                               
       MOVE WS-TESTX TO DATAS(1:10)                             
       IF DATAS(1:10) IS TEST-ERIC AND DATAS(1:10) > SPACES     
          COMPUTE WS-TEST2 = FUNCTION NUMVAL-C(DATAS(1:10))     
          MOVE WS-TEST2 TO WS-TEST2-EDT                         
          DISPLAY 'GUTSTEH' ' - ' 'WS-TEST2*'                   
              WS-TEST2                                           
              '*'                                               
              DATAS(1:10)                                       
              '*WS-TEST2-EDT*'                                   
              WS-TEST2-EDT                                       
              '*'                                               
       ELSE                                                     
          DISPLAY 'GUTSTEH' ' - ' 'DATA NOT TEST-ERIC COMPLIANT *
    ''                                                           
              DATAS(1:10)                                       
              '*'                                               
       END-IF                                                   
/* Ending: IF DATAS(1:10) IS TEST-ERIC AND DATAS(1:10) > ...     
    END-IF.                                                     
/* Ending: IF I-CTR > 1...                                       


The input value are :
Code:

   3.000,00 
3  3.000,00 
3.000,00     
3,00         
3           
3,,,         
....3       
A3           
B --> Blank             

It gives as result :
Code:

GUTSTEH - WS-TEST2*000000300000*3000,0    *WS-TEST2-EDT*     3.000,00*   
GUTSTEH - WS-TEST2*000003300000*33000,0   *WS-TEST2-EDT*    33.000,00*   
GUTSTEH - WS-TEST2*000000300000*3000,00   *WS-TEST2-EDT*     3.000,00*   
GUTSTEH - WS-TEST2*000000000300*3,00      *WS-TEST2-EDT*         3,00*   
GUTSTEH - WS-TEST2*000000000300*3         *WS-TEST2-EDT*         3,00*   
GUTSTEH - DATA NOT TEST-ERIC COMPLIANT3,,,                               
GUTSTEH - WS-TEST2*000000000300*3         *WS-TEST2-EDT*         3,00*   
GUTSTEH - DATA NOT TEST-ERIC COMPLIANT *A3        *                     
GUTSTEH - DATA NOT TEST-ERIC COMPLIANT *          *                     


So you see, with the code that I have added to shift the input field to the left, I think that I can expect everything from the user icon_wink.gif

At first the field must be validate :

1) One comma allowed
2) Remove blank and point (It give an error if there is leading point !)
3) validate that the field is TEST-ERIC compliant (the point may be removed in the CLASS)

Then use the function to format the input field !

I think from now it will be OK.

Eric
Back to top
View user's profile Send private message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Wed May 28, 2008 6:03 pm    Post subject: Reply to: Handeling function error
Reply with quote

Yeah, I also hope this will work.

In my task there was one more case of 'LEADING ZEROS' (like LEADING SPACES) say if user enters
Code:
0300

We can overcome to this one also.


Regards,
Yogeshwar
Back to top
View user's profile Send private message
eric henken

New User


Joined: 04 May 2007
Posts: 6
Location: Brussel

PostPosted: Wed May 28, 2008 6:09 pm    Post subject:
Reply with quote

It works also with severals leading zeroes

Code:

GUTSTEH - WS-TEST2*000000000300*0000003   *WS-TEST2-EDT*         3,00*


If I have forgotten something, I will give the modification !
Back to top
View user's profile Send private message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Wed May 28, 2008 6:18 pm    Post subject: Reply to: Handeling function error
Reply with quote

Eric,
Thanks for all your explanation.

You covered all possible cases. I dont think USER will have any other possible case which will cause your code ABEND.


Regards,

Yogeshwar
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 S922 Error yuvan ABENDS & Debugging 3 Fri Dec 02, 2016 6:58 pm
No new posts Invoke Webservice Fails with DFHPI100... divated CICS 2 Thu Nov 24, 2016 5:57 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am
No new posts Error during restore rename archanamuthukrishnan All Other Mainframe Topics 2 Fri Oct 14, 2016 3:30 pm


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