Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MarcLodge or other. Have source to read any file?

Status
Not open for further replies.

dallasdino

Programmer
Nov 27, 2002
28
US
Does anyone have source to read any file into a general purpose program?

I have a COBOL smart compare but want to make it general purpose smart compare program.

Does anyone have an Assembler program or another way to do this?

I am only talking about simple flat files here.
 
Hi,
what type of cobol are you using? Usually a "flat file" (i.e. no unprintable characters, c/r at end of record)
can be defined as a line sequential type with any large record size because the read statement will stop at the c/r character.
 
Hi Dallas,
At my site they have what I think you are after. It's an assembler program that you pass a operand telling it what you want to happen (open, read, write etc.) a DDNAME, and an output area. After the program has been executed, the output area has the data (if a read has been performed) and various file details that enable the program to checkpoint restart on files by going straight to a particular record. This enables any program to read/write etc any file without having to know it's LRECL etc.

Unfortunately, it's in assembler, which is most definitely not my field, and I don't even begin to understand how it works. Also, it has been written in-house and so is copywrited by my site.

The only think I can suggest, as I think that this sort of thing is beyond Cobol (unless somebody knows different), is to post to the assembler forum (assuming there is one). Sorry I can't be of much further help.
Marc
 
For simple flat files only, follow mrregan's suggestion.

In your FD, allow a maximum size record length, with DEPENDING ON if you like. There is nothing else special to do that I can think of. This is done routinely in COBOL.

Dimandja
 
Thanks to everyone.

I am breaking open the old assembler books and I will publish the result after it is tested. Maybe it will help someone else.

I had thought this was common problem going back to the 70s so someone would a block of MVS assemebler code to do this but by the lack of valuable responses there seems to be little knowledge of this.

I will try the assembler forums but there does not look to be much mainframe assembler being written.

Where have all the real hard core programmers gone? Are they all dead?
 
Dallas,
I'm still not sure exactly what it is you are after, and obviously from the fact that Dimandja's reply differs greatly from mine, I'd say that there is a small amount of confusion. Please give further details about what you are trying to achieve.
Marc
Ps. If you require an assembler routine that performs file open/close/read/write actions then try which I found in a simple search. It may save you from dusting off the manuals. The hard core programmers are still around, we just don't know every language! :)
 
I agree with Marc. What is being asked here is not clear at all.

Also, dallasdino, I thought you had started a thread (thread209-416310) on this issue. Have your requirements changed? Or is that thread not addressing the issue?

Dimandja

 
This is for a MVS mainframe OS/390 system. I forgot COBOL was on so many platforms but most COBOL is still on the mainframe so I assumed. Sorry.

I am interested in reading any size flat file either fixed or variable length and getting the DCB parameters from the program. I do have mainframe assembler skills but I have yet to venture too far down this path. After the file is opened it can be determined what type of file it is.

SYNCSORT, EDSs Waapdsut, DYL280, Easytrieve and many other utilities can process files without knowing the attributes first.

I have written a smart compare COBOL program that works but I must define the COBOL with some length. This does work but I must copy the OLD and NEW files to match the input format for COBOL and then supply the real attributes by a parm or card input. I could make the file variable but I would still have to copy the old fixed and new file using a SORT or something to the standard format for the COBOL progam. I want to bypass these extra steps copying the input to a certain format first. An assembler subprogram with a GL returning the file with a pointer might do the trick. I wish COBOL could.

Below is some basic assembler GET logic with a pointer.
I have seen sample code for after the open to test for a fixed or variable file as below but I am not sure it works yet. Also can I get other information like the LRECL supplied by the JCL when the file is opened? All I really need is the LRECL and if it is a fixed or variable file.
LA 1,FILEIN POINT TO DCB
TM 36(1),X'40' CHECK IF FIXED OR VARIABLE FILE
BZ FIXED
B VARIABLE

Basic 370 Assembler code:
USING NEWDSECT,4 REGISTER 4 POINTS TO NEW
************************************************************************
* READ THE NEWFILE *
************************************************************************
READNEW DS 0H
ST 14,READNEWS
CLI SNEWEOF,C'Y' IF NEW FILE NOT EOF
BE READNEWX
GET NEWFILE READ NEWFILE
LR 4,1 POINT TO NEW DSECT
B READNEWX ELSE
EOFNEW MVI SNEWEOF,C'Y' SET EOF SWITCH TO YES
READNEWX DS 0H END-IF
L 14,READNEWS
BR 14
SNEWEOF DC CL1'N'
NEWFILE DCB DSORG=PS,MACRF=GL,DDNAME=NEWFILE,EODAD=EOFNEW
 
Hi DD,

Since you're using MVS etc. COBOL you might consider defining the FB files as RECODING MODE U with a 32K rec len and ODO. I've used ODO with V recs, but never U. I'd guess it works the same way, but without the RDW/BDWs.

Anyway, you can then loop thru the block and compare record to record using the ODO field as the block size limit. You'de have to check the size of each block because of the possibility of imbedded and EOF short blocks. Kind of messy, but it might work.

Jack
 
Dallasdino,

I will first answer the following question...
Where have all the real hard core programmers gone? Are they all dead?
We are fortunate to have access to the father of one of the individuals in our group. He has written quite a few COBOL, Assembler and many other programs during his career and we can assure you that he is alive and well and keeping up with the best. We presented your question to him and he gave us the following.


This is a COBOL program that calls an Assembler program that provides access to a flat file. Since the LRECL is not specified it is returned in the DCB. In this example the COBOL program has a buffer specified in Working Storage with a length of 4,096 bytes so this is the maximum record length that can be read. You can increase this if it is not enough. A JCL member is also included. We tried it with two files, one with 80-byte records and one with 256 byte records and it worked simply by changing the DD statement in the JCL. The example and all the source code may be downloaded from the preceding URL.

Let us know if this is helpful and thanks to the Grey Fox for this one.

Saginaw
helpdesk@simotime.com
 
Hey guys,

Here is the solution is used. Please feel free to contact me for any source you would like. I have gotten the concept to work fine.

In any case I have a read/write program written in assembler that clearly shows how to get the input format and LRECL. It essentially does what SORT=COPY does for simple QSAM files. I am about 90% done writing the smart compare program in assembler. (I decided that I would just do this all in assembler but I have the ability to call COBOL now that I have it working.)

This smart compare has the following desirable features.
1. Key start/length provided to program for adds/deletes
2. OMIT columns provided allowed to prove you only changed thos columns
3. New file in
4. Old file in
5. Adds file out same length as new file
6. Deletes file out the same length as new file
7. Compare OMIT file (like compare file but omits columns in compare)
8. Compare file out 10 bytes longer than input with a 10 byte header showing 7 bytes of a record count and a new/old indicator with only the miscompared characters shown on the old file line and * under those characters for an easy read.
Code:
0000022 N MISCOMPARE   YYY
0000024 O NOT        XXX
        * ***        OOOOO
9. Smart compares are done by adding an omit card. This allows the omit columns to be omitted for compare purposes. This is enter by control card of omit or include. This card is optional.
Code:
OMIT    00012,00005

The whole premise here is to prove a file change by compare. After a file fix if you expected to change the customer code on the master file for 100 accounts a before and after download would be done and the key and omit card supplied to the program. Your expected results would be that there was 100 miscompares but zero would be in the omit file. This proves you changed what you wanted but also importantly proves you did not truncate all the records you updated for instance. This is soimetimes overlooked in testing.

The assembler version of this program does a couple of things that the COBOL version did not. The assembler version allows the input file to be any length. This allows you to omit a reformatting step to a particular length of file that the COBOL version required. The omit table built is not limited by a value imposed like 4096 and can always be the same as the input file. While this is little limitation it does make the utility more general purpose.

Here is the code needed for getting the input file attirbutes and setting an output file to the same attributes as an input file. If someone needs a general use program called from COBOL I would be happy to provide one. As you can see the format and LRECL can be gotten easily from the DCB after the input file is open but before it is read.
Code:
         OPEN  (IFILE,INPUT)           OPEN INPUT TO GET ATTRIBUTES
         MVC   OFILE+36(1),IFILE+36    MOVE THE FORMAT INPUT TO OUTPUT
*                                      V=X'40',VB=X'50,F=X'80',FB=X'90'
         MVC   OFILE+82(2),IFILE+82    MOVE THE LRECL  INPUT TO OUTPUT
*                                      (RECORD LENGTH IS A HALF WORD)
         OPEN  (OFILE,OUTPUT)          OPEN OUPUT WITH INPUT ATTRIBUTES

IFILE    DCB   DSORG=PS,MACRF=GL,DDNAME=IFILE,EODAD=EOFI
OFILE    DCB   DSORG=PS,MACRF=PL,DDNAME=OFILE
Thanks for everyone pointing me in the right direction. Yak back if you want a copy of the finished program of anything you have seen me post.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top