PUTDDREC: Writing a Character String as a Record in a Sequential File

How to:

The PUTDDREC function writes a character string as a record in a sequential file. The file must be identified with a FILEDEF (DYNAM on z/OS) command. If the file is defined as an existing file (with the APPEND option), the new record is appended. If the file is defined as NEW and it already exists, the new record overwrites the existing file.

PUTDDREC opens the file if it is not already open. Each call to PUTDDREC can use the same file or a new one. All of the files opened by PUTDDREC remain open until the end of a request or connection. At the end of the request or connection, all files opened by PUTDDREC are automatically closed.

If PUTDDREC is called in a Dialogue Manager -SET command, the files opened by PUTDDREC are not closed automatically until the end of a request or connection. In this case, you can close the files and free the memory used to store information about open file by calling the CLSDDREC function.


Top of page

x
Syntax: How to Write a Character String as a Record in a Sequential File
PUTDDREC(ddname, dd_len, record_string, record_len, output) 

where:

ddname

Alphanumeric

Is the logical name assigned to the sequential file in a FILEDEF command.

dd_len

Numeric

Is the number of characters in the logical name.

record_string

Alphanumeric

Is the character string to be added as the new record in the sequential file.

record_len

Numeric

Is the number of characters to add as the new record.

It cannot be larger than the number of characters in record_string. To write all of record_string to the file, record_len should equal the number of characters in record_string and should not exceed the record length declared in the command. If record_len is shorter than the declared length declared, the resulting file may contain extraneous characters at the end of each record. If record_string is longer than the declared length, record_string may be truncated in the resulting file.

output

Integer

Is the return code, which can have one of the following values:

 0 - Record is added.
-1 - FILEDEF statement is not found.
-2 - Error while opening the file.
-3 - Error while adding the record to the file.



Example: Writing a Character String as a Record in a Sequential File

Using the CAR synonym as input,

FILEDEF LOGGING DISK baseapp/logging.dat
PUTDDREC('LOGGING', 7, 'Country:' | COUNTRY, 20, 'I5')

would return the value 0, and would write the following lines to logging.dat:

Country: ENGLAND

Country: JAPAN

Country: ITALY

Country: W GERMANY

Country: FRANCE


iWay Software