Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Note: I don't think either of these are for Production-bound work.
There is a technique, here, to read an FB QSAM whose length is unknown at compile time (ie to run the same program unchanged with FB input of different lengths).
Jasorn, who developed and published the technique, said of FB output:
Quote: |
I haven't found any nice way to accomplish the same with the output file and still use FB. |
Now, David Staudacher, with assistance from Ronald Burr, has come up with a method, elsewhere, to achieve it in Cobol:
Quote: |
Coding "RECORD CONTAINS 0" on the FD, with PIC X(32767) on the subsequent 01 Level item, actually works, but gives a *nasty* "E" Level error and RC=8 on the compile step:
Code: |
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT OUTFILE ASSIGN OUTFILE.
DATA DIVISION.
FILE SECTION.
FD OUTFILE RECORD 0 RECORDING MODE F.
01 OUTREC PIC X(32767).
WORKING-STORAGE SECTION.
01 OUTAREA PIC X(32) VALUE '----+----1----+----2----+----3--'.
PROCEDURE DIVISION.
OPEN OUTPUT OUTFILE
|
Quote: |
IGYPA3143-E Physical "SEQUENTIAL" file "OUTFILE" specified in an "OPEN OUTPUT" or an "OPEN EXTEND" statement was defined with a "RECORD CONTAINS 0 CHARACTERS" clause. The statement was processed as written. |
Code: |
WRITE OUTREC FROM OUTAREA
CLOSE OUTFILE
GOBACK.
|
Still, if I ignore the "E" level error and RC=8 from the compile and go ahead and run the program anyway, using JCL like the above mentioned, with LRECL=12 in STEP1 and LRECL=24 in STEP2, I get:
Code: |
FILE1 = "----+----1--" (12 bytes, as expected)
FILE2 = "----+----1----+----2----" (24 bytes, as expected) |
Perfect results except for the compile error. Maybe compile with NOFLAG? |
The JCL referred to is:
Code: |
//*-----* FIRST - OUTPUT 12 BYTE RECORDS
//STEP1 EXEC PGM=COBPGM
//OUTFILE DD DSN=<file-name>,DISP=(,CATLG),
// SPACE=(TRK,1),DCB=(RECFM=FB,LRECL=12)
//*
//*-----* NEXT (SAME PROGRAM) - OUTPUT 24 BYTE RECORDS
//STEP2 EXEC PGM=COBPGM
//OUTFILE DD DSN=<file-name>,DISP=(,CATLG),
// SPACE=(TRK,1),DCB=(RECFM=FB,LRECL=24)
|
|
|
jasorn Warnings : 1 Active User
Joined: 12 Jul 2006 Posts: 191 Location: USA
|
|
|
|
Quote: |
Now, David Staudacher, with assistance from Ronald Burr, has come up with a method, elsewhere, to achieve it in Cobol:
|
Excuse the use of the old thread but it seemed best to post it here. I have used this method and it works well. The problem I had was I couldn't move it to production because I couldn't get around the rc=8. But it has served me well in test. Unfortunately we are moving to a compile process which will not let me intervene even in test and continue dispite the rc=8. |
|