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

FUNCTION NUMVAL problem


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
aedesy

New User


Joined: 11 Feb 2022
Posts: 6
Location: ITALY

PostPosted: Thu Mar 03, 2022 3:22 am
Reply with quote

Hi,
I have a CSV input file. I read it with UNSTRING. I am trying to move some alphanumeric fields to numeric fields by using FUNCTION NUMVAL.
Here is an example:

Input record:
Code:
...12/01/2020;300.000;...


'300.000' is stored into WK-IMPORTO.

COBOL code:
Code:
...
05 INCC-IMPORTO        PIC 9(13)V999.
...
01  WK-IMPORTO         PIC  X(16).
...
COMPUTE INCC-IMPORTO = FUNCTION NUMVAL(WK-IMPORTO)


I get this error:
'IGZ0152S Invalid character . was found in column 4 in argument-1 for function NUMVAL...'.
I also tried with INSPECT, replacing '.' with ',' but same error. But it works with OpenCOBOL. I really did not understand. Could someone explain? Thanks in advance.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8661
Location: Dubuque, Iowa, USA

PostPosted: Thu Mar 03, 2022 3:41 am
Reply with quote

With what you've posted, it looks like it should work. However, some questions do come up:
- What release of the compiler are you using?
- What does a DISPLAY of WK-IMPORTO just before the COMPUTE statement show?

Broadly speaking, the computer is telling you that the fourth character of your WK-IMPORTO variable is not valid for NUMVAL. So you need to take a very close look at that variable's value to determine why the computer made that determination.

Oh, and it doesn't matter what OPENCOBOL did with the statement -- unless you don't want to use Enterprise COBOL for this program.
Back to top
View user's profile Send private message
aedesy

New User


Joined: 11 Feb 2022
Posts: 6
Location: ITALY

PostPosted: Thu Mar 03, 2022 4:00 am
Reply with quote

Hi, thanks for your answer. The DISPLAY of the field is showing '300.000' and the release of compiler is '5655-EC6'. I tried to use HEX ON for help:

Code:
24/05/2019;300.000;
FF6FF6FFFF5FFF4FFF5
2410512019E300B000E


I don't see any particular issue.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10838
Location: italy

PostPosted: Thu Mar 03, 2022 4:20 am
Reply with quote

IMO there is a misunderstanding about the meaning of 300.000

for non english speaking countries dealing with national number representation needs a

Quote:
DECIMAL-POINT IS COMMA clause

DECIMAL-POINT IS COMMA
Exchanges the functions of the period and the comma in PICTURE character-strings and in numeric literals.
Back to top
View user's profile Send private message
aedesy

New User


Joined: 11 Feb 2022
Posts: 6
Location: ITALY

PostPosted: Thu Mar 03, 2022 1:05 pm
Reply with quote

Hi. I did try again with
Code:
INSPECT WK-IMPORTO REPLACING ALL '.' BY ','


and it seems to work until it finds numbers like that: '4.826.100'
Here is the output:

Code:
IMPORTO : 300,000                                               
IMPORTO : 264,000                                               
IMPORTO : 837,000                                               
IMPORTO : 131,450                                               
IMPORTO : 4,826,100                                             
IGZ0152S Invalid character , was found in column 6 in argument-1


I think I should try with different INSPECT options.
Back to top
View user's profile Send private message
aedesy

New User


Joined: 11 Feb 2022
Posts: 6
Location: ITALY

PostPosted: Thu Mar 03, 2022 2:57 pm
Reply with quote

Seems to work using by NUMVAL-C function. Thanks.
Back to top
View user's profile Send private message
AlanW2

New User


Joined: 14 Sep 2022
Posts: 1
Location: United States

PostPosted: Wed Sep 14, 2022 11:46 pm
Reply with quote

I don't have access to the code anymore but at one site we wrapped the NUMVAL function in its own small cobol routine and it trapped any NUMVAL exceptions and instead returned a status. The nice thing there is that NUMVAL was the ONLY editing performed against numbers from outside sources. No inspects, no other checking of content. If NUMVAL was happy, the number was considered good. It was done in a way where other exceptions for unrelated reasons could still be raised. I do recall that the proper CEE3 routine and a code sample was found during a google search. It all worked very well.
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 INSYNC option with same function as I... JCL & VSAM 0
No new posts z/vm installation problem All Other Mainframe Topics 0
No new posts Job scheduling problem. JCL & VSAM 9
No new posts Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
No new posts Need to add field to copybook, proble... COBOL Programming 14
Search our Forums:

Back to Top