How can i check the object existance in RPG program without
using QCMDEXC command.

Answers were Sorted based on User's Feedback



How can i check the object existance in RPG program without using QCMDEXC command...

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

How can i check the object existance in RPG program without using QCMDEXC command...

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

How can i check the object existance in RPG program without using QCMDEXC command...

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

How can i check the object existance in RPG program without using QCMDEXC command...

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

How can i check the object existance in RPG program without using QCMDEXC command...

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

How can i check the object existance in RPG program without using QCMDEXC command...

Answer / gagandeep kaur

I think using PSSR is also correct.

Is This Answer Correct ?    1 Yes 5 No

How can i check the object existance in RPG program without using QCMDEXC command...

Answer / syam

Using MONITOR...ON-ERROR...ENDMON

Is This Answer Correct ?    2 Yes 9 No

Post New Answer

More RPG400 Interview Questions

how do you use commitment control in rpg?

0 Answers   IBM,


please help me answer to this question what is the difference between the binding and srvpgm in ilerpg?

4 Answers   HCL,


suppose a job is running for 15 minutes after that it goes to message wait? what are the impact analysis

1 Answers  


how do u find whether a record is locked or not??

4 Answers   CTS,


3. Given the DOS Specification below and the following information: • Indicator 50 is off • No records have been written to the subfile What will be the result if the EXFMT operation code is performed on the record format CTLR? A R SUBFL A DESCRIP 101 6 1ODSPATR(UL) A DFT(’NOT FOUND’) A R CTLR SFLCTL(SUBFL) A N50 SFLDSP A SFLDSPCTL A SFLINZ A 67 SFIJEND A SFLSIZ(13) A SFLPAG(12) A ACCOUNTNO 100 S 10 a.) Only AccountNo will display b.) SUBFL will be initialized with 13 blank records c.) An I/O exception error will occur d.) The screen will display 12 records with ‘NOT FOUND’

4 Answers   IBM,






what will happen two jobs have same name are submitted

5 Answers   CTS,


2. Which of the following statement(s) explains the difference(s) between the /INCLUDE and ICOPY directives? a.) No difference, they function the same b.) ACOPY cannot be used as a conditional directive c.) IINCLUDE files cannot contain embedded SQL d.) Nesting /TNCLUDE directives is not allowed

2 Answers   IBM,


wat is the difference between dataarea and data queue?

5 Answers   Airtel, Four soft, Shahi Exports,


RPG/400 number of Records present in a physical file using file information data structure FPF001 IP E DISK F KINFDS INFDS1 IINFDS1 DS I *RECORD RECORD Is this coding correct sir,i have given I P E that is I- input,P-primary file,E-externally described. Primary to use RPG logic cycle,is this the correct method because we have to find number of records present using file information data structure in RPG/400 without doing any input/output operations on the file and also without using DSPFD,SQL. If the above coding is correct means,when i compile the program it gets compiled,but if i call the program it does not return anything,i need number of records,please complete the coding sir.

1 Answers   IBM,


Let?s consider a variable X of length 20. Move value ?ABC? to it.How to determine how many characters does X have?

1 Answers  


WHAT IS MENT BY RECORD LEVEL IDENTIFIER ? WHAT IS THE PURPOSE OF THIS?

1 Answers  


How to check which are the pgms using 1 perticulate file.? I know there is many tool available for X-reference...but need to know is there any command available in the system...?

4 Answers   IBM,


Categories