Return to the CL Tips
Retrieve an IFS Stream File's size
The RTVOBJD (Retrieve Object Description) command lets you retrieve the size of an object in the QSYS.LIB file system. However, no similar
command exists for retrieving the size of a stream file.
You can use the CL code shown below in a program to retrieve the size of a stream file in the AS/400 integrated file system (IFS). The
variable &PATH contains the path to the stream file, such as '/MYDIR/MYSUBDIR/FILE.EXT' or '/QDLS/MYFOLDER/MYDOC.EXT', and the size
is returned in the variable &SIZEDEC.
DCL VAR(&PATH) TYPE(*CHAR) LEN(128) DCL VAR(&SIZEDEC) TYPE(*DEC) LEN(15 0) DCL VAR(&HANDLE) TYPE(*CHAR) LEN(16) DCL VAR(&SIZEBIN) TYPE(*CHAR) LEN(4) DCL VAR(&PATHLEN) TYPE(*CHAR) LEN(4) DCL VAR(&ATTRTAB) TYPE(*CHAR) LEN(10) DCL VAR(&ATTRLEN) TYPE(*CHAR) LEN(4) CHGVAR VAR(%BIN(&PATHLEN)) VALUE(128) CHGVAR VAR(%BIN(&ATTRLEN)) VALUE(10) CALL PGM(QHFOPNSF) PARM(&HANDLE &PATH &PATHLEN + '100 100 ' &ATTRTAB &ATTRLEN ' ' + X'00000000') /* Open stream file */ CALL PGM(QHFGETSZ) PARM(&HANDLE &SIZEBIN + X'00000000') /* Get stream file size */ CALL PGM(QHFCLOSF) PARM(&HANDLE X'00000000') /* + Close stream file */ /* Retrieve the STMF size in decimal (15,0) */ CHGVAR VAR(&SIZEDEC) VALUE(%BIN(&SIZEBIN))Answer by Herman Van der Staey
[report a broken link by clicking here]