Page 1 of 1

SET NULL TO NON DB2 VARIABLE

PostPosted: Tue Jan 31, 2017 10:43 pm
by hariharan_bk
Hi ALL,

There is a requirement to send data from Mainframe to Server using JSON.

We have built a JSON data from mainframe and it looks like this - "m_last2_nm": "", but it has to look like this -"m_last2_nm": null,

Instead of "", we need to have null there.

COBOL declaration is -

05 X-LAST1-NM-LEN             PIC S9999  COMP-5 SYNC.  
05 X-LAST1-NM                 PIC N(100) USAGE NATIONAL.
 


I am not sure how to initialize a non-DB2 variable as NULL in mainframe. If Host variable, we can have indicator fields, and using that we can set it to -1.

But for non-DB2 variable, I am unable to get this value set as NULL. Not sure if that is really possible... Please forgive me if this is a naive question.

Re: SET NULL TO NON DB2 VARIABLE

PostPosted: Tue Jan 31, 2017 10:56 pm
by Akatsukami
You have to understand that you are confusing two levels of abstraction here.

A DB2 null is instantiated with a separate indicator variable; an EBCDIC (or ASCII) NUL could very well be a perfectly valid value for that column.

As you are sending data to a toy computer, you will likely want an ASCII NUL in that byte. In COBOL that is termed LOW-VALUES.

Re: SET NULL TO NON DB2 VARIABLE

PostPosted: Tue Jan 31, 2017 11:02 pm
by hariharan_bk
Okay. I am trying to move a value X'00' to that variable. I am in the process of generating the JSON.

Re: SET NULL TO NON DB2 VARIABLE

PostPosted: Wed Feb 01, 2017 12:33 am
by hariharan_bk
I tried to move X'00' (also tried NX'0000') to the national variable and verified the same in JSON.... I was expecting to get null but got \u0000..

Not sure how to get null in the JSON field and what is needed to pass in the mainframe variable.

Re: SET NULL TO NON DB2 VARIABLE

PostPosted: Wed Feb 01, 2017 12:35 am
by Robert Sample
Are you wanting the word "null" in the field? If so, just define it as X(04) and move it when appropriate. If you want something else you will need to explain more what you want.

Remember that NULL in DB2 is an indicator and not a particular value -- it ALWAYS requires another variable to indicates when the original variable is NULL; the original variable value is irrelevant when the indicator variable indicates NULL.

Re: SET NULL TO NON DB2 VARIABLE

PostPosted: Wed Feb 01, 2017 12:50 am
by hariharan_bk
Yeah I understand the point which you are trying to convey related to NULL, in mainframe. In Java, they have NULL as their data type and is different from empty string.

We require the JSON element to look like this - "m_last2_nm": null.... But it is generated like this -
"m_last2_nm": "",
"m_last2_nm": "null",
"m_last2_nm": \u0000,


I wanted just null and not "null"
Any value other than actual null (like "null", "", \u0000 ), when sent to java server though CICS webservice, it throws INTERNAL SERVER ERROR. so no clue to proceed further and we are stuck there.

Re: SET NULL TO NON DB2 VARIABLE

PostPosted: Wed Feb 01, 2017 1:00 am
by Akatsukami
The "\u0000" is Unicode encoding for a null in a Java-like syntax. Mainframe COBOL would not generate this.