|
On 18/03/2006, at 7:09 AM, Adrienne McConnon wrote:
I am trying to get a list of parm values for COBOL API-s - anyone know where something like this might be found? I can not believe they are not listed under the OPEN ()-- OPEN File api description on the boulder.ibm site. There are 25 pages explaining the api and its parameters - but no values! I am particularly interested in the oflag for the Open api using cobol.
I'm not aware of a COBOL list of these values. The API is intended to be used from C so IBM provide only the C prototypes and definitions. The API documentation tells you the name of the C include so you need to read that and convert the definitions to something usable in COBOL. The include is fcntl.h and is found in the H file in library QSYSINC.
QSYSINC is an optionally installable part of OS/400 so if you don't have the library you'll need to install the System Openness Includes which is option 13 of OS/400.
There are examples of using IFS APIs from COBOL in the archives.Many people have converted the C include to RPG IV. You may find it easier to convert one of these examples to COBOL than deal with the C definitions.
Here is a trivial example:
PROCESS NOMONOPRC.
IDENTIFICATION DIVISION.
PROGRAM-ID. IFSCOBOL.
AUTHOR. SIMON COULTER.
DATE-WRITTEN.
DATE-COMPILED.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-OFLAGS PIC 9(9) BINARY.
01 WS-O-RDONLY PIC 9(9) BINARY VALUE 1.
01 WS-O-WRONLY PIC 9(9) BINARY VALUE 2.
01 WS-O-RDWR PIC 9(9) BINARY VALUE 4.
01 WS-O-ACCMODE PIC 9(9) BINARY VALUE 7.
01 WS-O-CREAT PIC 9(9) BINARY VALUE 8.
01 WS-O-EXCL PIC 9(9) BINARY VALUE 16.
01 WS-O-TRUNC PIC 9(9) BINARY VALUE 64.
01 WS-O-NONBLOCK PIC 9(9) BINARY VALUE 128.
01 WS-O-APPEND PIC 9(9) BINARY VALUE 256.
01 WS-O-CODEPAGE PIC 9(9) BINARY VALUE 8388608.
01 WS-O-TEXTDATA PIC 9(9) BINARY VALUE 16777216.
01 WS-O-INHERITMODE PIC 9(9) BINARY VALUE 134217728.
01 WS-O-LARGEFILE PIC 9(9) BINARY VALUE 536870912.
01 WS-O-SHARE-RDONLY PIC 9(9) BINARY VALUE 65536.
01 WS-O-SHARE-WRONLY PIC 9(9) BINARY VALUE 131072.
01 WS-O-SHARE-RDWR PIC 9(9) BINARY VALUE 262144.
01 WS-O-SHARE-NONE PIC 9(9) BINARY VALUE 524288.
01 WS-AUTH-MODE PIC 9(9) BINARY.
01 WS-R-OWNER PIC 9(9) BINARY VALUE 256.
01 WS-W-OWNER PIC 9(9) BINARY VALUE 128.
01 WS-X-OWNER PIC 9(9) BINARY VALUE 64.
01 WS-RWX-OWNER PIC 9(9) BINARY VALUE 448.
01 WS-R-GROUP PIC 9(9) BINARY VALUE 32.
01 WS-W-GROUP PIC 9(9) BINARY VALUE 16.
01 WS-X-GROUP PIC 9(9) BINARY VALUE 8.
01 WS-RWX-GROUP PIC 9(9) BINARY VALUE 56.
01 WS-R-PUBLIC PIC 9(9) BINARY VALUE 4.
01 WS-W-PUBLIC PIC 9(9) BINARY VALUE 2.
01 WS-X-PUBLIC PIC 9(9) BINARY VALUE 1.
01 WS-RWX-PUBLIC PIC 9(9) BINARY VALUE 7.
01 WS-ERRNO-PTR USAGE IS POINTER.
01 WS-PATH PIC X(39).
01 WS-CODE-PAGE PIC 9(9) BINARY VALUE 819.
01 WS-FILE-DES PIC 9(9) BINARY.
LINKAGE SECTION.
01 WS-ERRNO PIC 9(9) BINARY.
PROCEDURE DIVISION.
CALL PROCEDURE "__errno" RETURNING WS-ERRNO-PTR.
SET ADDRESS OF WS-ERRNO TO WS-ERRNO-PTR.
STRING "/TMP/README" DELIMITED BY SIZE
X'00' DELIMITED BY SIZE
INTO WS-PATH.
ADD WS-O-WRONLY WS-O-CREAT WS-O-EXCL WS-O-CODEPAGE
GIVING WS-OFLAGS.
ADD WS-RWX-OWNER WS-R-PUBLIC GIVING WS-AUTH-MODE.
CALL PROCEDURE "open" USING BY REFERENCE WS-PATH
BY VALUE WS-OFLAGS
WS-AUTH-MODE
WS-CODE-PAGE
RETURNING WS-FILE-DES.
CALL PROCEDURE "close" USING BY VALUE WS-FILE-DES.
ADD WS-O-WRONLY, WS-O-TRUNC, WS-O-TEXTDATA GIVING WS-OFLAGS.
CALL PROCEDURE "open" USING BY REFERENCE WS-PATH
BY VALUE WS-OFLAGS
RETURNING WS-FILE-DES.
CALL PROCEDURE "close" USING BY VALUE WS-FILE-DES.
STOP RUN.
EXIT.
Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software AS/400 Technical Specialists
http://www.flybynight.com.au/
Phone: +61 3 9419 0175 Mobile: +61 0411 091 400 /"\
Fax: +61 3 9419 0175 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------
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.