Move DB2 VarChar into XML layout



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

Move DB2 VarChar into XML layout

Postby dlangmeyer » Sat Jun 15, 2013 1:29 am

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.
dlangmeyer
 
Posts: 10
Joined: Thu Sep 27, 2012 9:01 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Move DB2 VarChar into XML layout

 

Re: Move DB2 VarChar into XML layout

Postby Robert Sample » Sat Jun 15, 2013 2:09 am

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

Re: Move DB2 VarChar into XML layout

Postby BillyBoyo » Sat Jun 15, 2013 3:39 am

The same manual will also tell you how to find the length of the XML data.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Move DB2 VarChar into XML layout

Postby dlangmeyer » Mon Jun 17, 2013 9:30 pm

Thanks to everyone -
dlangmeyer
 
Posts: 10
Joined: Thu Sep 27, 2012 9:01 pm
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post