SET NULL TO NON DB2 VARIABLE



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

SET NULL TO NON DB2 VARIABLE

Postby hariharan_bk » Tue Jan 31, 2017 10:43 pm

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.
Many Thanks,
Harry
hariharan_bk
 
Posts: 70
Joined: Thu Mar 29, 2012 11:13 am
Has thanked: 5 times
Been thanked: 0 time

Re: SET NULL TO NON DB2 VARIABLE

 

Re: SET NULL TO NON DB2 VARIABLE

Postby Akatsukami » Tue Jan 31, 2017 10:56 pm

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.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: SET NULL TO NON DB2 VARIABLE

Postby hariharan_bk » Tue Jan 31, 2017 11:02 pm

Okay. I am trying to move a value X'00' to that variable. I am in the process of generating the JSON.
Many Thanks,
Harry
hariharan_bk
 
Posts: 70
Joined: Thu Mar 29, 2012 11:13 am
Has thanked: 5 times
Been thanked: 0 time

Re: SET NULL TO NON DB2 VARIABLE

Postby hariharan_bk » Wed Feb 01, 2017 12:33 am

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.
Many Thanks,
Harry
hariharan_bk
 
Posts: 70
Joined: Thu Mar 29, 2012 11:13 am
Has thanked: 5 times
Been thanked: 0 time

Re: SET NULL TO NON DB2 VARIABLE

Postby Robert Sample » Wed Feb 01, 2017 12:35 am

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.
Robert Sample
Global moderator
 
Posts: 3624
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 267 times

Re: SET NULL TO NON DB2 VARIABLE

Postby hariharan_bk » Wed Feb 01, 2017 12:50 am

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.
Many Thanks,
Harry
hariharan_bk
 
Posts: 70
Joined: Thu Mar 29, 2012 11:13 am
Has thanked: 5 times
Been thanked: 0 time

Re: SET NULL TO NON DB2 VARIABLE

Postby Akatsukami » Wed Feb 01, 2017 1:00 am

The "\u0000" is Unicode encoding for a null in a Java-like syntax. Mainframe COBOL would not generate this.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post