View previous topic :: View next topic
|
Author |
Message |
vardhan0007
New User
Joined: 05 Jun 2006 Posts: 51 Location: Bangalore,India
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Is this before or after using XML PARSE? |
|
Back to top |
|
|
vardhan0007
New User
Joined: 05 Jun 2006 Posts: 51 Location: Bangalore,India
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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 |
|
|
vardhan0007
New User
Joined: 05 Jun 2006 Posts: 51 Location: Bangalore,India
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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 |
|
|
vardhan0007
New User
Joined: 05 Jun 2006 Posts: 51 Location: Bangalore,India
|
|
|
|
Thanks for the piece of code.
Good Quote:If you have knowledge, let others light their candles with it.
Thanks Again... |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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. |
|
Back to top |
|
|
vardhan0007
New User
Joined: 05 Jun 2006 Posts: 51 Location: Bangalore,India
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
vardhan0007
New User
Joined: 05 Jun 2006 Posts: 51 Location: Bangalore,India
|
|
|
|
Thanks for all the Quotes and all possible solutions provided to all. |
|
Back to top |
|
|
|