Retreive Stream file size through CL

70 pts.
Tags:
AS/400 Control Language
CL
CLP
Stream files
Hi, How to detemine the file size of a '.TXT' file through CL program? Its a file stored in the IFS folder. Is there any specific command to do this? I need to continuosly look into this folder for the file. Fetch the file size. Wait for some sec and then again retrive the file size. If the size matches means the file was completely copied and hence start processing ithe file. Thanks.

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi,

The following ILE CL program should retrieve the size for you. Be aware that the size in the IFS may not match the size of an object from a library. You can uncomment the SNDPGMMSG commands if you want to see what gets retrieved. You need to pass the IFS object name including path and receive the size in your program (*DEC 15,0).

<pre>

RTVIFSSIZE: PGM PARM(&IFSOBJ &ALLOCDEC)

DCL VAR(&IFSOBJ) TYPE(*CHAR) LEN(256)
DCL VAR(&RTNVALBIN) TYPE(*CHAR) LEN(4)
DCL VAR(&RTNVALDEC) TYPE(*DEC) LEN(5 0)
DCL VAR(&RECEIVER) TYPE(*CHAR) LEN(4096)
DCL VAR(&NULL) TYPE(*CHAR) LEN(1) VALUE(X’00’)
DCL VAR(&SIZEBIN) TYPE(*CHAR) LEN(4)
DCL VAR(&SIZECHR) TYPE(*CHAR) LEN(15)
DCL VAR(&SIZEDEC) TYPE(*DEC) LEN(15 0)
DCL VAR(&ALLOCBIN) TYPE(*CHAR) LEN(4)
DCL VAR(&ALLOCCHR) TYPE(*CHAR) LEN(15)
DCL VAR(&ALLOCDEC) TYPE(*DEC) LEN(15 0)
CHGVAR VAR(&IFSOBJ) VALUE(&IFSOBJ *TCAT &NULL)

CALLPRC PRC(‘stat’) PARM((&IFSOBJ) (&RECEIVER)) +
RTNVAL(%BIN(&RTNVALBIN))

CHGVAR VAR(&RTNVALDEC) VALUE(%BIN(&RTNVALBIN))

IF COND(&RTNVALDEC *NE 0) THEN(SNDPGMMSG +
MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(‘IFS +
OBJECT ‘ *CAT &IFSOBJ *TCAT ‘ NOT FOUND’) +
MSGTYPE(*ESCAPE))

CHGVAR VAR(&SIZEBIN) VALUE(%SST(&RECEIVER 21 4))
CHGVAR VAR(&SIZEDEC) VALUE(%BIN(&SIZEBIN))
CHGVAR VAR(&SIZECHR) VALUE(&SIZEDEC)
/* SNDPGMMSG MSG(‘The object is’ *BCAT &SIZECHR *BCAT +
‘bytes’) */

CHGVAR VAR(&ALLOCBIN) VALUE(%SST(&RECEIVER 45 4))
CHGVAR VAR(&ALLOCDEC) VALUE(%BIN(&ALLOCBIN))
CHGVAR VAR(&ALLOCCHR) VALUE(&ALLOCDEC)
/* SNDPGMMSG MSG(‘The object uses’ *BCAT &ALLOCCHR *BCAT +
‘bytes disk space’) */

ENDPGM
</pre>

Regards,

Martin Gilbert.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following