IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Query on cobol string variable manipulation .


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Saroj Tripathy

New User


Joined: 05 Mar 2007
Posts: 23
Location: India

PostPosted: Tue Aug 14, 2007 2:15 pm
Reply with quote

My requiremnt is like this I have a string of say 5000 chars length.
the data it has is like below

[fgtyihcbc<doc>iiiiiiggggggg</doc>iiiiiiii<doc>iiiiitttttffffffffffffff</doc>kkk]

I want to replace all chars present outside <doc> and </doc> with spaces.

what should be my approch ??? icon_rolleyes.gif
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Aug 14, 2007 2:38 pm
Reply with quote

I had the same problem.
I used a perform loop with reference modification to squeeze in place the junk out.
Back to top
View user's profile Send private message
Saroj Tripathy

New User


Joined: 05 Mar 2007
Posts: 23
Location: India

PostPosted: Tue Aug 14, 2007 2:54 pm
Reply with quote

The problem is the <doc> and </doc> may appear anywhere in the string. so i dont think i can use reference modification.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Tue Aug 14, 2007 3:05 pm
Reply with quote

Nested tags possible? I mean
<doc>hhh <doc> hhhhh </doc> hhh</doc> icon_question.gif
IF NOT
You can simply replace data between </doc> and <doc> and it is possible with reference modification.
Back to top
View user's profile Send private message
Saroj Tripathy

New User


Joined: 05 Mar 2007
Posts: 23
Location: India

PostPosted: Tue Aug 14, 2007 3:10 pm
Reply with quote

No nested tags are not possible.

Can you please provide the syntax of how to replace data between </doc> and <doc> using reference modification.

thanks...
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Aug 14, 2007 3:52 pm
Reply with quote

Saroj Tripathy wrote:
Can you please provide the syntax of how to replace data between </doc> and <doc> using reference modification.
Replace or squeeze out?
Replace with what?
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Tue Aug 14, 2007 4:02 pm
Reply with quote

Code:
SET WF-START-POSITION-NOT FOUND TO TRUE
SET WF-END-POSITION-NOT-FOUND TO TRUE
PERFORM VARYING I FROM 1 BY 1 UNTIL I = LENGTH OF WS-STRING
     IF WS-STRING(I:5) = '<DOC>'
         SET WF-START-POSITION-FOUND TO TRUE
         MOVE I TO WS-START-POSITION
         COMPUTE I = I + 5
     END-IF
     IF WS-STRING(I:6) = '</DOC>
        SET WF-END-POSITION-FOUND TO TRUE
        COMPUTE I = I + 5
        MOVE I TO WS-END-POSITION
     END-IF
     IF WF-START-POSITION-FOUND AND WF-END-POSITION-FOUND
         MOVE WS-STRING(WS-START-POSITION:WS-END-POSITION) TO
         WS-FINAL-STRING
         SET WF-START-POSITION-NOT FOUND TO TRUE
         SET WF-END-POSITION-NOT-FOUND TO TRUE
         COMPUTE I = I + 1
     END-IF
END-PERFORM
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Aug 14, 2007 4:08 pm
Reply with quote

shankar.v

you code would work if he only has one pair of <doc></doc>, and you used the lower case for doc. XML standards dictate lowercase, not uppercase.
Back to top
View user's profile Send private message
Saroj Tripathy

New User


Joined: 05 Mar 2007
Posts: 23
Location: India

PostPosted: Tue Aug 14, 2007 4:37 pm
Reply with quote

thanks Shankar.

your code looks cool . icon_lol.gif

to all the members who contributed, thanks for helping me out.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
Search our Forums:

Back to Top