Erga Kandly
Erga Kandly

Reputation: 799

COBOL XML Generate : sub variable value is enter

I have a case about XML Generate function on COBOL. My copybook right now :

01 ABC.
   02 a  PIC X(02) VALUE SPACES.
   02 b  PIC X(02) VALUE SPACES.
   02 c  PIC X(02) VALUE SPACES.

result :

<ABC><a>aa</a><b>bb</b><c>cc</c></ABC>

But I have max lenth of the output is only ZZ characters. Thus, I guess I have to insert an "enter" character in there with expectation result :

<ABC><a>aa</a><b>bb</b>
<c>cc</c></ABC>

So I tried to edit the copybook to be like this :

01 ABC.
   02 a  PIC X(02) VALUE SPACES.
   02 b  PIC X(02) VALUE SPACES.
   02 FILLER  PIC X VALUE IS X'7D'.
   02 c  PIC X(02) VALUE SPACES.

but it doesn't worked. Any suggestion about this case?

Thanks a lot

Upvotes: 0

Views: 168

Answers (1)

Simon Sobisch
Simon Sobisch

Reputation: 7297

XML GENERATE is a now common extension to the COBOL standard. It only specifies the output format to be XML with a defined set of rules which data items to include in which way and format. It gives no guarantee of the the "print format" and specifies that you need the target to be big enough (sometimes 5 times as big as the COBOL data) to not get en exception.

It could even be that some version of a given implementation outputs a "pretty-print" (many spaces between the elements) and another doesn't.

Therefore you may do the following:

  • use a big enough target field
  • afterwards split the target field to the requested size via PERFORM.

More information on XML GENERATE may be found in the IBM Documentation, Micro Focus docs and ACUCOBOL-GT docs.

Upvotes: 1

Related Questions