IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

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: 7309
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

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
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: 191
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

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Pulling a fixed number of records fro... DB2 2
No new posts VB to VB copy - Full length reached SYNCSORT 8
Search our Forums:

Back to Top