IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search Log in to check your private messages Log in
 

Writing Fixed-Length output of unknown length


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7312
Location: Inside the Matrix

PostPosted: Sat Sep 08, 2012 5:45 pm
Reply with quote

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? icon_smile.gif


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)
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1566
Location: Andromeda Galaxy

PostPosted: Sat Sep 08, 2012 6:36 pm
Reply with quote

I created a simple tool to avoid redundancy which will use REXX SKELS and get the length , type of files through variables create a COBOL code and then compile them.So I can make use of the same program unchanged "for some key functionalities"

Note: This was indeed useful in reusing the similar pattern of codes and yeah I was recompiling them everytime icon_wink.gif
Back to top
View user's profile Send private message
jasorn
Warnings : 1

Active User


Joined: 12 Jul 2006
Posts: 184
Location: USA

PostPosted: Sat Apr 19, 2014 1:29 am
Reply with quote

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.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 

Search our Forum:

Similar Topics
Topic Forum Replies
No new posts FILE STATUS - 39 ON VARIABLE LENGTH V... COBOL Programming 1
No new posts BMS map length field greater than zero CICS 3
No new posts Altering output file attributes All Other Mainframe Topics 5
No new posts SARBCH REPORT DD writing error CA Products 1
No new posts DB2 - row_number function - Need 1st ... DB2 5

Back to Top