For Programmers: Free Programming Magazines  


Home > Archive > Cobol > September 2004 > how do I move NULL into a field ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how do I move NULL into a field ?
aaryam

2004-08-17, 8:55 pm

Hello:

I need to move NULL or null value into a field in cobol.

eg: I have a field called store-id PIC S99999V COMP-3. since I dont
populate any value into it I need to move NULL into it. It shouldn't be
zero. how do I do that in COBOL.

please help

RM



--
posted via MFF : http://www.MainFrameForum.com - USENET Gateway
Robert Wagner

2004-08-17, 8:55 pm

On Tue, 17 Aug 2004 21:58:09 GMT, aaryam <member@mainframeforum.com>
wrote:

>I need to move NULL or null value into a field in cobol.
>
>eg: I have a field called store-id PIC S99999V COMP-3. since I dont
>populate any value into it I need to move NULL into it. It shouldn't be
>zero. how do I do that in COBOL.
>
>please help


Move low-values to the group name before you start moving or put a
group name over the individual field, which is functionally the same
as redefines, and move low-values to it.

Caution: it is not common practice to put nulls in packed fields. On
IBM mainframes, a reference to the numeric field name will cause an
abend. Some non-mainframe compilers, for instance Micro Focus, also
cause an abend unless a non-default runtime option is used. Why do you
think you "need" to fill it with nulls?


Mike

2004-08-17, 8:55 pm

> Hello
>
> I need to move NULL or null value into a field in cobol
>
> eg: I have a field called store-id PIC S99999V COMP-3. since I don
> populate any value into it I need to move NULL into it. It shouldn't b
> zero. how do I do that in COBOL
>
> please hel
> posted via MFF : http://www.MainFrameForum.com - USENET Gateway


Since you posted this from MainFrameForum I will assume you are on
an IBM mainframe. Are you sure you know what you're doing?
COMP-3 is PACKED-DECIMAL and I assume by nulls you mean binary zeros?
Moving binary zeros would create an invalid packed field.
Can you say S0C7?

Anyway, here you go:

05 store-id pic S99999V comp-3.
05 store-id-x redefines
store-id pic x(3).

move low-values to store-id-x.

Don't blame me for abends.



Don Leahy

2004-08-17, 8:55 pm

"aaryam" <member@mainframeforum.com> wrote in message
news:RbvUc.22870$kC6.13105@cyclops.nntpserver.com...
> Hello:
>
> I need to move NULL or null value into a field in cobol.
>
> eg: I have a field called store-id PIC S99999V COMP-3. since I dont
> populate any value into it I need to move NULL into it. It shouldn't be
> zero. how do I do that in COBOL.
>
> please help
>
> RM
>
>
>
> --
> posted via MFF : http://www.MainFrameForum.com - USENET Gateway


Is this a DB2 program? ie, are you asking how to set a column to null via
a host variable?


JerryMouse

2004-08-17, 8:55 pm

aaryam wrote:
> Hello:
>
> I need to move NULL or null value into a field in cobol.


Trust me: No you don't.

>
> eg: I have a field called store-id PIC S99999V COMP-3. since I dont
> populate any value into it I need to move NULL into it. It shouldn't
> be zero. how do I do that in COBOL.


"Store-id" An identifier? If an identifier it should never be defined as a
numeric field (part numbers, zip codes, telephone or social security
numbers, etc.). If you can't do arithmetic on the value, it's not a number
and shouldn't be defined as one.


Jack Sleight

2004-08-18, 3:55 am

Hi RM,

Null data fields usually don't appear in COBOL code unless the field
is an address or a designated field in a DB2 table.

If it's packed it can't be an address. Could this field be a DB2 table
field?

Regards, Jack.




aaryam <member@mainframeforum.com> wrote in message news:<RbvUc.22870$kC6.13105@cyclops.nntpserver.com>...
> Hello:
>
> I need to move NULL or null value into a field in cobol.
>
> eg: I have a field called store-id PIC S99999V COMP-3. since I dont
> populate any value into it I need to move NULL into it. It shouldn't be
> zero. how do I do that in COBOL.
>
> please help
>
> RM

Robert Wagner

2004-08-18, 3:55 am

On Tue, 17 Aug 2004 18:53:46 -0500, "JerryMouse" <nospam@bisusa.com>
wrote:

> If you can't do arithmetic on the value, it's not a number
>and shouldn't be defined as one.


Well said. For this reason, dates are not numeric.

Michael Mattias

2004-08-18, 8:55 am

> > I need to move NULL or null value into a field in cobol.[color=darkred]

COBOL does not have a NULL value.

You can have a numeric zero, or an alphanumeric string of binary zeroes or
spaces, but there is no such thing as

01 FILLER
06 THE-DATA PIC anything VALUE IS NULL

or

MOVE NULL TO THE-DATA
or
SET THE-DATA TO NULL

That said, external programs might _consider_ a value as NULL; e.g., a
string of binary zeroes might be _interpreted_ as a null string by a 'C'
language program; or (better example for COBOL programmers) setting a
database indicator value to SQL_NULL tells a database manager that the data
being supplied is to be considered NULL.

MCM












Joe Zitzelberger

2004-08-18, 3:55 pm

IBM Cobol, which this seems to be, does have a null value -- for
Pointers.

You can use:

SET THE-DATA TO NULL

as long as THE-DATA is defined as usage pointer.


In article <R4HUc.1293$kd2.961@newssvr15.news.prodigy.com>,
"Michael Mattias" <michael.mattias@gte.net> wrote:

>
> COBOL does not have a NULL value.
>
> You can have a numeric zero, or an alphanumeric string of binary zeroes or
> spaces, but there is no such thing as
>
> 01 FILLER
> 06 THE-DATA PIC anything VALUE IS NULL
>
> or
>
> MOVE NULL TO THE-DATA
> or
> SET THE-DATA TO NULL
>
> That said, external programs might _consider_ a value as NULL; e.g., a
> string of binary zeroes might be _interpreted_ as a null string by a 'C'
> language program; or (better example for COBOL programmers) setting a
> database indicator value to SQL_NULL tells a database manager that the data
> being supplied is to be considered NULL.
>
> MCM


Howard Brazee

2004-08-18, 3:55 pm


On 17-Aug-2004, aaryam <member@mainframeforum.com> wrote:

> Hello:
>
> I need to move NULL or null value into a field in cobol.
>
> eg: I have a field called store-id PIC S99999V COMP-3. since I dont
> populate any value into it I need to move NULL into it. It shouldn't be
> zero. how do I do that in COBOL.
>
> please help


How does your subsequent program know that this COMP-3 field is null?
danactn

2004-08-18, 8:55 pm

Robert Wagner wrote:
> On Tue, 17 Aug 2004 18:53:46 -0500, "JerryMouse"
> <nospam@bisusa.com> wrote:
> Well said. For this reason, dates are not numeric.




You don't work in an accounting environment with aged payables and
receivables, I take it.



--
posted via MFF : http://www.MainFrameForum.com - USENET Gateway
Lorne Sunley

2004-08-19, 3:55 am

On Tue, 17 Aug 2004 21:58:09 UTC, aaryam <member@mainframeforum.com>
wrote:

> Hello:
>
> I need to move NULL or null value into a field in cobol.
>
> eg: I have a field called store-id PIC S99999V COMP-3. since I dont
> populate any value into it I need to move NULL into it. It shouldn't be
> zero. how do I do that in COBOL.
>
> please help
>
> RM
>
>
>


Have you tried LOW-VALUES?

--
Lorne Sunley
Frank Swarbrick

2004-08-21, 3:55 am

Having a packed decimal field (or even a numeric USAGE DISPLAY field) set to
low-values can be useful when you want to differentiate between a field that
has a value of zero and a field that has 'no value'.

To be honest, I can't recall offhand a specific situation where I used this,
but I seem to recall at least having done so. Justifiably? Perhaps not,
but I'd have to recall my specific situation in order to discuss it
further...

In any case, there would obviously be code later that would say something
like:

if packed-field numeric
perform handle-numeric
else
perform handle-other
end-if

Frank

> Hello
>
> I need to move NULL or null value into a field in cobol
>
> eg: I have a field called store-id PIC S99999V COMP-3. since I don
> populate any value into it I need to move NULL into it. It shouldn't b
> zero. how do I do that in COBOL
>
> please hel
> posted via MFF : http://www.MainFrameForum.com - USENET Gateway


Since you posted this from MainFrameForum I will assume you are on
an IBM mainframe. Are you sure you know what you're doing?
COMP-3 is PACKED-DECIMAL and I assume by nulls you mean binary zeros?
Moving binary zeros would create an invalid packed field.
Can you say S0C7?

Anyway, here you go:

05 store-id pic S99999V comp-3.
05 store-id-x redefines
store-id pic x(3).

move low-values to store-id-x.

Don't blame me for abends.





JerryMouse

2004-08-21, 3:55 am

Frank Swarbrick wrote:
> Having a packed decimal field (or even a numeric USAGE DISPLAY field)
> set to low-values can be useful when you want to differentiate
> between a field that has a value of zero and a field that has 'no
> value'.
>
> To be honest, I can't recall offhand a specific situation where I
> used this, but I seem to recall at least having done so.
> Justifiably? Perhaps not, but I'd have to recall my specific
> situation in order to discuss it further...
>
> In any case, there would obviously be code later that would say
> something like:
>
> if packed-field numeric
> perform handle-numeric
> else
> perform handle-other
> end-if
>
> Frank


Sure. If zero is a permissable value, how do you distinguish a non-value? In
my view, a better way is a specific value way outside the value's range. For
example, sales-year-to-date for a new customer could be initialized
to -99999.99 or depth-of-well could be -100 (that is, there are 100 feet of
pipe sticking up in the air).

In this way, you substitute one I-know-the-secret for a different
I-know-the-secret.


N Benson

2004-08-21, 3:55 am

RM

Because a COMP-3 field (signed) isn't suitable for storing a Null value (?), any
processing you do on the field will check that it contains a valid number
(signed) and probably abend (die screaming).

The way I would get around this is to redefine the storage area and manually
check for a Null (whether you select spaces, low values, high values for your
Null, in my example I'll use low values as this is other languages treat as
nulls.)

eg:

03 store-id PIC S99999V COMP-3.
03 store-id-str PIC X(3).
88 Null-store-id VALUE LOW-VALUES.
....
....
****** Read your data

IF NOT Null-store-id
***** Do what you'd like mathematically with store-id.


Regards

Nigel

> Hello:
>
> I need to move NULL or null value into a field in cobol.
>
> eg: I have a field called store-id PIC S99999V COMP-3. since I dont
> populate any value into it I need to move NULL into it. It shouldn't be
> zero. how do I do that in COBOL.
>
> please help
>
> RM



Warren Simmons

2004-08-21, 3:55 am

Frank Swarbrick wrote:
> Having a packed decimal field (or even a numeric USAGE DISPLAY field) set to
> low-values can be useful when you want to differentiate between a field that
> has a value of zero and a field that has 'no value'.
>
> To be honest, I can't recall offhand a specific situation where I used this,
> but I seem to recall at least having done so. Justifiably? Perhaps not,
> but I'd have to recall my specific situation in order to discuss it
> further...
>
> In any case, there would obviously be code later that would say something
> like:
>
> if packed-field numeric
> perform handle-numeric
> else
> perform handle-other
> end-if
>
> Frank
>
>
>
>
> Since you posted this from MainFrameForum I will assume you are on
> an IBM mainframe. Are you sure you know what you're doing?
> COMP-3 is PACKED-DECIMAL and I assume by nulls you mean binary zeros?
> Moving binary zeros would create an invalid packed field.
> Can you say S0C7?
>
> Anyway, here you go:
>
> 05 store-id pic S99999V comp-3.
> 05 store-id-x redefines
> store-id pic x(3).
>
> move low-values to store-id-x.
>
> Don't blame me for abends.
>
>
>
>
>

This may help, but who knows.

Early days of computing.
Merging files.
Need something that will cause all data to pass as larger.

End of Idea.

Warren Simmons
Robert Wagner

2004-08-21, 3:56 am

On Tue, 17 Aug 2004 21:58:09 GMT, aaryam <member@mainframeforum.com>
wrote:

>I need to move NULL or null value into a field in cobol.
>
>eg: I have a field called store-id PIC S99999V COMP-3. since I dont
>populate any value into it I need to move NULL into it. It shouldn't be
>zero. how do I do that in COBOL.
>
>please help


Move low-values to the group name before you start moving or put a
group name over the individual field, which is functionally the same
as redefines, and move low-values to it.

Caution: it is not common practice to put nulls in packed fields. On
IBM mainframes, a reference to the numeric field name will cause an
abend. Some non-mainframe compilers, for instance Micro Focus, also
cause an abend unless a non-default runtime option is used. Why do you
think you "need" to fill it with nulls?


Mike

2004-08-21, 3:56 am

> Hello
>
> I need to move NULL or null value into a field in cobol
>
> eg: I have a field called store-id PIC S99999V COMP-3. since I don
> populate any value into it I need to move NULL into it. It shouldn't b
> zero. how do I do that in COBOL
>
> please hel
> posted via MFF : http://www.MainFrameForum.com - USENET Gateway


Since you posted this from MainFrameForum I will assume you are on
an IBM mainframe. Are you sure you know what you're doing?
COMP-3 is PACKED-DECIMAL and I assume by nulls you mean binary zeros?
Moving binary zeros would create an invalid packed field.
Can you say S0C7?

Anyway, here you go:

05 store-id pic S99999V comp-3.
05 store-id-x redefines
store-id pic x(3).

move low-values to store-id-x.

Don't blame me for abends.



Ubiquitous

2004-08-21, 3:56 am

JerryMouse <nospam@bisusa.com> wrote:

: Sure. If zero is a permissable value, how do you distinguish a non-value? In
: my view, a better way is a specific value way outside the value's range. For
: example, sales-year-to-date for a new customer could be initialized
: to -99999.99 or depth-of-well could be -100 (that is, there are 100 feet of
: pipe sticking up in the air).

In COBOL, is there really a need for NULL?
I mean, it seems to me that initializing to zeros would suffice.

Lowell Young

2004-08-21, 3:56 am

However, a date in ddmmyyyy can be used in arithmetic.

Robert Wagner wrote:
> On Tue, 17 Aug 2004 18:53:46 -0500, "JerryMouse" <nospam@bisusa.com>
> wrote:
>
>
>
>
> Well said. For this reason, dates are not numeric.
>


Lorne Sunley

2004-08-21, 3:56 am

On Fri, 20 Aug 2004 20:02:38 UTC, weberm@polaris.net (Ubiquitous)
wrote:

> JerryMouse <nospam@bisusa.com> wrote:
>
> : Sure. If zero is a permissable value, how do you distinguish a non-value? In
> : my view, a better way is a specific value way outside the value's range. For
> : example, sales-year-to-date for a new customer could be initialized
> : to -99999.99 or depth-of-well could be -100 (that is, there are 100 feet of
> : pipe sticking up in the air).
>
> In COBOL, is there really a need for NULL?
> I mean, it seems to me that initializing to zeros would suffice.
>


Not when it is a numeric field and you want to know if it has been
set. zero is a valid number and a zero in the field can be a valid
entry (depending on the application, of course)

--
Lorne Sunley
JerryMouse

2004-08-21, 3:56 am

Ubiquitous wrote:
> JerryMouse <nospam@bisusa.com> wrote:
>
>
> In COBOL, is there really a need for NULL?
> I mean, it seems to me that initializing to zeros would suffice.


1. And where zero is a valid value? (HOURS-OVERTIME, QUAN-ON-HAND, etc.)

2. If there were no need for a NULL, LOW-VALUES would not be part of the
language construct (I know, I know: LOW-VALUES is but the smallest value in
the collating sequence).


Jack Sleight

2004-08-21, 3:56 am

Hello aaryam (RM),

Are you out there? You've gotten 17 replies to your ques. How about
the courtesy of some feedback from you?



N Benson <nigel@lbenny1.demon.co.uk> wrote in message news:<caeai0lb97hjf19qt8ro8kar4ttccup0ok@4ax.com>...[color=darkred]
> RM
>
> Because a COMP-3 field (signed) isn't suitable for storing a Null value (?), any
> processing you do on the field will check that it contains a valid number
> (signed) and probably abend (die screaming).
>
> The way I would get around this is to redefine the storage area and manually
> check for a Null (whether you select spaces, low values, high values for your
> Null, in my example I'll use low values as this is other languages treat as
> nulls.)
>
> eg:
>
> 03 store-id PIC S99999V COMP-3.
> 03 store-id-str PIC X(3).
> 88 Null-store-id VALUE LOW-VALUES.
> ....
> ....
> ****** Read your data
>
> IF NOT Null-store-id
> ***** Do what you'd like mathematically with store-id.
>
>
> Regards
>
> Nigel
>
JerryMouse

2004-08-21, 8:55 pm

Jack Sleight wrote:
> Hello aaryam (RM),
>
> Are you out there? You've gotten 17 replies to your ques. How about
> the courtesy of some feedback from you?
>
>


For some, newsgroups are a write-only medium.

Strange the concept should be so pervasive.

I once invented write-only ROM (block of wood with two imbedded wires).
Wasn't popular at all.

I've written two totally non-popular books: "The New Testament in Morse
Code" and "Toilet Tissue Origami."

Maybe its just me.


Joe Zitzelberger

2004-08-22, 3:55 am

IBM Cobol, which this seems to be, does have a null value -- for
Pointers.

You can use:

SET THE-DATA TO NULL

as long as THE-DATA is defined as usage pointer.


In article <R4HUc.1293$kd2.961@newssvr15.news.prodigy.com>,
"Michael Mattias" <michael.mattias@gte.net> wrote:

>
> COBOL does not have a NULL value.
>
> You can have a numeric zero, or an alphanumeric string of binary zeroes or
> spaces, but there is no such thing as
>
> 01 FILLER
> 06 THE-DATA PIC anything VALUE IS NULL
>
> or
>
> MOVE NULL TO THE-DATA
> or
> SET THE-DATA TO NULL
>
> That said, external programs might _consider_ a value as NULL; e.g., a
> string of binary zeroes might be _interpreted_ as a null string by a 'C'
> language program; or (better example for COBOL programmers) setting a
> database indicator value to SQL_NULL tells a database manager that the data
> being supplied is to be considered NULL.
>
> MCM


Lueko Willms

2004-08-22, 3:55 am

.. Am 21.08.04
schrieb nospam@bisusa.com (JerryMouse)
auf /COMP/LANG/COBOL
in dYqdnZySoPl2QbrcRVn-rA@giganews.com
ueber Re: how do I move NULL into a field ?

n> I once invented write-only ROM (block of wood with two imbedded
n> wires).

That would be a WOM, not ROM.


Yours,
Lüko Willms http://www.mlwerke.de
/--------- L.WILLMS@jpberlin.de -- Alle Rechte vorbehalten --

"Regierung aus dem Volke, durch das Volk und für das Volk"
- Abraham Lincoln, Ansprache in Gettysburg, 19.11.1863
"... was in die revolutionäre Sprache von heute übersetzt heißt:
eine Regierung von Arbeitern, durch Arbeiter und für Arbeiter"
- Fidel Castro, November 1994
Jeff York

2004-08-22, 8:55 am

l.willms@jpberlin.de (Lueko Willms) wrote:

>. Am 21.08.04
>schrieb nospam@bisusa.com (JerryMouse)
> auf /COMP/LANG/COBOL
> in dYqdnZySoPl2QbrcRVn-rA@giganews.com
> ueber Re: how do I move NULL into a field ?
>
>n> I once invented write-only ROM (block of wood with two imbedded
>n> wires).
>
> That would be a WOM, not ROM.


Just the "storage" device to keep auditors happy.. They insist that
you keep everything, but never look at it. :-)

--
Jeff. Ironbridge, Shrops, U.K.
jjy@jakfield.xu-netx.com (remove the x..x round u-net for return address)
and don't bother with ralf4, it's a spamtrap and I never go there.. :)

.... "There are few hours in life more agreeable
than the hour dedicated to the ceremony
known as afternoon tea.."

Henry James, (1843 - 1916).


SkippyPB

2004-08-22, 3:55 pm

On 22 Aug 2004 05:17:00 GMT, l.willms@jpberlin.de (Lueko Willms)
enlightened us:

>. Am 21.08.04
>schrieb nospam@bisusa.com (JerryMouse)
> auf /COMP/LANG/COBOL
> in dYqdnZySoPl2QbrcRVn-rA@giganews.com
> ueber Re: how do I move NULL into a field ?
>
>n> I once invented write-only ROM (block of wood with two imbedded
>n> wires).
>
> That would be a WOM, not ROM.
>
>


Wouldn't that be WOW (write only wood)?

>Yours,
>Lüko Willms http://www.mlwerke.de
>/--------- L.WILLMS@jpberlin.de -- Alle Rechte vorbehalten --
>
>"Regierung aus dem Volke, durch das Volk und für das Volk"
> - Abraham Lincoln, Ansprache in Gettysburg, 19.11.1863
>"... was in die revolutionäre Sprache von heute übersetzt heißt:
>eine Regierung von Arbeitern, durch Arbeiter und für Arbeiter"
> - Fidel Castro, November 1994


Regards,

////
(o o)
-oOO--(_)--OOo-


"He who would trade an ounce of freedom for a
pound of security loses both and deserves neither."
-- Benjamin Franklin..
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Remove nospam to email me.

Steve
Donald Tees

2004-08-22, 3:55 pm

SkippyPB wrote:
> On 22 Aug 2004 05:17:00 GMT, l.willms@jpberlin.de (Lueko Willms)
> enlightened us:
>
>
>
>
> Wouldn't that be WOW (write only wood)?
>


For users as dumb as a stump ... I wonder how much encoding is
encapsulated in tree DNA?

Donald

Robert Wagner

2004-08-22, 3:55 pm

On Sun, 22 Aug 2004 11:09:14 -0400, Donald Tees
<donald_tees@sympatico.ca> wrote:

>SkippyPB wrote:
>
>For users as dumb as a stump ...


Let's not malign testers.

>I wonder how much encoding is encapsulated in tree DNA?


Hardwoods have 1B base pairs; conifers have 15-30B. For comparison,
humans have 3B.

Most grasses have 2B base pairs, but rice has only .5B while wheat has
16B.

In all cases, more than 90 percent is junk. When they do DNA matching,
as in forensics, the sequences they're matching are all junk. It
doesn't matter, junk is copied with as much fidelity as good stuff.

Mike

2004-08-22, 8:55 pm

> Hello
>
> I need to move NULL or null value into a field in cobol
>
> eg: I have a field called store-id PIC S99999V COMP-3. since I don
> populate any value into it I need to move NULL into it. It shouldn't b
> zero. how do I do that in COBOL
>
> please hel
> posted via MFF : http://www.MainFrameForum.com - USENET Gateway


Since you posted this from MainFrameForum I will assume you are on
an IBM mainframe. Are you sure you know what you're doing?
COMP-3 is PACKED-DECIMAL and I assume by nulls you mean binary zeros?
Moving binary zeros would create an invalid packed field.
Can you say S0C7?

Anyway, here you go:

05 store-id pic S99999V comp-3.
05 store-id-x redefines
store-id pic x(3).

move low-values to store-id-x.

Don't blame me for abends.



Robert Wagner

2004-08-22, 8:55 pm

On Tue, 17 Aug 2004 21:58:09 GMT, aaryam <member@mainframeforum.com>
wrote:

>I need to move NULL or null value into a field in cobol.
>
>eg: I have a field called store-id PIC S99999V COMP-3. since I dont
>populate any value into it I need to move NULL into it. It shouldn't be
>zero. how do I do that in COBOL.
>
>please help


Move low-values to the group name before you start moving or put a
group name over the individual field, which is functionally the same
as redefines, and move low-values to it.

Caution: it is not common practice to put nulls in packed fields. On
IBM mainframes, a reference to the numeric field name will cause an
abend. Some non-mainframe compilers, for instance Micro Focus, also
cause an abend unless a non-default runtime option is used. Why do you
think you "need" to fill it with nulls?


JerryMouse

2004-08-22, 8:55 pm

Robert Wagner wrote:
>
> In all cases, more than 90 percent is junk. When they do DNA matching,
> as in forensics, the sequences they're matching are all junk. It
> doesn't matter, junk is copied with as much fidelity as good stuff.


This is true in data process also.


Don Leahy

2004-08-22, 8:55 pm

"aaryam" <member@mainframeforum.com> wrote in message
news:RbvUc.22870$kC6.13105@cyclops.nntpserver.com...
> Hello:
>
> I need to move NULL or null value into a field in cobol.
>
> eg: I have a field called store-id PIC S99999V COMP-3. since I dont
> populate any value into it I need to move NULL into it. It shouldn't be
> zero. how do I do that in COBOL.
>
> please help
>
> RM
>
>
>
> --
> posted via MFF : http://www.MainFrameForum.com - USENET Gateway


Is this a DB2 program? ie, are you asking how to set a column to null via
a host variable?


JerryMouse

2004-08-23, 3:55 am

aaryam wrote:
> Hello:
>
> I need to move NULL or null value into a field in cobol.


Trust me: No you don't.

>
> eg: I have a field called store-id PIC S99999V COMP-3. since I dont
> populate any value into it I need to move NULL into it. It shouldn't
> be zero. how do I do that in COBOL.


"Store-id" An identifier? If an identifier it should never be defined as a
numeric field (part numbers, zip codes, telephone or social security
numbers, etc.). If you can't do arithmetic on the value, it's not a number
and shouldn't be defined as one.


Jack Sleight

2004-08-23, 3:55 am

Hi RM,

Null data fields usually don't appear in COBOL code unless the field
is an address or a designated field in a DB2 table.

If it's packed it can't be an address. Could this field be a DB2 table
field?

Regards, Jack.




aaryam <member@mainframeforum.com> wrote in message news:<RbvUc.22870$kC6.13105@cyclops.nntpserver.com>...
> Hello:
>
> I need to move NULL or null value into a field in cobol.
>
> eg: I have a field called store-id PIC S99999V COMP-3. since I dont
> populate any value into it I need to move NULL into it. It shouldn't be
> zero. how do I do that in COBOL.
>
> please help
>
> RM

Ubiquitous

2004-08-23, 3:55 am

JerryMouse <nospam@bisusa.com> wrote:

: Sure. If zero is a permissable value, how do you distinguish a non-value? In
: my view, a better way is a specific value way outside the value's range. For
: example, sales-year-to-date for a new customer could be initialized
: to -99999.99 or depth-of-well could be -100 (that is, there are 100 feet of
: pipe sticking up in the air).

In COBOL, is there really a need for NULL?
I mean, it seems to me that initializing to zeros would suffice.

Michael Mattias

2004-08-23, 3:55 am

> > I need to move NULL or null value into a field in cobol.[color=darkred]

COBOL does not have a NULL value.

You can have a numeric zero, or an alphanumeric string of binary zeroes or
spaces, but there is no such thing as

01 FILLER
06 THE-DATA PIC anything VALUE IS NULL

or

MOVE NULL TO THE-DATA
or
SET THE-DATA TO NULL

That said, external programs might _consider_ a value as NULL; e.g., a
string of binary zeroes might be _interpreted_ as a null string by a 'C'
language program; or (better example for COBOL programmers) setting a
database indicator value to SQL_NULL tells a database manager that the data
being supplied is to be considered NULL.

MCM












Howard Brazee

2004-08-23, 8:55 am


On 17-Aug-2004, aaryam <member@mainframeforum.com> wrote:

> Hello:
>
> I need to move NULL or null value into a field in cobol.
>
> eg: I have a field called store-id PIC S99999V COMP-3. since I dont
> populate any value into it I need to move NULL into it. It shouldn't be
> zero. how do I do that in COBOL.
>
> please help


How does your subsequent program know that this COMP-3 field is null?
Joe Zitzelberger

2004-08-23, 8:55 am

In article <9FLYHsw9flB@jpberlin-l.willms.jpberlin.de>,
l.willms@jpberlin.de (Lueko Willms) wrote:

> . Am 21.08.04
> schrieb nospam@bisusa.com (JerryMouse)
> auf /COMP/LANG/COBOL
> in dYqdnZySoPl2QbrcRVn-rA@giganews.com
> ueber Re: how do I move NULL into a field ?
>
> n> I once invented write-only ROM (block of wood with two imbedded
> n> wires).
>
> That would be a WOM, not ROM.
>


I suppose, depending upon the type of wood, it could have been a Binary
Archive in a Tree...

Thus making it a WOM-BAT.

Jack Sleight

2004-08-23, 3:55 pm

Hello aaryam (RM),

Are you out there? You've gotten 17 replies to your ques. How about
the courtesy of some feedback from you?



N Benson <nigel@lbenny1.demon.co.uk> wrote in message news:<caeai0lb97hjf19qt8ro8kar4ttccup0ok@4ax.com>...[color=darkred]
> RM
>
> Because a COMP-3 field (signed) isn't suitable for storing a Null value (?), any
> processing you do on the field will check that it contains a valid number
> (signed) and probably abend (die screaming).
>
> The way I would get around this is to redefine the storage area and manually
> check for a Null (whether you select spaces, low values, high values for your
> Null, in my example I'll use low values as this is other languages treat as
> nulls.)
>
> eg:
>
> 03 store-id PIC S99999V COMP-3.
> 03 store-id-str PIC X(3).
> 88 Null-store-id VALUE LOW-VALUES.
> ....
> ....
> ****** Read your data
>
> IF NOT Null-store-id
> ***** Do what you'd like mathematically with store-id.
>
>
> Regards
>
> Nigel
>
Lorne Sunley

2004-08-23, 3:55 pm

On Tue, 17 Aug 2004 21:58:09 UTC, aaryam <member@mainframeforum.com>
wrote:

> Hello:
>
> I need to move NULL or null value into a field in cobol.
>
> eg: I have a field called store-id PIC S99999V COMP-3. since I dont
> populate any value into it I need to move NULL into it. It shouldn't be
> zero. how do I do that in COBOL.
>
> please help
>
> RM
>
>
>


Have you tried LOW-VALUES?

--
Lorne Sunley
N Benson

2004-08-26, 3:55 pm

RM

Because a COMP-3 field (signed) isn't suitable for storing a Null value (?), any
processing you do on the field will check that it contains a valid number
(signed) and probably abend (die screaming).

The way I would get around this is to redefine the storage area and manually
check for a Null (whether you select spaces, low values, high values for your
Null, in my example I'll use low values as this is other languages treat as
nulls.)

eg:

03 store-id PIC S99999V COMP-3.
03 store-id-str PIC X(3).
88 Null-store-id VALUE LOW-VALUES.
....
....
****** Read your data

IF NOT Null-store-id
***** Do what you'd like mathematically with store-id.


Regards

Nigel

> Hello:
>
> I need to move NULL or null value into a field in cobol.
>
> eg: I have a field called store-id PIC S99999V COMP-3. since I dont
> populate any value into it I need to move NULL into it. It shouldn't be
> zero. how do I do that in COBOL.
>
> please help
>
> RM



Howard Brazee

2004-08-26, 3:55 pm


On 20-Aug-2004, "Lorne Sunley" <lsunley@mb.sympatico.ca> wrote:

>
> Not when it is a numeric field and you want to know if it has been
> set. zero is a valid number and a zero in the field can be a valid
> entry (depending on the application, of course)


But the question remains - how are you using this null field? Some program
must read this field and determine it is null. As with any programming
problem, we should determine how a field is used before determining how to
create it.
Howard Brazee

2004-08-26, 3:55 pm


On 20-Aug-2004, Lowell Young <ittool@comcast.net> wrote:
[color=darkred]
> However, a date in ddmmyyyy can be used in arithmetic.
>

What kind of arithmetic would you use that date format in?
Donald Tees

2004-08-26, 3:55 pm

SkippyPB wrote:
> On 22 Aug 2004 05:17:00 GMT, l.willms@jpberlin.de (Lueko Willms)
> enlightened us:
>
>
>
>
> Wouldn't that be WOW (write only wood)?
>


For users as dumb as a stump ... I wonder how much encoding is
encapsulated in tree DNA?

Donald

Robert Wagner

2004-08-26, 3:55 pm

On Sun, 22 Aug 2004 11:09:14 -0400, Donald Tees
<donald_tees@sympatico.ca> wrote:

>SkippyPB wrote:
>
>For users as dumb as a stump ...


Let's not malign testers.

>I wonder how much encoding is encapsulated in tree DNA?


Hardwoods have 1B base pairs; conifers have 15-30B. For comparison,
humans have 3B.

Most grasses have 2B base pairs, but rice has only .5B while wheat has
16B.

In all cases, more than 90 percent is junk. When they do DNA matching,
as in forensics, the sequences they're matching are all junk. It
doesn't matter, junk is copied with as much fidelity as good stuff.

tom

2004-08-26, 3:55 pm

On Fri, 20 Aug 2004 23:59:41 GMT, "Lorne Sunley"
<lsunley@mb.sympatico.ca> wrote:

>On Fri, 20 Aug 2004 20:02:38 UTC, weberm@polaris.net (Ubiquitous)
>wrote:
>
>
>Not when it is a numeric field and you want to know if it has been
>set. zero is a valid number and a zero in the field can be a valid
>entry (depending on the application, of course)

You can do it the way SQL doess it on Tandem. make the element a
group-item, consissting of an indicator and a VALU.
03 STORE-ID.
05 INDICATOR PIC S9(01).
05 VALU PIC X(3).

And if you want it to represent null, you move -1 to the indicator
..

Warren Simmons

2004-08-26, 3:55 pm

Frank Swarbrick wrote:
> Having a packed decimal field (or even a numeric USAGE DISPLAY field) set to
> low-values can be useful when you want to differentiate between a field that
> has a value of zero and a field that has 'no value'.
>
> To be honest, I can't recall offhand a specific situation where I used this,
> but I seem to recall at least having done so. Justifiably? Perhaps not,
> but I'd have to recall my specific situation in order to discuss it
> further...
>
> In any case, there would obviously be code later that would say something
> like:
>
> if packed-field numeric
> perform handle-numeric
> else
> perform handle-other
> end-if
>
> Frank
>
>
>
>
> Since you posted this from MainFrameForum I will assume you are on
> an IBM mainframe. Are you sure you know what you're doing?
> COMP-3 is PACKED-DECIMAL and I assume by nulls you mean binary zeros?
> Moving binary zeros would create an invalid packed field.
> Can you say S0C7?
>
> Anyway, here you go:
>
> 05 store-id pic S99999V comp-3.
> 05 store-id-x redefines
> store-id pic x(3).
>
> move low-values to store-id-x.
>
> Don't blame me for abends.
>
>
>
>
>

This may help, but who knows.

Early days of computing.
Merging files.
Need something that will cause all data to pass as larger.

End of Idea.

Warren Simmons
Mike

2004-08-26, 3:55 pm

Come on you guys. All these excuses trying to find some reason that
nulls in a packed field can be used for something. Well, okay
I guess you can program around it and make it work. But this
is just grandstanding in my opinion: "Look, I can think up a way bad
data in a field can be used to mean something". BALONY. I still say
putting meaningful data in field where that data is invalid by the
definition of the field is bad programming. Low-values in a
packed-decimal field is a S0C7 waiting to happen. Set a flag or something.









William M. Klein

2004-08-26, 3:55 pm

Check the archives.

See long (and useless) discussion on dates, arithmetic's, and numeric
definitions.

BELIEVE ME, you don't want to revisit this!!!

--
Bill Klein
wmklein <at> ix.netcom.com
"Howard Brazee" <howard@brazee.net> wrote in message
news:cgfseq$1oe$1@peabody.colorado.edu...
>
> On 20-Aug-2004, Lowell Young <ittool@comcast.net> wrote:
>
>
> What kind of arithmetic would you use that date format in?



Lorne Sunley

2004-08-26, 3:55 pm

On Tue, 24 Aug 2004 18:58:05 UTC, tom <nobody@nomail.invalid> wrote:

> On Fri, 20 Aug 2004 23:59:41 GMT, "Lorne Sunley"
> <lsunley@mb.sympatico.ca> wrote:
>
> You can do it the way SQL doess it on Tandem. make the element a
> group-item, consissting of an indicator and a VALU.
> 03 STORE-ID.
> 05 INDICATOR PIC S9(01).
> 05 VALU PIC X(3).
>
> And if you want it to represent null, you move -1 to the indicator
> .
>


That's the way you do it with SQL using DB2 and most other SQL
database engines.

SQL Syntax is

Select
datafield null-indicator,
moredata more-null
from whatever

Unfortunately if you are not using a database engine, then you should
design your data storage to have null indicator fields for every data
item that can be NULL (not specified). Using low-values in a data
field is a hack that is usually done when you did not design the data
storage layout properly.



--
Lorne Sunley
Jack Sleight

2004-08-26, 3:55 pm

Hi RM,

Null data fields usually don't appear in COBOL code unless the field
is an address or a designated field in a DB2 table.

If it's packed it can't be an address. Could this field be a DB2 table
field?

Regards, Jack.




aaryam <member@mainframeforum.com> wrote in message news:<RbvUc.22870$kC6.13105@cyclops.nntpserver.com>...
> Hello:
>
> I need to move NULL or null value into a field in cobol.
>
> eg: I have a field called store-id PIC S99999V COMP-3. since I dont
> populate any value into it I need to move NULL into it. It shouldn't be
> zero. how do I do that in COBOL.
>
> please help
>
> RM

Robert Wagner

2004-08-26, 3:55 pm

On Tue, 24 Aug 2004 16:59:50 -0500, "Mike"
<NoMoreSpam@SpamStopper.Org> wrote:

>Come on you guys. All these excuses trying to find some reason that
>nulls in a packed field can be used for something. Well, okay
>I guess you can program around it and make it work. But this
>is just grandstanding in my opinion: "Look, I can think up a way bad
>data in a field can be used to mean something". BALONY. I still say
>putting meaningful data in field where that data is invalid by the
>definition of the field is bad programming. Low-values in a
>packed-decimal field is a S0C7 waiting to happen. Set a flag or something.


I concur. Strongly-typed languages do not allow this. Weakly-typed
languages, such as Cobol, rely on the programmer's good will and
cooperation. When the programmer deliberately violates that trust, he
or she is acting irresponsibly.

Telling the compiler a field is numeric and then deliberately writing
non-numeric values is self-contradiction.

If one must distinguish between zero and 'virgin', initialize numbers
to -9999999 and dates to '1600-01-01'.
Lorne Sunley

2004-08-26, 3:55 pm

On Fri, 20 Aug 2004 20:02:38 UTC, weberm@polaris.net (Ubiquitous)
wrote:

> JerryMouse <nospam@bisusa.com> wrote:
>
> : Sure. If zero is a permissable value, how do you distinguish a non-value? In
> : my view, a better way is a specific value way outside the value's range. For
> : example, sales-year-to-date for a new customer could be initialized
> : to -99999.99 or depth-of-well could be -100 (that is, there are 100 feet of
> : pipe sticking up in the air).
>
> In COBOL, is there really a need for NULL?
> I mean, it seems to me that initializing to zeros would suffice.
>


Not when it is a numeric field and you want to know if it has been
set. zero is a valid number and a zero in the field can be a valid
entry (depending on the application, of course)

--
Lorne Sunley
JerryMouse

2004-08-26, 3:55 pm

Ubiquitous wrote:
> JerryMouse <nospam@bisusa.com> wrote:
>
>
> In COBOL, is there really a need for NULL?
> I mean, it seems to me that initializing to zeros would suffice.


1. And where zero is a valid value? (HOURS-OVERTIME, QUAN-ON-HAND, etc.)

2. If there were no need for a NULL, LOW-VALUES would not be part of the
language construct (I know, I know: LOW-VALUES is but the smallest value in
the collating sequence).


Lorne Sunley

2004-08-27, 3:55 pm

On Fri, 20 Aug 2004 20:02:38 UTC, weberm@polaris.net (Ubiquitous)
wrote:

> JerryMouse <nospam@bisusa.com> wrote:
>
> : Sure. If zero is a permissable value, how do you distinguish a non-value? In
> : my view, a better way is a specific value way outside the value's range. For
> : example, sales-year-to-date for a new customer could be initialized
> : to -99999.99 or depth-of-well could be -100 (that is, there are 100 feet of
> : pipe sticking up in the air).
>
> In COBOL, is there really a need for NULL?
> I mean, it seems to me that initializing to zeros would suffice.
>


Not when it is a numeric field and you want to know if it has been
set. zero is a valid number and a zero in the field can be a valid
entry (depending on the application, of course)

--
Lorne Sunley
Jeff York

2004-08-29, 8:55 am

l.willms@jpberlin.de (Lueko Willms) wrote:

>. Am 21.08.04
>schrieb nospam@bisusa.com (JerryMouse)
> auf /COMP/LANG/COBOL
> in dYqdnZySoPl2QbrcRVn-rA@giganews.com
> ueber Re: how do I move NULL into a field ?
>
>n> I once invented write-only ROM (block of wood with two imbedded
>n> wires).
>
> That would be a WOM, not ROM.


Just the "storage" device to keep auditors happy.. They insist that
you keep everything, but never look at it. :-)

--
Jeff. Ironbridge, Shrops, U.K.
jjy@jakfield.xu-netx.com (remove the x..x round u-net for return address)
and don't bother with ralf4, it's a spamtrap and I never go there.. :)

.... "There are few hours in life more agreeable
than the hour dedicated to the ceremony
known as afternoon tea.."

Henry James, (1843 - 1916).


Mike

2004-08-31, 3:55 am

Come on you guys. All these excuses trying to find some reason that
nulls in a packed field can be used for something. Well, okay
I guess you can program around it and make it work. But this
is just grandstanding in my opinion: "Look, I can think up a way bad
data in a field can be used to mean something". BALONY. I still say
putting meaningful data in field where that data is invalid by the
definition of the field is bad programming. Low-values in a
packed-decimal field is a S0C7 waiting to happen. Set a flag or something.









Howard Brazee

2004-08-31, 3:55 pm


On 20-Aug-2004, Lowell Young <ittool@comcast.net> wrote:
[color=darkred]
> However, a date in ddmmyyyy can be used in arithmetic.
>

What kind of arithmetic would you use that date format in?
Howard Brazee

2004-08-31, 3:55 pm


On 20-Aug-2004, "Lorne Sunley" <lsunley@mb.sympatico.ca> wrote:

>
> Not when it is a numeric field and you want to know if it has been
> set. zero is a valid number and a zero in the field can be a valid
> entry (depending on the application, of course)


But the question remains - how are you using this null field? Some program
must read this field and determine it is null. As with any programming
problem, we should determine how a field is used before determining how to
create it.
tom

2004-08-31, 3:55 pm

On Fri, 20 Aug 2004 23:59:41 GMT, "Lorne Sunley"
<lsunley@mb.sympatico.ca> wrote:

>On Fri, 20 Aug 2004 20:02:38 UTC, weberm@polaris.net (Ubiquitous)
>wrote:
>
>
>Not when it is a numeric field and you want to know if it has been
>set. zero is a valid number and a zero in the field can be a valid
>entry (depending on the application, of course)

You can do it the way SQL doess it on Tandem. make the element a
group-item, consissting of an indicator and a VALU.
03 STORE-ID.
05 INDICATOR PIC S9(01).
05 VALU PIC X(3).

And if you want it to represent null, you move -1 to the indicator
..

Lorne Sunley

2004-08-31, 3:55 pm

On Tue, 24 Aug 2004 18:58:05 UTC, tom <nobody@nomail.invalid> wrote:

> On Fri, 20 Aug 2004 23:59:41 GMT, "Lorne Sunley"
> <lsunley@mb.sympatico.ca> wrote:
>
> You can do it the way SQL doess it on Tandem. make the element a
> group-item, consissting of an indicator and a VALU.
> 03 STORE-ID.
> 05 INDICATOR PIC S9(01).
> 05 VALU PIC X(3).
>
> And if you want it to represent null, you move -1 to the indicator
> .
>


That's the way you do it with SQL using DB2 and most other SQL
database engines.

SQL Syntax is

Select
datafield null-indicator,
moredata more-null
from whatever

Unfortunately if you are not using a database engine, then you should
design your data storage to have null indicator fields for every data
item that can be NULL (not specified). Using low-values in a data
field is a hack that is usually done when you did not design the data
storage layout properly.



--
Lorne Sunley
William M. Klein

2004-09-01, 3:55 am

Check the archives.

See long (and useless) discussion on dates, arithmetic's, and numeric
definitions.

BELIEVE ME, you don't want to revisit this!!!

--
Bill Klein
wmklein <at> ix.netcom.com
"Howard Brazee" <howard@brazee.net> wrote in message
news:cgfseq$1oe$1@peabody.colorado.edu...
>
> On 20-Aug-2004, Lowell Young <ittool@comcast.net> wrote:
>
>
> What kind of arithmetic would you use that date format in?



Robert Wagner

2004-09-01, 3:55 am

On Tue, 24 Aug 2004 16:59:50 -0500, "Mike"
<NoMoreSpam@SpamStopper.Org> wrote:

>Come on you guys. All these excuses trying to find some reason that
>nulls in a packed field can be used for something. Well, okay
>I guess you can program around it and make it work. But this
>is just grandstanding in my opinion: "Look, I can think up a way bad
>data in a field can be used to mean something". BALONY. I still say
>putting meaningful data in field where that data is invalid by the
>definition of the field is bad programming. Low-values in a
>packed-decimal field is a S0C7 waiting to happen. Set a flag or something.


I concur. Strongly-typed languages do not allow this. Weakly-typed
languages, such as Cobol, rely on the programmer's good will and
cooperation. When the programmer deliberately violates that trust, he
or she is acting irresponsibly.

Telling the compiler a field is numeric and then deliberately writing
non-numeric values is self-contradiction.

If one must distinguish between zero and 'virgin', initialize numbers
to -9999999 and dates to '1600-01-01'.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com