On Wed, 14 Jan 2009 15:07:10 -0200, Carlos Bodra <cbo...@terra.com.br> wrote:
>Hi Listers, (xposted to VSE-L and OS/390 List) > >I need to read an IBM 3490 cartridge recorded by OS/390 program in a >Linux system. If this works fine in intel server, I can migrate it to >Linux under mainframe later. > >I have a 3490-E01 (scsi interface) connected to an IBM x236 system. >Until here no problem. > >Tape has a record type of VB (126-1295) and some fields into record are >defined as PIC 9(xxx) comp-3. I got this from mainframe cobol program, >since today >I read it in our mainframe system, using a cobol program. (read tape and >write a pds file) > >Since I´m no an expert in cobol or other programm language and in Linux >plataform, my questions are: > >There is any open source software or not that can read this record and >resolve comp-3 fields? I am not aware of any package which will do that, if this is what you mean. COMP-3 fields are "packed decimal". It is rather easy to convert these into an integer. The number of bytes that are taken for a PIC S9(n) COMP-3 field is (n+2)/2 and ignore the remainder. E.g. PIC S9(1) COMP-3 is 1 byte. PIC S9(2) COMP-3 is 2 bytes, as is PIC S9(3). And so on. Now, if there is no S in front of the 9, then the data is forced to be positive. Some C code which can convert from COMP-3 to int: int toint(unsigned char* packed, int digits) { int bytes=(digits+2)>>1; int n=bytes-1; int i,j; int result=0; for (i=1;i<n;i++) { result=100*j+10*(*packed>>1)+(*packed & 0x0f); packed++; /* examine next byte */ } result=10*result+(*packed>>1); i=*packed & 0x0f; if (i==11 || i==13) result=-result; /* negative sign */ return result; } >If no software availalble, any one has a sample how to read this record >using any linux plataform language? I've used Java to do something similar. I must assume that you already know how to read the file on tape. I don't know how to do that. But assume that the variable tape is the open()'ed FILE *. You must read every record yourself. This will be a bit complicated because the file is variable blocked. That means that every physical tape record consists of a BDW (Block Descriptor Word), followed by one or more logical records. Each logical record is prefixed with a RDW (Record Descriptor Word). My, this is getting complicated. The following C code should perhaps help. But I cannot test it (the same as the above). #include <stdio.h> #include <string.h> #include <stdlib.h> static char buffer[32768]; static int buf_off=32768; static int block_length=0; static int record_length=0; size_t doread(char *record, FILE *tape) { unsigned char bdw[2]; if (buf_off >= block_length) { block_read:; fread(bdw,2,1,tape); /* read the block descriptor */ block_length=bdw[1]<<8|bdw[2]-4; fread(bdw,2,1,tape); /* read and skip 2 bytes */ if (block_length>0) { fread(buffer,block_length,1,tape); } else goto block_read; } record_length=buffer[buf_off]<<8|buffer[buf_off+1]-4; buf_off+=4; if (buf_off+record_length>block_length) return -1; if (record_length>0) { memcpy(record,buffer+buf_off,record_length); } return record_length; } Note that the above copies the current logical record into your memory area. It also returns the length of the amount of data copied. The length could be zero. If the routine returns a -1, that means that there is a problem with the file (or a bug in my code). > >Thanks for comments and hints. > >-- >Carlos Alberto Bodra >VM/VSE System Consultant >Sao Paulo - Brazil Hope this is of some use to you. -- John ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html