Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Writing Fixed-Length output of unknown length

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7306

PostPosted: Sat Sep 08, 2012 5:45 pm    Post subject: Writing Fixed-Length output of unknown length
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: 1534
Location: Andromeda Galaxy

PostPosted: Sat Sep 08, 2012 6:36 pm    Post subject:
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

Active User


Joined: 12 Jul 2006
Posts: 153
Location: USA

PostPosted: Sat Apr 19, 2014 1:29 am    Post subject: Re: Writing Fixed-Length output of unknown length
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts Problem reading GTF trace output danik56 ABENDS & Debugging 7 Thu Mar 16, 2017 1:02 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts How to get current date -1 and curren... murali.andaluri DFSORT/ICETOOL 3 Wed Mar 08, 2017 2:09 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us