String manipulation

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

String manipulation

Postby GZiden » Fri Nov 12, 2010 8:56 pm

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
Posts: 1
Joined: Fri Nov 12, 2010 8:47 pm
Has thanked: 0 time
Been thanked: 0 time

Re: String manipulation

Postby Robert Sample » Fri Nov 12, 2010 9:02 pm

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?
Robert Sample
Global moderator
Posts: 3686
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 274 times

Return to IBM Cobol


  • Related topics
    Last post