bdfp1m1o | Programming Concepts and Reference |
Use this function to sort logical records (LRECs) in an open subfile.
Format
void dfsrt(dft_fil *file, dft_fil *input, dft_opt options, dft_kyl *key_list);
void dfsrt_pty(dft_fil *file, dft_fil *input, dft_opt options, dft_kyl *key_list, dft_pty pty);
|
Entry Requirements
Both subfiles must be opened before you call the dfsrt function.
Normal Return
None.
Error Return
See Identifying Return Indicators and Errors for information about how to check the error indicators.
Programming Considerations
Figure 19. Sorting LRECs from One Subfile into Another. The input file is defined by the input parameter and the output file is defined by the file parameter.
Examples
The following example sorts LRECs from the subfile file_ptr and puts them into the file out_file_ptr. The sort key is in a key list structure called keys.
/* set up the keys to use to sort the output file */ df_nbrkeys(&sortkeys, 1); df_setkey(&sortkeys, 1, offsetof(struct gr95sr, gr95nam), member_size(struct gr95sr, gr95nam), 0, NULL, 0, DF_UPORG, DF_CHAR); /* set up the keys to use to select the LRECs in the input file */ df_setkey(&keys, 1, offsetof(struct gr95sr, gr95key), 1, DF_EQ, &pky, 0, DF_UPORG, DF_CHAR); df_nbrkeys(&keys, 1); dfkey(in_fileptr, &keys); /* sort the subfile after extracting matching LRECs */ /* release the input file after the sort */ /* (the key list in the command is the sort key specification) */ dfsrt(out_file_ptr, in_fileptr, DFSRT_RELEASE, &sortkeys);
Related Functions