Skip to main content

Hello VC Forum,

in my current project we have to generate JSON from from a COBOL structure which looks like

01 jsonStructure. 05 array1Count pic 9. 05 array2Count pic 9. 05 array1 occurs 1 to 5 depending on array1Count. 05 array2 occurs 1 to 5 depending on array2count. 10 subarrayCount pic 9. 10 subarray occurs 1 to 5 depending on subarrayCount.

Unfortunately VC compiler produce on the part "subarray" an error:

  1. without ODOSLIDE directive: COBCH0144S OCCURS DEPENDING subsidiary to OCCURS only allowed with ODOSLIDE
  2. with ODOSLIDE directive: COBCH0245S DEPENDING ON item subarrayCount missing or illegal.

It is maybe possible, to use fix occurs structures, but then we get problems with the called service because of empty elements generated by JSON GENERATE.

Does someone have the same problem? Is there any possibility to use dynamic occurs structures with JSON GENERATE or to avoid the generation of empty elements by fix occurs?

Thanks

Andreas


#JSONGENERATE
#OCCURS

Hello VC Forum,

in my current project we have to generate JSON from from a COBOL structure which looks like

01 jsonStructure. 05 array1Count pic 9. 05 array2Count pic 9. 05 array1 occurs 1 to 5 depending on array1Count. 05 array2 occurs 1 to 5 depending on array2count. 10 subarrayCount pic 9. 10 subarray occurs 1 to 5 depending on subarrayCount.

Unfortunately VC compiler produce on the part "subarray" an error:

  1. without ODOSLIDE directive: COBCH0144S OCCURS DEPENDING subsidiary to OCCURS only allowed with ODOSLIDE
  2. with ODOSLIDE directive: COBCH0245S DEPENDING ON item subarrayCount missing or illegal.

It is maybe possible, to use fix occurs structures, but then we get problems with the called service because of empty elements generated by JSON GENERATE.

Does someone have the same problem? Is there any possibility to use dynamic occurs structures with JSON GENERATE or to avoid the generation of empty elements by fix occurs?

Thanks

Andreas


#JSONGENERATE
#OCCURS

Unfortunately that structure does not work, as the OCCURS DEPENDING ON item needs to be in a fixed location, and also needs to be a non-OCCURing item.

I'm not an expert on JSON GENERATE, so I'm afraid I can't suggest an alternative way of coding this.