Return to the RPG Tips
Check for existance of objects from within a program
Create it as a module and stick it in a service program. One thing you should note, if you are not authorizied to the object, i still flag the object as existing. CHKOBJ doesnt work this way, but this way seems to work better for what i usualy use the procedure for. If you're not on RPGIV, i think i can find an RPGiii version around somewhere. HTH, Ron Hawkins HNOMAIN * * procedure name: Exists * * procedure function: Return Y/N field based on objects existence. * GetAcro prototype D/copy *libl/prsource,Exists P Exists B export d Exists PI 1 d Object 10 const d ObjectType 10 const d ObjectILib 10 const options(*nopass) d ReceiveVar s 100 d ReceiveLen s 9b 0 inz(100) d ObjdFormat s 8 inz('OBJD0100') d ObjectLib s 20 inz(' *LIBL ') d ObjectTypF s 10 d Valid s 1 D ErrorDs DS 116 INZ D BytesPrv 1 4B 0 inz(116) D BytesAvl 5 8B 0 inz(0) D MessageId 9 15 D ERR### 16 16 D MessageDta 17 116 * c movel Object ObjectLib c eval ObjectTypF = ObjectType c if %parms = 3 c move ObjectILib ObjectLib c endif * Attemp to retrieve object description C CALL 'QUSROBJD' C PARM ReceiveVar C PARM ReceiveLen C PARM ObjdFormat C PARM ObjectLib C PARM ObjectTypF C PARM ErrorDs c select * If not authorized, then object must exist c when MessageId = 'CPF9821' c eval Valid = 'Y' * Otherwise, error trying to get object description, means not valid c when MessageDta <> *blanks c eval Valid = 'N' c other c eval Valid = 'Y' c endsl c return Valid P Exists E
[report a broken link by clicking here]