Processing Variable Length Files 
Author Message
 Processing Variable Length Files

I am in the process of writing a program that will read in a variable
length record of streaming data which happens to be the HIPAA 837
definition, of which the fields are seperated by the '*' character and
the end of record is defined by the "~" character.  Biggest question I
have is how to code it to read in the record then split it up into
seperate fields to be inserted into the segments they belong to.  The
COBOL books I have don't give me much help at all, they all deal with
flat and indexed files.


Tue, 12 Oct 2004 04:03:05 GMT  
 Processing Variable Length Files
Look at the UNSTRING verb which is designed to do this,
as in:  unstring input-record delimited by '*' into fld1 fld2 fld3....


Quote:
> I am in the process of writing a program that will read in a variable
> length record of streaming data which happens to be the HIPAA 837
> definition, of which the fields are seperated by the '*' character and
> the end of record is defined by the "~" character.  Biggest question I
> have is how to code it to read in the record then split it up into
> seperate fields to be inserted into the segments they belong to.  The
> COBOL books I have don't give me much help at all, they all deal with
> flat and indexed files.



Tue, 12 Oct 2004 04:53:54 GMT  
 Processing Variable Length Files

Quote:
> I am in the process of writing a program that will read in a variable
> length record of streaming data which happens to be the HIPAA 837
> definition, of which the fields are seperated by the '*' character and
> the end of record is defined by the "~" character.

Actually, the fields are delimited by the element separator, defined as the
first character following the 'ISA' segment identifier of the Interchange
Header segment and ended by the segment terminator, defined as the first
character following element 16 of that segment. Fields are also delimited by
the subelement separator, which is element 16 of that segment, but only if
the Interchange Standard (element 15) is at least '00302'

But go ahead and hard-code it if you like.

Quote:
> Biggest question I
> have is how to code it to read in the record then split it up into
> seperate fields to be inserted into the segments they belong to.  The
> COBOL books I have don't give me much help at all, they all deal with
> flat and indexed files.

UNSTRING is good, except that assumes you have a count of the elements in a
segment or do it one element at a time using the POINTER option of UNSTRING.
So is reading the input byte-by-byte until you hit a magic character. That's
about the limit of your choices.

In fairness, this is NOT simple code to write. And just wait until you have
to code for malformed EDI!

--
Michael Mattias
Tal Systems, Inc.
Racine WI



Tue, 12 Oct 2004 05:02:42 GMT  
 Processing Variable Length Files

Quote:



> > I am in the process of writing a program that will read in a variable
> > length record of streaming data which happens to be the HIPAA 837
> > definition, of which the fields are seperated by the '*' character and
> > the end of record is defined by the "~" character.

> Actually, the fields are delimited by the element separator, defined as the
> first character following the 'ISA' segment identifier of the Interchange
> Header segment and ended by the segment terminator, defined as the first
> character following element 16 of that segment. Fields are also delimited by
> the subelement separator, which is element 16 of that segment, but only if
> the Interchange Standard (element 15) is at least '00302'

Well, thanks for that tip, this whole HIPAA mess was thrown in my lap and I've
only gotten as far as the data division definitions of all the loops.

Quote:
> > Biggest question I
> > have is how to code it to read in the record then split it up into
> > seperate fields to be inserted into the segments they belong to.  The
> > COBOL books I have don't give me much help at all, they all deal with
> > flat and indexed files.

> UNSTRING is good, except that assumes you have a count of the elements in a
> segment or do it one element at a time using the POINTER option of UNSTRING.
> So is reading the input byte-by-byte until you hit a magic character. That's
> about the limit of your choices.

Great...I know it was much easier to split strings with perl and never done it
with COBOL.

Quote:
> In fairness, this is NOT simple code to write. And just wait until you have
> to code for malformed EDI!

Malformed EDI?  Well, I'm not familiar with it...explain?

--
Crimefighter                             Co-Creator, Promised Land MUD
The COMPLETE Abermud List            http://promisedland.betterbox.net



Tue, 12 Oct 2004 07:20:58 GMT  
 Processing Variable Length Files

Quote:

> I am in the process of writing a program that will read in a variable
> length record of streaming data which happens to be the HIPAA 837
> definition, of which the fields are seperated by the '*' character and
> the end of record is defined by the "~" character.  Biggest question I
> have is how to code it to read in the record then split it up into
> seperate fields to be inserted into the segments they belong to.  The
> COBOL books I have don't give me much help at all, they all deal with
> flat and indexed files.

See UNSTRING:

        MOVE SPACES   TO field-block                    
        UNSTRING Stream-Data
            DELIMITED BY "*" OR "~"
            INTO field1
                 field2
                 etc



Tue, 12 Oct 2004 19:20:26 GMT  
 Processing Variable Length Files
Have you told us what platform and compiler you are using?

Everyone who has recommended UNSTRING is giving "reasonable" advice - but
only when you have data "read" into your program.

The suggestion about reading "byte-by-byte" is PROBABLY the best way to get
your data into your program, but depending on the operating system and
COBOL, there MIGHT be better ways to do it (for example, if they support -
which most compilers don't) a useful version of the PADDING character phrase
to "delimit" your records.

--
Bill Klein
 wmklein <at> ix.netcom.com

Quote:
> I am in the process of writing a program that will read in a variable
> length record of streaming data which happens to be the HIPAA 837
> definition, of which the fields are seperated by the '*' character and
> the end of record is defined by the "~" character.  Biggest question I
> have is how to code it to read in the record then split it up into
> seperate fields to be inserted into the segments they belong to.  The
> COBOL books I have don't give me much help at all, they all deal with
> flat and indexed files.



Tue, 12 Oct 2004 08:52:14 GMT  
 Processing Variable Length Files
NetExpress 3.1

Quote:

> Have you told us what platform and compiler you are using?

--
Crimefighter                             Co-Creator, Promised Land MUD
The COMPLETE Abermud List            http://promisedland.betterbox.net



Tue, 12 Oct 2004 09:42:47 GMT  
 Processing Variable Length Files

Quote:

>I am in the process of writing a program that will read in a variable
>length record of streaming data which happens to be the HIPAA 837
>definition, of which the fields are seperated by the '*' character and
>the end of record is defined by the "~" character.  Biggest question I
>have is how to code it to read in the record then split it up into
>seperate fields to be inserted into the segments they belong to.  The
>COBOL books I have don't give me much help at all, they all deal with
>flat and indexed files.

Crimefighter:

One of my customers has already developed a tool which translates
records into HIPPAA compliant format.

It supports variable length records and translates the record in real
time as well.  The tool was designed to allow you to use it in any
COBOL application.


I'm not sure if this helps, but I figured that if it already exists,
why re-invent the wheel?

Bob Wolfe
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When replying by e-mail, make sure that you correct the e-mail address.
Check out The Flexus COBOL Page at http://www.flexus.com



Tue, 12 Oct 2004 20:46:16 GMT  
 Processing Variable Length Files

Quote:

> >I am in the process of writing a program that will read in a variable
> >length record of streaming data which happens to be the HIPAA 837
> >definition, of which the fields are seperated by the '*' character and
> >the end of record is defined by the "~" character.  Biggest question I
> >have is how to code it to read in the record then split it up into
> >seperate fields to be inserted into the segments they belong to.  The
> >COBOL books I have don't give me much help at all, they all deal with
> >flat and indexed files.

> Crimefighter:

> One of my customers has already developed a tool which translates
> records into HIPPAA compliant format.

> It supports variable length records and translates the record in real
> time as well.  The tool was designed to allow you to use it in any
> COBOL application.

There are a ton of software products available to parse and map ANSI ASC X12
EDI and have been for years. Unfortunately, they are all expensive to
license and require you learn a whole suite of products, and all the "big
guys'" products are designed to support all standards, all documents and
about eigh{*filter*} thousand options; there really is a dearth of limited-purpose
stuff available. However, I expect there will be a bunch of
reasonably-priced "HIPPA-EDI-only" libraries offered over the next two
years.

MCM



Wed, 13 Oct 2004 00:42:00 GMT  
 Processing Variable Length Files
Hi SM,

Here are a few ques that need answers before you can begin devising a solution:

1)  Do the "variable" recs contain  RDWs? These are 4 byte prefixes to the data
portion of the rec that contain the block and rec lengths. These will guide you
in defining the file to your compiler. If you choose the "unstring" solution
this may not be important, but if you choose the "byte-by-byte" solution,
knowing the length of the field can be helpful, if not downright crucial.

2)  I presume that each variable length rec contains a fixed # of fields
(including the null fields, defined as ...**...). Is that correct?

3)  How does the data provider handle separator chars (* ~) in the text string?
Most "wrap" the text in yet another separator char.  Is this situation possible
in your case?

Regards, Jack.



Thu, 14 Oct 2004 05:33:55 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Processing variable length/variable data files

2. processing variable length records in text file

3. Getting true length of a variable length record - IBM Mainframe

4. Finding Variable-Length Record Length

5. Problem when formating a variable delimited file to fixed length

6. Import dos file variable record length

7. Reading variable-length records from a file

8. Variable length file access

9. How to access files with variable length records?

10. How to access files with variable length records?

11. Variable Length Files- Fujitsu 5.0

12. Sorting a file with variable length records.

 

 
Powered by phpBB® Forum Software