x
Reference: Usage Notes for the PUTDDREC and CLSDDREC Functions
- The open, close,
and write operations are handled by the operating system. Therefore,
the requirements for writing to the file and the results of deviating
from the instructions when calling PUTDDREC are specific to your
operating environment. Make sure you are familiar with and follow
the guidelines for your operating system when performing input/output
operations.
- You can call
PUTDDREC in a DEFINE FILE command or in a DEFINE in the Master File.
However, PUTDDREC does not open the file until its field name is
referenced in a request.
Example: Calling PUTDDREC in a TABLE Request
The following example defines a new
file whose logical name is PUTDD1. The TABLE request then calls
PUTDDREC for each employee in the EMPLOYEE data source and writes a
record to the file composed of the employee's last name, first name,
employee ID, current job code, and current salary (converted to
alphanumeric using the EDIT function). The return code of zero (in
OUT1) indicates that the calls to PUTDDREC were successful:
FILEDEF PUTDD1 DISK putdd1.dat
TABLE FILE EMPLOYEE
PRINT EMP_ID CURR_JOBCODE AS 'JOB' CURR_SAL
COMPUTE SALA/A12 = EDIT(CURR_SAL); NOPRINT
COMPUTE EMP1/A50= LAST_NAME|FIRST_NAME|EMP_ID|CURR_JOBCODE|SALA;
NOPRINT
COMPUTE OUT1/I1 = PUTDDREC('PUTDD1',6, EMP1, 50, OUT1);
BY LAST_NAME BY FIRST_NAME
END
The output is:
LAST_NAME FIRST_NAME EMP_ID JOB CURR_SAL OUT1
--------- ---------- --------- --- -------- ----
BANNING JOHN 119329144 A17 $29,700.00 0
BLACKWOOD ROSEMARIE 326179357 B04 $21,780.00 0
CROSS BARBARA 818692173 A17 $27,062.00 0
GREENSPAN MARY 543729165 A07 $9,000.00 0
IRVING JOAN 123764317 A15 $26,862.00 0
JONES DIANE 117593129 B03 $18,480.00 0
MCCOY JOHN 219984371 B02 $18,480.00 0
MCKNIGHT ROGER 451123478 B02 $16,100.00 0
ROMANS ANTHONY 126724188 B04 $21,120.00 0
SMITH MARY 112847612 B14 $13,200.00 0
RICHARD 119265415 A01 $9,500.00 0
STEVENS ALFRED 071382660 A07 $11,000.00 0
After running this request, the sequential
file contains the following records:
BANNING JOHN 119329144A17000000029700
BLACKWOOD ROSEMARIE 326179357B04000000021780
CROSS BARBARA 818692173A17000000027062
GREENSPAN MARY 543729165A07000000009000
IRVING JOAN 123764317A15000000026862
JONES DIANE 117593129B03000000018480
MCCOY JOHN 219984371B02000000018480
MCKNIGHT ROGER 451123478B02000000016100
ROMANS ANTHONY 126724188B04000000021120
SMITH MARY 112847612B14000000013200
SMITH RICHARD 119265415A01000000009500
STEVENS ALFRED 071382660A07000000011000
Example: Calling PUTDDREC and CLSDDREC in Dialogue Manager -SET Commands
The following example defines a new
file whose logical name is PUTDD1. The first -SET command creates
a record to add to this file. The second -SET command calls PUTDDREC to
add the record. The last -SET command calls CLSDDREC to close the
file. The return codes are displayed to make sure operations were
successful:
FILEDEF PUTDD1 DISK putdd1.dat
-SET &EMP1 = 'SMITH'|'MARY'|'A07'|'27000';
-TYPE DATA = &EMP1
-SET &OUT1 = PUTDDREC('PUTDD1',6, &EMP1, 17, 'I1');
-TYPE PUT RESULT = &OUT1
-SET &OUT1 = CLSDDREC('I1');
-TYPE CLOSE RESULT = &OUT1
The
output is:
DATA = SMITHMARYA0727000
PUT RESULT = 0
CLOSE RESULT = 0
After running this
procedure, the sequential file contains the following record:
SMITHMARYA0727000