How can i check the object existance in RPG program without
using QCMDEXC command.
Answers were Sorted based on User's Feedback
Answer / syam
Without using QCMDEXC.
RPG Free format
/Free
MONITOR;
Open emp1;
ON-ERROR 1217;
Dsply ' File not found'
return;
ENDMON;
/END-FREE
Is This Answer Correct ? | 13 Yes | 1 No |
Answer / keshar jain
In addition to above answers with MONITOR we can check for mesage CPF9801. It will give clear idea about object existence.
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / roshan.wankar
1. To check File object, you should defined file in User
open mode and by using %Open operation we can identify the
file object is present or not.
2. To check Program object,
Use MONITOR; opcode or in calling specify low indicator, if
Low indicator is On, means object is not present in library
list.
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / naveen chandra joshi
The question is:
How can i check the object existence in RPG program without
using QCMDEXC command?
Answers posted by AS/400 experts:- use Monitor On error; what if file is not in user opened mode and already declared & opened in F specs...this solution will not work in this case and program will throw error when it tries to open the file in F specs itself...(This we can solve using File Information DS)
User wants to know the object existence, it (object)can be file object, program object or any other type of object.
Generally we check object existence by using CHKOBJ command but user said not to use QCMDEXC API...
The solution is(by using QUSROBJD API):
*---------- 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
*-- 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)
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
Is This Answer Correct ? | 1 Yes | 3 No |
Answer / mithila
In RPG4, QusRtvObjd API can be used which has procedutrs
like ChkObj and ChkMbr. or a CL program can be called that
checks the existence of object and returns some indicator
to for found/not found.
Is This Answer Correct ? | 3 Yes | 7 No |
in which journalling which attributes are necessary??/
When it is desirable to describe files Internally?
what are the array operations?
1.How to read a subfile in out put mode? 2.what are the keywords used to share same file? 3.using composite key which rpg code used?
How can i keyed a flat file in RPGLE
what is post opcode do
What will be the value of STRING after line 0106 is executed in the code below? 0101 E* Fromfiletofile..tabnameprnentlenpdatabnamlenpda 0102 E ARR 8 1 0103 ISTRING DS 0104 I 1 8 ARR 0105 C MOVE *BLANK STRING 0106 C MOVEA'ABC' ARR A) 'AAAAAAAA' B) 'BBBBBBBB' C) 'CCCCCCCC' D) 'ABC ' E) ' ABC'
1. If my rpg program has a date field, What extra care I have to take while compiling that RPG program? 2. If the file is keyed and I have declared the file as well as Key list properly in my program. Still am getting an error message like "Chain/reade operation is not allowed" What may be the case?
what is data area and how it is used in rpg program ?
I want to add 10 days in current date. how it is possible in CL program...?
this is rpg3 code W0RTN IFEQ @CN,002 what is the means @CN,002
How to find d key field of a pf that doesn’t have source physical file?