|
I have here this little example for demonstration:
IDENTIFICATION DIVISION.
PROGRAM-ID. DYNSAMPLE.
* This program writes a record to the file.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT OUTPUT-FILE
ASSIGN TO DISK-FILE1
FILE STATUS IS FS1.
DATA DIVISION.
FILE SECTION.
FD OUTPUT-FILE
01 F-RECORD-1.
05 F-ITEM-1 PIC X(80).
WORKING-STORAGE SECTION.
01 FS1 PIC 99.
PROCEDURE DIVISION.
* DISK-file that is unavailable at the time of an
* OPEN operation is created dynamically in the same LIBRARY,
* where the program is placed.
OPEN OUTPUT OUTPUT-FILE.
IF FS1 NOT = 0 THEN
DISPLAY "File Status " FS1 " on OPEN"
STOP RUN
END-IF.
MOVE "Hello, this is the first record" TO F-RECORD-1.
WRITE F-RECORD-1.
IF FS1 NOT = 0 THEN
DISPLAY "File Status " FS1 " on WRITE"
STOP RUN
END-IF.
CLOSE OUTPUT-FILE.
IF FS1 NOT = 0 THEN
DISPLAY "File Status " FS1 " on CLOSE"
STOP RUN
END-IF.
GOBACK.
END PROGRAM DYNSAMPLE.
Compile the program with CRTBNDCBL using the OPTION(*CRTF).
The program DYNSAMPLE creates dynamically the program described file
FILE1 of the type *FILE and attribute PF-DTA
in the CURLIB.
The library for dynamically created file FILE1 can not by probably
specified, I tried it using the DISK-MYLIB-FILE1,
but the program created instead of the file MYLIB/FILE1 the file MYLIB in
my current library.
If you want your dynamically created file should be placed in the given
library, you should change your CURLIB to that library.
However if you try CHGCURLIB CURLIB(QTEMP), you get this error: Parameter
CURLIB value cannot be QTEMP. :-))
Better is using an externally described files instead of program described
files:
First add the given library to your LIBL, then create the externally
described file via DDS or SQL-stetement
and then run the program on that file - it works.
"Don Stafford" <don.stafford@xxxxxxxxx>
Sent by: cobol400-l-bounces@xxxxxxxxxxxx
27.01.2006 14:10
Please respond to
COBOL Programming on the iSeries/AS400 <cobol400-l@xxxxxxxxxxxx>
To
"COBOL Programming on the iSeries/AS400" <cobol400-l@xxxxxxxxxxxx>
cc
Subject
[COBOL400-L] File creation questions
I am using *CRTF as a compiler option - and my program does an OPEN OUTPUT
TextFile
1) How do I specify both the library is which I want the file created AND
the file name itself? I coded my SELECT statement as....
SELECT TextFile
ASSIGN TO DISK-ASN001
The created the file in the QTEMP library.
I tried to code the SELECT as.......
SELECT TextFile
ASSIGN TO DISK-UAVPROFL-ASN001
But the compiler stripped off the -ASN001
2) How do I specify *NOMAX for the file being created? If I don't, my
program errors out when the maximum number of records has been written...
THANKS for all the help!!
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.