COBOL Manual for TNS and TNS/R Programs

Input and Output Concepts
HP COBOL Manual for TNS and TNS/R Programs522555-006
26-9
Associating COBOL File Names With System File
Names
To follow Step 2, you must declare Working-Storage data items to hold the name and
the error value returned by the COBOLASSIGN or COBOL_ASSIGN_ routine, prompt
the user for a file name, and then call the COBOLASSIGN or COBOL_ASSIGN_
routine:
01 ADJUSTABLE-STUFF.
03 ADJUSTABLE-NAME PICTURE X(34).
03 ADJUSTABLE-ERROR PICTURE S9(4).
. .
DISPLAY "What file shall I read?".
ACCEPT ADJUSTABLE-NAME.
ENTER "COBOLASSIGN" USING ADJUSTABLE
ADJUSTABLE-NAME
GIVING ADJUSTABLE-ERROR.
IF ADJUSTABLE-ERROR = ZERO
OPEN INPUT ADJUSTABLE
ELSE
PERFORM ADJUSTABLE-ERROR-ROUTINE
...
To lock a file that has been opened with dynamic assignment, use the LOCKFILE
statement. You cannot perform a CLOSE WITH LOCK operation on such a file.
For further information about the COBOLASSIGN and COBOL_ASSIGN_ routines, see
COBOLASSIGN and COBOL_ASSIGN_.
DEFINE Name
If the file-control entry assigns the COBOL file name (the file-name in the SELECT
clause) with a DEFINE name (the define-name-literal in the ASSIGN clause),
then you must associate the DEFINE name with a system file name before executing
the program (see Adding DEFINEs
). Even when the program executes in the OSS
environment, the DEFINE must specify a Guardian file name, tape device, or spooler.
These SELECT and ASSIGN clauses associate the COBOL file name MAJRACCT
with the DEFINE name =BIGCUST:
SELECT MAJRACCT
ASSIGN TO "=BIGCUST"
This command associates =BIGCUST with the system file \AKRON.$SLB.MAJ.ACC:
ADD DEFINE =BIGCUST, FILE \AKRON.$SLB.MAJ.ACC
Note. Do not use #DYNAMIC in the TACL command ASSIGN. You will get an error when you
try to assign a system file name to the associated COBOL file name with the COBOLASSIGN
or COBOL_ASSIGN_ routine.
Note. This topic applies only to the Guardian file system. DEFINEs do not accept OSS
pathnames.