View previous topic :: View next topic |
Author |
Message |
gupta Beginner
Joined: 12 Feb 2005 Posts: 27 Topics: 15
|
Posted: Mon Feb 14, 2005 2:09 am Post subject: how to extract using cobol & easytrieve |
|
|
hi,
I have an req that i have to read the section of data from an input file
The input file is an VB of 32106 bytes.
INPUT-FILE DATAS;
<WAA>BND460000300*J880*L090205*WSXSA08120073*Z997*<STA>A803*OEMP*MBNU*T<GAA>
<WAA>BND460007495*J880*L090205*Q465654325*WSXSA08140147*Z997*<STA>A803*OEMP*MBNU*<GAA>
<WAA>BND460007693*J880*L090205*WSXSA08074718*Z997*<STA>A123*O000*MBNU*<GAA>
<WAA>BBD460012206*J880*L281004*WSXSA08044307* <STA>A803*M803*O803*U <GAA>
each record starting with <WAA> tag
A parameter will be passed stating read the data from '<WAA>' . I need to find the location and from there i have to read till i find '<' tag.
Then i have to seperate the information.
can anyone tell me a simple logic so that it can be implemented in
cobol & easytrieve
Thanks |
|
Back to top |
|
 |
powerhawk Beginner

Joined: 08 Nov 2004 Posts: 28 Topics: 4 Location: Stockholm
|
Posted: Mon Feb 14, 2005 5:49 am Post subject: |
|
|
I understand the task like this:
A parameter will give you the start tag, in the sample above it's <WAA>. The start tag can have any length, not just 5 characters. You want the data string from the character after the start tag till the next '<' character.
Here is a COBOL solution:
Initialize A-TAGLENGTH ( S9(4) COMP. )
inspect A-PARAMETER tallying A-TAGLENGTH for characters before initial spaces
Initialize A-STRINGSTART ( S9(4) COMP. )
inspect A-RECORD tallying A-STRINGSTART for leading A-PARAMETER(1:A-TAGLENGTH)
add A-TAGLENGTH to A-STRINGSTART
UNSTRING A-RECORD DELIMITED BY '<'
into A-STRING
with pointer A-STRINGSTART
END-UNSTRING
If the file records is in real XML (don't seems to be here) you can use the XML parse funktion instead. |
|
Back to top |
|
 |
gupta Beginner
Joined: 12 Feb 2005 Posts: 27 Topics: 15
|
Posted: Mon Feb 14, 2005 6:33 am Post subject: |
|
|
Thanks powerhawk. |
|
Back to top |
|
 |
|
|