Problem:
Example of Status Codes returned by byte-streams routines:
14605 = Hex 390D = 9 013 = File not found.
The sample pasted below "retrieves" the extended file-status code from the status-code returned by the byte-stream routine.
Resolution:
copy "cblproto.cpy".
program-id. MYMAIN.
working-storage section.
01 .
05 file-details cblt-fileexist-buf.
01 status-code pic xx comp-5.
01 status-codeX pic xx comp-x.
01 lgind-status redefines status-codeX .
03 status-key-1 pic x.
03 status-key-2 pic x.
03 status-key-bin redefines status-key-2 pic x comp-x.
01 key-2-disp pic 999.
01 work-msg pic x(20).
procedure division.
call 'CBL_CHECK_FILE_EXIST' using 'mymain.cbl '
file-details
if return-code not = 0
move return-code to status-codeX
perform disp-status
display 'File mymain.cbl does not exist (or error)'
else
display 'File mymain.cbl size is '
cblte-fe-filesize of file-details
end-if
initialize status-code
call 'CBL_CHECK_FILE_EXIST' using 'mymain.cbl '
file-details
returning status-code
end-call
if status-code not = 0 move status-code to status-codex
perform disp-status
end-if
stop run.
******************
*Disp-status
******************
disp-status.
if status-key-1 = "9"
move status-key-bin to key-2-disp
else
move status-key-2 to key-2-disp
end-if
move spaces to work-msg
string status-key-1 delimited by size
" " delimited by size
key-2-disp delimited by size
" " delimited by size
into work-msg
display work-msg
.
end program MYMAIN.