Page 1 of 1

Move DB2 VarChar into XML layout

PostPosted: Sat Jun 15, 2013 1:29 am
by dlangmeyer
I have a field from DB2 VarChar (500).
Have the definition with the level 49 fields, but don't know the proper definition for the XML layout
I am using the COBOL GENERATE command to create the XML output.
If I define the field in the XML layout as 500, but actual length is only 100, will the full 500 bytes be between the XML tags?
Do I have to define the XML fields as as table of 1 byte occuring 1 to 500 times depending on DB-FIELD-LEN?

Assuming the code would look something like the following:

05 DB-FIELD
49 DB-FIELD-LEN PIC S9(4) COMP
49 DB-FIELD-DATA PIC X(500)

01 XML-AREA.
05 DB2-varchar-field PIC X(???)

MOVE DB-FIELD-DATA(1:DB-FIELD-LEN) TO DB2-varchar-field.

Re: Move DB2 VarChar into XML layout

PostPosted: Sat Jun 15, 2013 2:09 am
by Robert Sample
There is a link to IBM Manuals at the top right of this page. You would be wise to click on it, find the COBOL Language Reference manual, and read up on the XML GENERATE statement. If you do so, you will find that the manual explicitly tells you that leading and trailing spaces are removed during XML GENERATE. Furthermore, the manual also says things about variables with OCCURS in the XML GENERATE statement, but I'll let you do the reading for that. You will also want to read the Programming Guide manual to find out more about XML GENERATE statements in COBOL.

Re: Move DB2 VarChar into XML layout

PostPosted: Sat Jun 15, 2013 3:39 am
by BillyBoyo
The same manual will also tell you how to find the length of the XML data.

Re: Move DB2 VarChar into XML layout

PostPosted: Mon Jun 17, 2013 9:30 pm
by dlangmeyer
Thanks to everyone -