Page 1 of 1

String manipulation

PostPosted: Fri Nov 12, 2010 8:56 pm
by GZiden
Hello there. The final task i need to do, is to generate a XML report in cobol and save into a longvarchar at a DB2. The way ive set up this xml was fillin a vector, for example:

Vect(1) = '<Person>'
vect(2) = '<name> John </name>'
vect(3) = '</Person>'

Heres how i declare the vector:

 01  W-VETOR.
           05 W-VETOR-LENGTH PIC S9(9) COMP-5.
           05      W-VETOR-LINHAS  OCCURS 5000 TIMES.
             10    W-V-LINHA          PIC X(200) VALUE SPACES.


Now, the thing is... when i save this vector with 3 lines i gave as example at the DB, it will come as
<person> (+200 characters spaces) <name> John </name> (+200 character spaces)

the problem is that, the reports are very large, so i would need to concat all strings together w/ no blank spaces. The first way ive tought to make this, is , instead inserting each xml type onto a vector line, making many characters free, make it filled till a characters count reach 200 then jump to the next line, making it filled correctly, but i have no actual idea on how i could do this. Ive searched for some methods to check the lenght of a string, but i couldnt get a working one. Is there any tips i can perform this ?

Thanx for any attention .

[]´s Gabriel

Re: String manipulation

PostPosted: Fri Nov 12, 2010 9:02 pm
by Robert Sample
You're not using the XML GENERATE statement in COBOL?

Why not define your XML data variable as X(1000000) and use STRING or reference modification to fill it in -- if XML GENERATE won't give you what you want?