Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 6968
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 Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us