Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Query on cobol string variable manipulation .

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Query on cobol string variable manipulation .
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: 3158
Location: Tucson AZ

PostPosted: Tue Aug 14, 2007 2:38 pm    Post subject:
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    Post subject: Re: Query on cobol string variable manipulation .
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: 686
Location: Earth

PostPosted: Tue Aug 14, 2007 3:05 pm    Post subject:
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    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Tue Aug 14, 2007 3:52 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us