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

Unstring in cobol


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon May 04, 2009 5:09 pm
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
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: 2146
Location: At my coffee table

PostPosted: Mon May 04, 2009 6:07 pm
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon May 04, 2009 7:32 pm
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: 2146
Location: At my coffee table

PostPosted: Mon May 04, 2009 8:47 pm
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
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: 1353
Location: Israel

PostPosted: Mon May 04, 2009 11:27 pm
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
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

Moderator Emeritus


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

PostPosted: Tue May 05, 2009 9:32 am
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
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 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 COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top