NetCOBOL Invalid Value Specified on Comparison

430 views Asked by At

I am using NetCOBOL for .NET to extend a COBOL application. When I read through and input file I am doing a simple comparison on a numeric field and on certain records I get an INVALID VALUE SPECIFIED error.

The field is INV-MST-ONHAND as defined:

 02   INV-MST-LOCATION OCCURS 3.                  
    04 INV-MST-ONHAND         PIC S9(7)V999.
    04 INV-MST-SALES          PIC S9(6) OCCURS 12.         
    04 INV-MST-PTDSALE        PIC S9(6)V999.

The comparison is in this line of code

IF INV-MST-ONHAND(1) > 0 MOVE INV-MST-ONHAND(1) TO WS-ITEM-ONHAND.

It only happens on some records. The data file is indexed so it's not easy to parse by hand. I am looking for a way to fix it or even to skip over these but I don't know how to catch and handle this error condition.

Here is the full record layout:

000381 FD INVMAST
000382     RECORD 845 CHARACTERS.
000383 01  INV-MST-REC.
000384     02   INV-MST-MCS             PIC X(10).
000385     02   INV-MST-KEY.
000386       04 INV-MST-ITEM-NO            PIC X(15)
000387    02   INV-MST-ALT1-KEY.
000389       04 INV-MST-PLU                 PIC 9(13).
000390     02   INV-MST-ALT2-KEY.
000391       04 INV-MST-WORDS1         PIC X(10).
000392     02   INV-MST-ALT3-KEY.
000393       04 INV-MST-WORDS2         PIC X(10).
000394     02   INV-MST-ALT4-KEY        PIC X(10).
000395     02   INV-MST-ALT5-KEY.
000396       04 INV-MST-CATEGORY       PIC X(10).
000399     02   INV-MST-UPC-KEYS.
000400       04 INV-MST-UPC01-KEY       PIC X(15).
000401       04 INV-MST-UPC02-KEY       PIC X(15).
000402       04 INV-MST-UPC03-KEY       PIC X(15).
000403       04 INV-MST-UPC04-KEY       PIC X(15).
000404       04 INV-MST-UPC05-KEY       PIC X(15).
000405       04 INV-MST-UPC06-KEY       PIC X(15).
000406       04 INV-MST-UPC07-KEY       PIC X(15).
000407       04 INV-MST-UPC08-KEY       PIC X(15).
000408       04 INV-MST-UPC09-KEY       PIC X(15).
000409       04 INV-MST-UPC10-KEY       PIC X(15).
000410       04 INV-MST-UPC11-KEY       PIC X(15).
000411       04 INV-MST-UPC12-KEY       PIC X(15).
000412     02   INV-MST-ITEM-NAME.
000454      04  INV-MST-NAME1          PIC X(20).
000455      04  INV-MST-NAME2          PIC X(20).
000456      04  INV-MST-NAME3          PIC X(20).           
000457     02   INV-MST-SCRAP          PIC 9(6)V99.
000458     02   INV-MST-ENV-LEVY       PIC 9(3)V99.
000459     02   INV-MST-UORD           PIC XXX.
000460     02   INV-MST-USTOCK         PIC XXX.
000461     02   INV-MST-UUNO           PIC 99999.
000462     02   INV-MST-VEND1          PIC 9999.
000463     02   INV-MST-VEND2          PIC 9999.
000464     02   INV-MST-VEND3          PIC 9999.          
000465     02   INV-MST-ONORDER        PIC 9(6).
000466     02   INV-MST-COMMIT         PIC 9(6).
000467     02   INV-MST-REORD          PIC 9(5).          
000468     02   INV-MST-MINORD         PIC 9(5).
000469     02   INV-MST-BASIS          PIC 99.
000470     02   INV-MST-BIN            PIC X(6).
000471     02   INV-MST-GL             PIC 9(4).
000472     02   INV-MST-DEPT           PIC 999.
000473     02   INV-MST-ALTITEM1       PIC X(15).
000474     02   INV-MST-ALTITEM2       PIC X(15).            
000476     02   INV-MST-COST1          PIC 9(6)V99.
000477     02   INV-MST-COST2          PIC 9(6)V99.
000478     02   INV-MST-COST3          PIC 9(6)V99.
000479     02   INV-MST-COST4          PIC 9(6)V99.
000480     02   INV-MST-SELLPRICES. 
000481      04  INV-MST-SELL1          PIC 9(6)V99.
000482      04  INV-MST-SELL2          PIC 9(6)V99.
000483      04  INV-MST-SELL3          PIC 9(6)V99.
000484      04  INV-MST-SELL4          PIC 9(6)V99.
000485      04  INV-MST-SELL5          PIC 9(6)V99.         
000486     02   FILLER REDEFINES INV-MST-SELLPRICES.
000487      04  INV-MST-SELL                PIC 9(6)V99 OCCURS 5.
000488    02     INV-MST-SELLPRICE-FACTORS.
000489       04 INV-FACTOR OCCURS 5.
000490       06 INV-PRC-FACTOR          PIC 9V99.
000491       06 INV-COST-BASE               PIC X.              
000492     02   INV-MST-SALE-DECPT     PIC 9.
000493     02   INV-MST-STOCK-DECPT    PIC 9.
000494     02   INV-MST-PRICE-UNITS    PIC 9999.
000495     02   INV-MST-ALTERNATE-UNITS.
000496       04 INV-MST-ALT-DESC            PIC X(10).
000497       04 INV-MST-ALT-ABBREV      PIC XX.
000498       04 INV-MST-ALT-FACTOR      PIC 9(3)V9(4).
000499       04 INV-MST-ALT-SALE-FLAG   PIC X.
000500       04 INV-MST-ALT-ORDER-FLAG  PIC X.
000501     02   INV-MST-TAX1           PIC X.
000502     02   INV-MST-TAX2           PIC X.            
000503     02   INV-MST-LOCATION OCCURS 3.                  
000504       04 INV-MST-ONHAND         PIC S9(7)V999.
000505       04 INV-MST-SALES          PIC S9(6) OCCURS 12.         
000506       04 INV-MST-PTDSALE        PIC S9(6)V999.             
000507     02   INV-MST-FIL            PIC X(30). 

When I check the value of INV-MST-ONHAND(1) when it fails, Visual Studio debugger shows a value of +0000000.000 and the condition tests as true using Quick Watch.

When I inspect INV-MST-LOCATION(1) I see thisquick watch

1

There are 1 answers

0
Bill Woodger On BEST ANSWER

You are using a compiler option, CHECK, with sub-option (NUMERIC) or (ALL).

This is producing the JMP0828I-U message. The U means it will end execution. Somewhere you could tell it to instead produce E as a suffix to the message, in which case you'd get the message but execution would continue.

The problem is that you data does not "conform to PICture". You field is defined as signed (the S in your PICture string), but the overpunch which would indicate a positive or negative value is not present.

You mentioned that you created the data. What I suspect is that where you created the data you accidentally described that field as unsigned (no S in the PICture string) and then, for expedience, did a group-move to the record, allowing an unsigned value to get into your signed field.

The CHECK(NUMERIC) or CHECK(ALL) spotted this when you attempted the IF-test, and produced the message (and ended your program).

It is interesting that your NUMERIC test was true. There is probably a compiler-option to describe what is valid in the NUMERIC test. You'd need to locate this, and ensure that only positive and negative, and not unsigned, are valid for a signed field.

A couple of lessons: the message reference is important, and allows you to locate more information about the message - for your future searches, exclude the suffix, as the description in the documentation does not describe the suffixes separately; avoid group MOVEs - or take great care with them - a missing sign, or the wrong length or number of decimal places can give you subtle errors, its not worth the saving of coding vs time chasing the subtleties.

With your debugger, you should see if there is some way to see the actual source value, not the "edited" value that you showed in your question. Seeing the actual source would have aided you earlier.

Non-COMPUTATIONAL numerics are "zoned". One digit per byte, preceded by the "zone" value. For an unsigned value, all digits have zoned. For a signed value the low-order byte has the "overpunch" to indicate positive or negative instead.

An unsigned value is always treated as positive.

COBOL to the 1985 Standard has no mechanism to "catch" errors caused by non-numeric values. Your documentation will indicate whether you have any way to do that with your NetCOBOL run-time.