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
 

 

Unstring in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
vardhan0007

New User


Joined: 05 Jun 2006
Posts: 51
Location: Bangalore,India

PostPosted: Mon May 04, 2009 3:39 pm    Post subject: Unstring in cobol
Reply with quote

A String coming from the Input file is in XML format with tags.

I want specific tags which are placed at different positions in different records in the Input File.

eg: ::TAG1=AAAA :TAG2=11233281531219:TAG3=888888 :TAG4=AAAA
and there are many more tags in the record.

I need tag1,tag2 and tag3 from the file for processing.
Again when it comes to the next record these tags may vary their position.

How to Retrieve these tags from all Records using Unstring or any other Cobol facilities.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Mon May 04, 2009 5:09 pm    Post subject:
Reply with quote

Is this before or after using XML PARSE?
Back to top
View user's profile Send private message
vardhan0007

New User


Joined: 05 Jun 2006
Posts: 51
Location: Bangalore,India

PostPosted: Mon May 04, 2009 5:28 pm    Post subject:
Reply with quote

we will get the tags in the input files. I am reading the input file sequentially. And should format the input record.

We are not parsing using XML. The program is a pure DB2 cobol program
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Mon May 04, 2009 6:07 pm    Post subject:
Reply with quote

Quote:
We are not parsing using XML. The program is a pure DB2 cobol program
Good, only use a pure COBOL Parse.......
Back to top
View user's profile Send private message
vardhan0007

New User


Joined: 05 Jun 2006
Posts: 51
Location: Bangalore,India

PostPosted: Mon May 04, 2009 7:16 pm    Post subject:
Reply with quote

Thanks we ll use only cobol.
Quote:
Good, only use a pure COBOL Parse
.......and ll come up soon with the code which will parse only using Perform Until's..okay
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Mon May 04, 2009 7:32 pm    Post subject:
Reply with quote

If the tags were XML formatted, you could use the COBOL verb XML PARSE to split it out. You may have to use reference modification to split out the fields. based on what you've shown so far.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Mon May 04, 2009 8:47 pm    Post subject:
Reply with quote

Something like:
Code:
:TAG1=AAAA :TAG2=11233281531219:TAG3=888888 :TAG4=AAAA
Unstring input delimited by ':TAG1=' or ':TAG2=' or ':TAG3='
   into tagdata(1) delimiter in tagdelimiter(1)
        tagdata(2) delimiter in tagdelimiter(2)
        tagdata(3) delimiter in tagdelimiter(3)
end-unstring
Perform varing count from 1 by 1 until count = 3
   Evaluate tagdelimiter(1)
      when ':TAG1='
         unstring tagdata(1) delimited by ':'
            into tag1
         end-string
      when ':TAG2='
         unstring tagdata(1) delimited by ':'
            into tag2
         end-string
      when ':TAG3='
         unstring tagdata(1) delimited by ':'
            into tag3
         end-string
   end-evaluate
end-perform
Syntax checking required
Initializing and housekeeping are needed.
The above expects no more that one ':TAGn=' per input.
Back to top
View user's profile Send private message
vardhan0007

New User


Joined: 05 Jun 2006
Posts: 51
Location: Bangalore,India

PostPosted: Mon May 04, 2009 10:19 pm    Post subject:
Reply with quote

Thanks for the piece of code.

Good Quote:If you have knowledge, let others light their candles with it.


Thanks Again...
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1228
Location: Israel

PostPosted: Mon May 04, 2009 11:27 pm    Post subject: Re: Unstring in cobol
Reply with quote

vardhan0007 wrote:
eg: ::TAG1=AAAA :TAG2=11233281531219:TAG3=888888 :TAG4=AAAA
and there are many more tags in the record.
What you are showing in your example is not XML. What is it?
XML tags can be (and usually are) more complicated.

vardhan0007 wrote:
We are not parsing using XML. The program is a pure DB2 cobol program
If you have the correct COBOL version, you could use XML PARSE.
That would still be pure COBOL, except you would be using one of its newest feature!

If you can't, the piece of code by CICS Guy should show you the way. icon_smile.gif
Back to top
View user's profile Send private message
vardhan0007

New User


Joined: 05 Jun 2006
Posts: 51
Location: Bangalore,India

PostPosted: Tue May 05, 2009 9:22 am    Post subject:
Reply with quote

There are many more tags before TAG1 like TAGA:RRR TAGC:CCCC and plenty more tag before :TAG1=AAAA :TAG2=11233281531219:TAG3=888888 :TAG4=AAA
Now i need the exact values of TAG1,TAG2 and TAG3
Unstring input delimited by ':TAG1=' or ':TAG2=' or ':TAG3='
into tagdata(1) delimiter in tagdelimiter(1)
tagdata(2) delimiter in tagdelimiter(2)
tagdata(3) delimiter in tagdelimiter(3)
end-unstring
This will delimit the string till it encounters TAG1/2/3, so TAGDATA(1) will have the all the data that exists before TAG1 like TAGA/C and many more tags, which is not my requirement.
I need the Values of TAG1, TAG2 and TAG3. Again to stress these TAGS may not be positional for the next consecutive record.

Kindly suggest solutions.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue May 05, 2009 9:32 am    Post subject:
Reply with quote

Hello,

Quote:
Kindly suggest solutions.
Suggest you write code using reference modification to parse the "input field" and create the individual "tag output" fields as needed. . .
Back to top
View user's profile Send private message
vardhan0007

New User


Joined: 05 Jun 2006
Posts: 51
Location: Bangalore,India

PostPosted: Tue May 05, 2009 10:50 am    Post subject:
Reply with quote

Thanks for all the Quotes and all possible solutions provided to all.
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
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts COBOL Programming Sandpit? jodrisco COBOL Programming 6 Wed Apr 12, 2017 3:47 am


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