How to handle Null value in COBOL/400.

100 pts.
Tags:
COBOL
COBOL Programs
COBOL/400
COBOL/400 Errors
I have created a view that have Null value.I have populated this field on the basis of some conditions.But when i am reading this view in COBOL program it is going in infinite loop & reading the same record.

ASKED: May 9, 2011  5:49 AM
UPDATED: May 12, 2011  10:40 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 8  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • CharlieBrowne
    Can you post the code. If you are just doing a read, it should not make any difference if a value is null. If you are reading an LF and updating, then there is more of a possibility to keep on reading the same record.
    39,815 pointsBadges:
    report
  • TomLiotta
    Also, can you clarify if this is COBOL/400 (OPM) or ILE COBOL? The program code might be the same, but the compiled behaviors may be slightly different. Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    The SQL Programming with Host Languages manual has examples for COBOL coding. As with RPG, null columns will supply a "null indicator" that you need to test before using a variable that has a null value. An example might be like the following. Given the statement:
    EXEC SQL FETCH CLS_CURSOR INTO :CLS-CD,
                                   :NUMDAY :NUMDAY-IND,
                                   :BGN :BGN-IND,
                                   :ENDCLS :ENDCLS-IND
    END-EXEC.
    The variables can be declared as follows:
    EXEC SQL BEGIN DECLARE SECTION END-EXEC.
    77 CLS-CD     PIC X(7).
    77 NUMDAY     PIC S9(4) BINARY.
    77 BGN        PIC X(8).
    77 ENDCLS     PIC X(8).
    77 NUMDAY-IND PIC S9(4) BINARY.
    77 BGN-IND    PIC S9(4) BINARY.
    77 ENDCLS-IND PIC S9(4) BINARY.
    EXEC SQL END DECLARE SECTION END-EXEC.
    Is that what you're looking for? Tom
    125,585 pointsBadges:
    report
  • Rr22
    Thanks for the reply.It is in COBOL/400.I am not using the null values in our program.It is present in View.When i am reading the view,it is reading same record due to Null value & giving 46 error code.
    100 pointsBadges:
    report
  • TomLiotta
    If your tables have null-capable columns and any of those columns have null values, your program must use null-indicators in order to fetch those rows successfully. Tom
    125,585 pointsBadges:
    report
  • MDratwa
    Flat files (unkeyed) can not contain nulls (null capable fields). You must use keyed PF or keyed LF: Null key map is used when any of the key fields are null capable. Null map is used when any of the fields (key or not) are null capable. In the null map or null key map fields will contain a B'1' or B'0' ('0' = not null, '1' = null). Before any updating (write/rewrite), if you change a null to a value other than null, the corr null map field (and/or null key map) for that field needs to be changed from B'1' to B'0'. The source must be changed from "CBL" to "CBLLE". SELECT IOF-GIS ASSIGN DATABASE-XXXLFA40W-ALWNULL ORGANIZATION INDEXED ACCESS DYNAMIC RECORD KEY EXTERNALLY-DESCRIBED-KEY WITH DUPLICATES FILE STATUS WS-FILE-STATUS. Working Storage Section. 01 WS-NULL-FILE-AREA. COPY DDS-ALL-FORMATS OF XXXLFA40W WITH NULL-MAP WITH NULL-KEY-MAP. Procedure Division. READ IOF-GIS NULL-KEY-MAP IS SOMPFA40W-NKM NULL-MAP IS SOMPFA40W-NM INVALID KEY (or next record) go to xxxx END-READ.
    785 pointsBadges:
    report
  • TomLiotta
    Flat files (unkeyed) can not contain nulls (null capable fields). You must use keyed PF or keyed LF: Flat files do not equate with 'unkeyed'. Unkeyed files are not necessarily 'flat files' even though flat files will be unkeyed. Further, null-capable columns can exist in unkeyed files. I have a number of them. However, thanks for pointing out that this might not be a SQL issue. It hasn't actually been stated if the COBOL is using SQL or native I/O to process the file. The way that the term "view" was used in the question put me into thinking that SQL was the focus. Your native I/O example could be the right direction. Tom
    125,585 pointsBadges:
    report
  • Rr22
    [...] A member wondering how to handle null value in COBOL/400 is getting some help from TomLiotta, CharlieBrowne, and MDratwa. Jump in with your own expertise! [...]
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following