HP3000-L Archives

December 2003, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Brian Donaldson <[log in to unmask]>
Reply To:
Date:
Sun, 14 Dec 2003 23:44:46 EST
Content-Type:
text/plain
Parts/Attachments:
text/plain (153 lines)
I repeat one more time --

without the VALIDATE option in the $CONTROL statement non-numeric data can be
moved into numeric fields without a program abort (illegal ascii digit)

With the VALIDATE option in the $CONTROL statement alpha data being moved
into a numeric field (PIC 9(n), PIC S9(n) COMP, PIC s9(n) COMP-3) will cause a
run time program abort (illegal ascii digit error)

Moving non-numeric data into numeric fields can compromise the integrity of
your data. BTDT. At various companies I've worked at, I've seen many TurboIMAGE
data sets with corrupted data caused by COBOL programs moving non-numeric
data into COMP or COMP-3 fields.

Example:COBTEST SOURCE CODE:

$CONTROL VALIDATE
 IDENTIFICATION DIVISION.
 PROGRAM-ID. COBTEST.
 ENVIRONMENT DIVISION.
 DATA DIVISION.
 WORKING-STORAGE SECTION.
 01  WS-INPUT-DATA PIC X(8) VALUE "1234567 ".
 01  WS-COMP-FIELD PIC S9(8) COMP VALUE ZEROES.
 PROCEDURE DIVISION.
 MAINLINE.

     MOVE WS-INPUT-DATA TO WS-COMP-FIELD.
     DISPLAY "1) WS-INPUT-DATA " WS-INPUT-DATA.
     DISPLAY "2) WS-COMP-FIELD " WS-COMP-FIELD.
     STOP RUN.

At run time with VALIDATE in the $CONTROL:

Illegal ASCII digit (COBERR 711)
Program file: COBTEST.NMPRG.E3K
Trap type = 00000200 (22,00), at pc = 000000BB.00005E9B
invalid ascii digit
Source address = 418442E8, Source = '1234567 '
                  (hex)    Source = '3132333435363720'
DEBUG/iX C.25.06

HPDEBUG Intrinsic at: b9.00259304 cob_trap.print_message+$5ec
$$$$ Trap occurred at: _start+$70, at Stmt    #25
     PC=bb.00005654 $$valg+$14
  0) SP=41844330 RP=bb.00005ea0 _start+$78
* 1) SP=41844330 RP=bb.00000000
     (end of NM stack)
$$$$ The address $418442e8 = SP-$48 is in _start (TEMPCELL or $DYNAMIC)
============================================================

**** COB_QUIT 711 ****

ABORT: COBTEST.NMPRG.E3K
NM SYS   a.010061ec dbg_abort_trace+$28
NM USER  b9.00258398 COB_QUIT+$b8
NM SYS   a.002a315c px_getsig_lowpri+$188
 --- Interrupt Marker
NM SYS   a.01428150 ?pi_call_2_handler+$8
 --- Interrupt Marker
NM PROG  bb.00005654 $$valg+$14
Program terminated in an error state. (CIERR 976)

At run time without the VALIDATE in the $CONTROL:

:COBTEST
1) WS-INPUT-DATA 1234567
2) WS-COMP-FIELD +12345670

As you can see, the receiving field value is corrupted and does not reflect a
true account of the input data.

The same problem will occur if the SENDING field is defined as PIC 9(8) and
contains alpha data.

Other example, see this Cobol source code:

$CONTROL validate
 IDENTIFICATION DIVISION.
 PROGRAM-ID. COBTEST.
 ENVIRONMENT DIVISION.
 DATA DIVISION.
 WORKING-STORAGE SECTION.
 01  WS-INPUT-DATA.
     05  WS-ID-DATA PIC 9(8)       VALUE ZEROES.
 01  WS-COMP-FIELD  PIC S9(8) COMP VALUE ZEROES.
 PROCEDURE DIVISION.
 MAINLINE.

     MOVE "1234567 "    TO WS-INPUT-DATA.
     MOVE WS-INPUT-DATA TO WS-COMP-FIELD.
     DISPLAY "1) WS-INPUT-DATA   " WS-INPUT-DATA.
     DISPLAY "2) MOVE WS-ID-DATA " WS-ID-DATA.
     DISPLAY "3) WS-COMP-FIELD   " WS-COMP-FIELD.
     MOVE WS-ID-DATA TO WS-COMP-FIELD.
     DISPLAY "4) WS-COMP-FIELD   " WS-COMP-FIELD.
     STOP RUN.

At run time:

:COBTEST
1) WS-INPUT-DATA   1234567
2) MOVE WS-ID-DATA 1234567
3) WS-COMP-FIELD   +25373492
Illegal ASCII digit (COBERR 711)
Program file: COBTEST.NMPRG.E3K
Trap type = 00000200 (22,00), at pc = 000000DF.00005FB3
invalid ascii digit
Source address = 41646030, Source = '1234567 '
                  (hex)    Source = '3132333435363720'
DEBUG/iX C.25.06

HPDEBUG Intrinsic at: b9.00259304 cob_trap.print_message+$5ec
$$$$ Trap occurred at: _start+$188, at ????
     PC=df.00005654 $$valg+$14
  0) SP=41844370 RP=df.00005fb8 _start+$190
* 1) SP=41844370 RP=df.00000000
     (end of NM stack)
$$$$ The address $41646030 = DP+$30 may be in main, $SUBPROGRAM or EXTERNAL
============================================================

**** COB_QUIT 711 ****

ABORT: COBTEST.NMPRG.E3K
NM SYS   a.010061ec dbg_abort_trace+$28
NM USER  b9.00258398 COB_QUIT+$b8
NM SYS   a.002a315c px_getsig_lowpri+$188
 --- Interrupt Marker
NM SYS   a.01428150 ?pi_call_2_handler+$8
 --- Interrupt Marker
NM PROG  df.00005654 $$valg+$14
Program terminated in an error state. (CIERR 976)

Example of same code without the VALIDATE option in the $CONTROL statement:

COBTEST
1) WS-INPUT-DATA   1234567
2) MOVE WS-ID-DATA 1234567
3) WS-COMP-FIELD   +25373492
4) WS-COMP-FIELD   +12345670

As you can see the resultant receiving data is totally corrupted and wrong!

Let me reiterate one more time -- moving "X" type data into numeric fields
(COMP, COMP-3 or plain old PIC 9(N) fields) can be hazardous to your data.

BTDT way too many times!!!

Brian Donaldson.

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2