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
 

 

Checking for a null value in cobol

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

New User


Joined: 14 Aug 2007
Posts: 35
Location: Hyderabad

PostPosted: Thu Jun 12, 2008 7:38 pm    Post subject: Checking for a null value in cobol
Reply with quote

Hi all,

I have a feild[9(2)] in an i/p file which is null means an invalid feild for certain number of records in the file.

When I am directly moving it to the feild[S 9(4) COMP] in the O/P file,its populating as 0 instead of blank(as in the I/P).

But I want the O/P as same as I/P because it has to be stored in a table as null value instead of 0.

Moreover I also need to check the feild if it is not null,so that I can count the number of records having not null values for the particular feild.

Please suggest me what to do?
Back to top
View user's profile Send private message

srj1957

New User


Joined: 15 Dec 2005
Posts: 72
Location: RALEIGH NC, USA

PostPosted: Thu Jun 12, 2008 9:21 pm    Post subject: Re: Checking for a null value in cobol
Reply with quote

bibek24 wrote:
Hi all,

I have a feild[9(2)] in an i/p file which is null means an invalid feild for certain number of records in the file.

When I am directly moving it to the feild[S 9(4) COMP] in the O/P file,its populating as 0 instead of blank(as in the I/P).

But I want the O/P as same as I/P because it has to be stored in a table as null value instead of 0.

Moreover I also need to check the feild if it is not null,so that I can count the number of records having not null values for the particular feild.

Please suggest me what to do?


We usually code
Code:
IF WS-FIELD = LOW-VALUES




LET ME KNOW IF IT WORKS
Back to top
View user's profile Send private message
srj1957

New User


Joined: 15 Dec 2005
Posts: 72
Location: RALEIGH NC, USA

PostPosted: Thu Jun 12, 2008 9:40 pm    Post subject: Re: Checking for a null value in cobol
Reply with quote

bibek24 wrote:
Hi all,

I have a feild[9(2)] in an i/p file which is null means an invalid feild for certain number of records in the file.

When I am directly moving it to the feild[S 9(4) COMP] in the O/P file,its populating as 0 instead of blank(as in the I/P).

But I want the O/P as same as I/P because it has to be stored in a table as null value instead of 0.

Moreover I also need to check the feild if it is not null,so that I can count the number of records having not null values for the particular feild.

Please suggest me what to do?


To check for NULLS we usually code

Code:
IF WS-FIELD = LOW-VALUES


To check for NOT NULL we usually code

Code:
IF WS-FIELD > LOW-VALUES



LET ME KNOW IF IT WORKS
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Thu Jun 12, 2008 9:45 pm    Post subject: Reply to: Checking for a null value in cobol
Reply with quote

there is no NULL value in se...
nullness is a convention....
every bit configuration is a valid configuration without any implied meaning

a NULL value is any bit configuration defined as such by the application specifications...

somebody uses low values, but that' s not mandatory
for example if a field is unsigned binary numeric, a negative value might b use to indicate a NULL/invalid value

so the answer is ... check the appliaction data description specifications
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: Thu Jun 12, 2008 9:47 pm    Post subject: Re: Checking for a null value in cobol
Reply with quote

If the field is display-numeric, you can test it for X'00's using reference modification -
Code:

03  WS-FIELD PIC  9(02).
*
IF  WS-FIELD (1:) = LOW-VALUES

You're correct in testing a binary-field for ZERO (same as LOW-VALUES), but if you have a packed-decimal field, you need to redefine it as alphanumeric (PIC X), then you can test it for LOW-VALUES.

Note that depending on the field, there's also this wonderful "NULL" value that IBM uses in POINTER fields which is X'FF000000', so keep this in mind if at one time a binary-fullword had been a POINTER.

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

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jun 12, 2008 9:47 pm    Post subject:
Reply with quote

Hello,

NULL VALUE is a databse term/concept.

A qsam input file cannot have the "database NULL" in it. The qsam file will have values in each byte between x'00' and x'FF' - none of which is null.

The spaces you see are probably unprintable characters (maybe x'00's).
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Fri Jun 13, 2008 3:30 pm    Post subject:
Reply with quote

Quote:
But I want the O/P as same as I/P because it has to be stored in a table as null value instead of 0

In order to store the data as NULL in the table, why dont you use the NULL INDICATORs? passing the value -1 to the NULL INDICATOR before inserting it to the table will insert the field as NULL in the table....
Back to top
View user's profile Send private message
birdy K

New User


Joined: 05 Mar 2008
Posts: 72
Location: chennai

PostPosted: Fri Jun 13, 2008 4:09 pm    Post subject:
Reply with quote

Check for the low-values or invalid fields. For invalid fields, move -1 to host variable and insert it.
Back to top
View user's profile Send private message
bibek24

New User


Joined: 14 Aug 2007
Posts: 35
Location: Hyderabad

PostPosted: Fri Jun 13, 2008 4:22 pm    Post subject:
Reply with quote

checking for low-values,<0 etc are not working.
I am not using null indicator because the table has to be loaded with a load file through a load utility.

anywys let the fields come as 0 to the load file(O/P) .Is there any way to load the table field as null wherever there is 0 for the field in the load file.
I mean whenever the load utility will find a 0 in the load file for the particular field ,the corresponding field in the table should be null.

Any suggestions?
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Fri Jun 13, 2008 4:29 pm    Post subject: Reply to: Checking for a null value in cobol
Reply with quote

use the NULLIF construct of the load utility

something like ( logic, the syntax might be wrong)
Code:
field_name  POSITION(field_position ) field_type
NULLIF (field_to_be_checked_coordinates)=condition_to_be_checked 


but it would be better to read the load utility documentation
Back to top
View user's profile Send private message
bibek24

New User


Joined: 14 Aug 2007
Posts: 35
Location: Hyderabad

PostPosted: Fri Jun 13, 2008 5:14 pm    Post subject:
Reply with quote

hi all,

I tried for the following and got the result

exp - FIELD1 POSITION (655) SMALLINT
NULLIF (35:36)=X'0000' ,

But I didn't meet my 1st requirement,moving a null value from a input field to its corresponding O/P field.
Its always coming as 0.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jun 13, 2008 5:28 pm    Post subject:
Reply with quote

In DB2 a column which is defined as nullable and has the null indicator set to -1 does not have any value, there is no such thing as a null value in DB2. If the column is defined as char you can put hex'00' in the column but that does not make it null.
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 Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm


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