付録 - プログラムのアンロード

unload_liant_files:proc() options(main);
%replace MAX_REC_LEN               by 100;
%replace MAX_REC_LEN_SV            by 102;
%replace INPUT_TITLE               by 'liantCISAM';
%replace OUTPUT_TITLE              by 'fixed_cisam.dat';
dcl inputfile    file record         env(vsam  recsize( MAX_REC_LEN ) );
dcl outputfile    file record output env(f recsize( MAX_REC_LEN_SV ));
 
dcl record_buff char(MAX_REC_LEN ) varying;
dcl fixed_buf   char( MAX_REC_LEN_SV ) based(addr(record_buff));
dcl vsam_buff   char( MAX_REC_LEN );
 
on endfile(inputfile) goto doneinputfile;

open file(inputfile) title(INPUT_TITLE) keyed sequential input;
open file(outputfile) title(OUTPUT_TITLE);
 
substr(fixed_buf, 2, length(fixed_buf) - 2) = '';
read file(inputfile) into(record_buff);
do while(1);
write file(outputfile) from (fixed_buf);
substr(fixed_buf, 2, length(fixed_buf) - 2) = '';
read file(inputfile) into(record_buff);
end;
 
doneinputfile:
close file(inputfile);
close file(outputfile);
end;