Return to the API Tips
QUSROBJD API example in RPG IV to test if an object exists by Carsten Flensburg
Here's an RPG/IV sample to test if an object exists: **-- Header specifications: --------------------------------------------** H Option( *SrcStmt ) **-- Global variables: -------------------------------------------------** D ObjNam s 10a D ObjLib s 10a D ObjTyp s 10a **-- Api error data structure: -----------------------------------------** D ApiError Ds D AeBytPro 10i 0 Inz( %Size( ApiError )) D AeBytAvl 10i 0 Inz D AeMsgId 7a D 1a D AeMsgDta 128a **-- Object description structure OBJD0100: ----------------------------** D RoData Ds D RoBytRtn 10i 0 D RoBytAvl 10i 0 D RoObjNam 10a D RoObjLib 10a D RoObjTypRt 10a D RoObjLibRt 10a D RoObjASP 10i 0 D RoObjOwn 10a D RoObjDmn 2a D RoObjCrtDts 13a D RoObjChgDts 13a D RoExtAtr 10a D RoTxtDsc 50a D RoSrcF 10a D RoSrcLib 10a D RoSrcMbr 10a **-- Retrieve object description: --------------------------------------** D RtvObjD Pr ExtPgm( 'QUSROBJD' ) D RoRcvVar 32767a Options( *VarSize ) D RoRcvVarLen 10i 0 Const D RoFmtNam 8a Const D RoObjNamQ 20a Const D RoObjTyp 10a Const D RoError 32767a Options( *VarSize ) ** **-- Get Web value: ----------------------------------------------------** ** C Eval ObjNam = '???' C Eval ObjLib = '*LIBL' C Eval ObjTyp = '*PGM' ** C CallP RtvObjD( RoData C : %Size( RoData ) C : 'OBJD0100' C : ObjNam + ObjLib C : ObjTyp C : ApiError C ) ** C If AeBytAvl > *Zero And C AeMsgId = 'CPF9801' **-- Object doesn't exist... C EndIf ** C Return ** Best regards, Carsten Flensburg (this example was found on the RPG400-L Mailing List)
[report a broken link by clicking here]