gtpc2m2s | C/C++ Language Support User's Guide |
This function reads a record and attaches the block of working storage
containing it to the specified data level of the ECB. The ECB must not
be holding a storage block on the specified level.
This service finds a record that resides either in VFA or DASD.
Format
#include <tpfio.h>
void findc(enum t_lvl level);
- level
- One of 16 possible values representing a valid data level from the
enumeration type t_lvl, expressed as Dx, where x
represents the hexadecimal number of the level (0-F). The data
record being retrieved is attached to this level.
Normal Return
Void.
Error Return
Not applicable.
Programming Considerations
- The findc function cannot be issued on a record that is part of
the suspended commit scope of an ECB. The following sequence will cause
a system error:
- tx_begin()
- findc() record X
- tx_suspend_tpf()
- findc() record X.
- The specified CBRW is initialized to indicate that a block of storage is
attached to the specified data level. Specifying an invalid data level
results in a system error with exit.
- The TPF system checks to determine if the ECB is holding a block of
storage at the specified level and if the file address contained at the
specified level is valid. If either condition is violated, control is
transferred to the system error routine. In addition, the record ID on
the specified level, if nonzero, is compared with the record ID in the record
retrieved from file. The record code check on the specified level, if
nonzero, is also compared to the record code check in the record. If
either check fails, an error code is posted in the ECB level
indicators.
- To ensure completion of the I/O, the requesting program must call
waitc following findc. If an error has occurred,
waitc will return a nonzero value.
- TPF transaction services processing affects findc processing in
the following ways:
- If a system error occurs because of one of the previous considerations,
processing ends as if a rollback was issued.
- The TPF system will first search for the record in the commit
scope. If the record is not found, normal DASD retrieval will take
place from virtual file access (VFA) or the DASD surface.
Examples
The following example retrieves a data record from file on level D2 after
making a call to FACS to calculate the file address.
#define VD1RI "#VD1RI "
#pragma map(get_file_addr,"FACS") /* map FACS to a function name */
#pragma linkage(get_file_addr,TPF,N) /* define appropriate linkage */
#include <tpfapi.h>
#include <tpfio.h>
/* set up storage */
struct TPF_regs *regs = (struct TPF_regs *) &(ecbptr()->ebx000);
·
·
·
regs->r6 = (long int) VD1R1 /* record ID */
regs->r7 = (long int) &(ecbptr()->ce1fa2); /* lvl where file addr is */
regs->r0 = 10; /* ordinal number */
get_file_addr(regs); /* calculate fixed file address */
if (!regs->r0) /* FACS error? */
if (regs->r7 == 1) /* invalid record ID */
exit(0x12345);
else
{ /* invalid ordinal number */
serrc_op(SERRC_EXIT,0x12345,"INVALID ORDINAL NUMBER",NULL);
}
findc(D2); /* find the record */
if (waitc()) /* abort on any errors */
{
serrc_op(SERRC_EXIT,0x12345,"I/O ERROR OCCURRED",NULL);
/*
In TARGET(TPF) this used to be done with:
errno = 0x1234;
perror("I/O ERROR OCCURRED");
abort();
*/
}
Related Information