IBM Support

JSON Transform results in invalid values in CICS COBOL Sercvice Provider

Question & Answer


Question

The Transform of a JSON Request message containing DISP-NUM, COMP, and COMP-3 COBOL fields with a length > 2 and values with leading zeros that are NOT in quotes results in erroneous values.

For example:

 {"CTCService5Operation":
   {"ZCONReqData":
     {"CTC5Q":
      {"CTC_REQUEST":
         {"CTC_ID":"999998",
          "CTC_TOWN":"Mytown",
          "CTC_STATE":"NH",
          "CTC_RED_CNT_IN":"03",
          "CTC_BLUE_CNT_IN":"04", 
 
          "CTC_NUM2":02,
          "CTC_NUM3":023,
          "CTC_NUM4":0234,
          "CTC_COMPB":02,
          "CTC_COMPC":023,
          "CTC_COMPD":0234,
       "CTC_COMP3B":02,
       "CTC_COMP3C":023,
       "CTC_COMP3D":0234,
        }       
  }}}}

results in the following COBOL values:

 LV ---- COBOL DATANAME KEEPS ----,-- ATTRIBUTES --,----+---10----
 03 CTC-NUM2                      ,9(2) NUM-DIS    ,02
 03 CTC-NUM3                      ,9(3) NUM-DIS    ,019
 03 CTC-NUM4                      ,9(4) NUM-DIS    ,0156
 03 CTC-COMPB                     ,9(2) COMP       ,0002
 03 CTC-COMPC                     ,9(3) COMP       ,0019
 03 CTC-COMPD                     ,9(4) COMP       ,0156
 03 CTC-COMP3B                    ,9(2) COMP-3     ,002
 03 CTC-COMP3C                    ,9(3) COMP-3     ,019
 03 CTC-COMP3D                    ,9(4) COMP-3     ,00156
 03 CTC-NUM2                      ,9(2) NUM-DIS    ,02

As you can see value 023 for JSON field "CTC-NUM3" becomes 019 in the matching COBOL field. Other fields are also not transformed correctly. I was expecting to have the same value in the COBOL fields. Why are there values different?

Answer

The use of the leading zero '0' in DISP-NUM, COMP, and COMP-3 fields with a length greater than 2 causes the JSON parser to convert the value as an octal value rather than decimal. As such, the values being seen in the COBOL application are correct when using octal.

For example, for JSON Request field:

"CTC_NUM4":0234,

JSON treats that as an octal value 0234 and it is translated to decimal in the COBOL field becoming 0156:

03 CTC-NUM4 ,9(4) NUM-DIS ,0156

This is a valid transformation and not a problem.

Chris Carlin
IBM zCEE Level2 Support

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSNPJM","label":"IBM z\/OS Connect"},"Platform":[{"code":"PF035","label":"z\/OS"}],"Component":"","Version":"","Line of Business":{"code":"LOB35","label":"Mainframe SW"}}]

Product Synonym

zCEE

Document Information

Modified date:
14 February 2023

UID

dwa1479828