[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference clt::cobol

Title:VAX/DEC COBOL
Notice:Kit,doc,performance talk info-->DIR/KEY=KIT or DOC or PERF_TALK
Moderator:PACKED::BRAFFITT
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3250
Total number of notes:13077

3220.0. "help with creating/reading tapes on Digital UNIX" by CSC32::E_VAETH (Suffering from temporary brain cramp, stay tuned) Wed Mar 26 1997 17:47

    Hi,
    
    I am ready to call Uncle... I am working with a customer that is trying
    to read a tape created on an IBM system using DEC COBOL on Digital
    UNIX.  He consistently gets;
    
    cobrtl: severe: The tape in drive /dev/nrmtra  has invalid ANSI
    format or is incorrectly positioned
    
    
    So I tried to create a file on tape without success.  I get:
    
    
    licris.cxo.dec.com> ./tstape
    Begin writing tape
    cobrtl: info: Tape device is required for file DATAFILE
    cobrtl: info: Enter tape device name or press A to abort:
    /dev/rmt0h
    cobrtl: severe: Error during OPEN on file DATAFILE
    cobrtl: severe: The tape in drive /dev/nrmt0h has invalid ANSI
    format or is incorrectly positioned
    licris.cxo.dec.com>
    
    Then the tape ejects.  What am I doing wrong.  I can copy/pull files to
    the tape using the dd and tar commands without problems.  My code
    follows. 
    
    Help!!
    
    Thanks, 
    
    Elin
    
    
    identification division.
    program-id.   bldtape.
    environment division.
    configuration section.
    input-output section.
    file-control.
    
        select data-file
            assign to reel
            organization is sequential.
    
    data division.
    file section.
    fd  data-file
        value of id "datafile"
        record contains 100 characters.
    01  data-rec.
        03  data-rec-text         pic x(19).
        03  data-rec-no           pic 9(5). 
        03  data-rec-stuff        pic x(76).
    
    working-storage section.
    01  irecno                    pic s9(9)  comp value 0.
    
    procedure division.
    start-here.
         display 'Begin writing tape'.
         open output data-file.
    
         move "Data Record number " to data-rec-text.
         move all " data" to data-rec-stuff.
         perform varying irecno
              from 1 by 1 until irecno is greater than 500
                move irecno to data-rec-no
                write data-rec
         end-perform.
    
         close data-file.
T.RTitleUserPersonal
Name
DateLines
3220.1ltf command line?PACKED::BRAFFITTWed Mar 26 1997 18:313
>    So I tried to create a file on tape without success.  I get:
    
    What ltf command line did you use initialize the tape?
3220.2didn't init tapeCSC32::E_VAETHSuffering from temporary brain cramp, stay tunedThu Mar 27 1997 10:438
I didn't use ltf.  I don't know that will do anything to help.  Will it?  I just
tried initializing it.  From what I can tell, you have to use -c, -H, -t, -x or
-i along with another qualifier.  I think I want -O (omits usage of optional
headers) and now it is really hosed.

Even if I can get the tape to work by some combination of init and whatever,
that still won't help the customer. He is reading tapes created on an IBM.  It
needs to be kinda like the VMS mount/foreign command.
3220.3DEC COBOL RTL supports ANSI labeled tapes initialized with ltfPACKED::BRAFFITTThu Mar 27 1997 14:2919
>I didn't use ltf.  I don't know that will do anything to help.  Will it?  I just

>Even if I can get the tape to work by some combination of init and whatever,
>that still won't help the customer. He is reading tapes created on an IBM.  It
>needs to be kinda like the VMS mount/foreign command.
    
    The DEC COBOL RTL supports tape handling only for those tapes
    initialized with ltf as ANSI labeled tapes.
    
    If you need to work with a tape intialized some other way, you will
    need to use other DIGITAL UNIX utilities to read/write the tape to/from
    a disk file that can be processed with DEC COBOL.
    
******************************
CLT::CLT$LIBRARY:[DEC_COBOL]DEC_COBOL_RN_V24.TXT;1

     V2.4-863      [Digital UNIX] You must use ltf (logical tape facility)
                   as supplied on a Digital UNIX V3.0 or higher system to
                   initialize ANSI labeled magtapes.
3220.4CSC32::E_VAETHSuffering from temporary brain cramp, stay tunedThu Mar 27 1997 15:3326
>>******************************
>>CLT::CLT$LIBRARY:[DEC_COBOL]DEC_COBOL_RN_V24.TXT;1

>>     V2.4-863      [Digital UNIX] You must use ltf (logical tape facility)
>>                   as supplied on a Digital UNIX V3.0 or higher system to
>>                   initialize ANSI labeled magtapes.

I saw that, however I did not read that to mean that DEC COBOL *only* supports
ANSI labeled tapes.  I read it to mean that if you want to create an ANSI
labeled tape, then use ltf first.  Perhaps it should also say you can only
create ANSI labeled tapes through DEC COBOL.  Which is too bad. This customer is
trying real hard to stick with DEC COBOL, but he keeps hitting one road block
after another. This particular application (critical app) is build around
processing tapes created on other platforms, mostly IBM.  

He can (and  would not necessarilty mind) pulling the files off tape using the
dd command, however, then he has the same problem I reported in note 3210 for
him.  The workaround offered works in some cases but apparently not all cases
with his real files which are quite large.  I suggested that he use C for now to
process the files which is working ok for him.  But that is posing another
problem, that is they have (in his words) a lot of useless COBOL code and he has
to re-invent the wheel. 

Thanks,

elin
3220.5QUARRY::nethCraig NethThu Mar 27 1997 17:3211
If the tape isn't labeled, then don't describe it as a tape to COBOL and
everything should work.  (i.e. leave off assign to reel - just assign
it to /dev/rmt0h, and take out the value of id thing, or the RTL will
replace the rmt0h with the value of id string...).

It works for me.

The 'assign to reel' syntax is there specifically to describe ANSI labeled 
tapes, which requires all sorts of nasty machinations in the rtl.


3220.6almost thereCSC32::E_VAETHSuffering from temporary brain cramp, stay tunedFri Mar 28 1997 10:2227
Thanks Craig, yes that works great.  However, I don't believe it will do much
for the customer since he will be reading EBCDIC tapes created on an IBM
containing the header/data/trailer stuff.  Since I cannot create a tape with
multiple files from within COBOL, I am assuming that he will not be able to read
them either.  

cobol: Warning: tape.cob, line 9: CLOSE NO REWIND also requires ASSIGN TO
REEL/UNIT for use with magnetic tapes
    SELECT HEADER-FILE
-----------^
cobol: Warning: tape.cob, line 13: OPEN NO REWIND also requires ASSIGN TO
REEL/UNIT for use with magnetic tapes
    SELECT DATA-FILE
-----------^
cobol: Warning: tape.cob, line 13: CLOSE NO REWIND also requires ASSIGN TO
REEL/UNIT for use with magnetic tapes
    SELECT DATA-FILE
-----------^
cobol: Warning: tape.cob, line 17: OPEN NO REWIND also requires ASSIGN TO
REEL/UNIT for use with magnetic tapes
    SELECT TRAILER-FILE
-----------^

I'll keep digging.

thanks,
elin
3220.7A remembrance of IBM magtape handlingPACKED::MASLANKAFri Mar 28 1997 11:2732
Re .6

>   Thanks Craig, yes that works great.  However, I don't believe it will do much
>   for the customer since he will be reading EBCDIC tapes created on an IBM
>   containing the header/data/trailer stuff.  Since I cannot create a tape with
>   multiple files from within COBOL, I am assuming that he will not be able to read
>   them either.  

     I don't know about Digital UNIX handling of magtapes. However, the
     "header/data/trailer stuff" on an IBM magtape is actually three files.
     The header contains three 80-column card-images. These contain
     identifying information about the user's data file. The data is of 
     course the user's data file. The trailer contains two 80-column card-
     images which contain a little redundant identifying information and
     information about record and block counts for the user data.

     If the IBM user declares LABEL RECORDS STANDARD for his data file in the
     COBOL program that creates it, the program writes out these three files
     under the OPEN, WRITE and CLOSE verbs for the one user data file. Likewise, 
     a retrieval program in IBM COBOL will declare LABE RECORDS STANDARD and 
     this program will read these three files as if they were one file. If the 
     IBM user wants to deal with the three files individually, he sets up
     three FDs, one for each file and declares LABEL RECORDS OMITTED for each.
     Then he writes serial processing for OPEN, record-access-verb, CLOSE
     for each file in succession. When the user runs this program with LABEL 
     RECORDS OMITTED, he mounts the magtape and lets the system do its thing. 
     The idea is that after an IBM system closes each file it will position its 
     tape drive to the beginning of the next file . FWIW it also works this way 
     under OpenVMS VAX and Alpha, and it most likely works this way on Digital 
     UNIX. IBM essentially wrote the Bible on this kind of magtape handling 
     ages ago (mid-1960's) and it is a defacto industry standard. I would
     guess that you just need to stretch Craig's answer a little bit.
3220.8LABELLED tapes must be ANSIWENDYL::BLATTFri Mar 28 1997 11:4325
I suspect the tapes are IBM labelled.  There are two possible tape
label formats to be encountered:

1.  ANSI labelled
2.  IBM  labelled

and, of course:

3.  unlabelled

I think this thread shows that 1 & 3 are not true.  Therfore,
the tapes must have IBM labels on them.

DEC COBOL does not support #2.

There's probably a way to dump the first 80 bytes to read the
first label (dd?). I think there's a field defined in there that
specifies "A" for ANSI.    I think the tape header formats
are defined in the docset somewhere.






3220.9what a ANSI VOL1 label looks likeWENDYL::BLATTFri Mar 28 1997 12:0132
try ltf -tv

 v     Displays long form information about volume and files.  Normally, ltf
        operates with little terminal output.
 
The VOL1 label will be intreprted.  However, ltf works on ANSI volumes
only, so not sure just what will happen.  

Here is a view of the VOL1 label (ANSI):

typedef struct _VOL1_LABEL
{

  char label_id[4] ;           /* VOL1 label identifier           */
  char volume_id[6] ;          /* Volume Identifier      */  char access ;                /* Access field                    */
  char reserved1[26] ;         /* reserved for future use         */
  char owner_id[14] ;          /* Owner Identifier                */
  char reserved2[28] ;         /* reserved for future use         */
  char ANSI_version ;          /* ANSI tape version               */

} Cob_VOL1_Label ;


The last byte is expected to be a 3 or 4.

I don't know what an IBM label looks like, but it likely won't match
the above.

The next label starts with 4 bytes containing "HDR1".  If not, the error 
message in .0 will occur.