1.Load an runtime array of length 99 from the pf and you
want to handle all the possible errors?



1.Load an runtime array of length 99 from the pf and you want to handle all the possible errors?..

Answer / sagar wagh

H DFTACTGRP(*NO) ACTGRP(*NEW)

Dcl-F EMPPF DISK; // Declare the physical file

Dcl-S EmpArray CHAR(10) DIM(99); // Declare the runtime array
Dcl-S Index INT(10); // Declare an index for the array
Dcl-S ErrorMsg CHAR(100); // Declare a variable for error messages

// Main logic
C/EXEC SQL
C+ DECLARE C1 CURSOR FOR
C+ SELECT EMPNO FROM EMPPF
C/END-EXEC

C/EXEC SQL
C+ OPEN C1
C/END-EXEC

Index = 1;

DoU Index > 99;
C/EXEC SQL
C+ FETCH C1 INTO :EmpArray(Index)
C/END-EXEC

If SQLCOD = 100; // No more records
Leave;
ElseIf SQLCOD <> 0; // Handle SQL errors
ErrorMsg = 'SQL Error: ' + %Char(SQLCOD);
Dsply ErrorMsg;
Leave;
EndIf;

Index += 1;
EndDo;

C/EXEC SQL
C+ CLOSE C1
C/END-EXEC

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More RPG400 Interview Questions

Can we create 300 logical files based on a single physical file using the CRTLF command only once?.

8 Answers  


how can an indexed file be used as arrival sequence in RPG?

3 Answers   IBM,


What is journalling and commitment control?

3 Answers   IBM,


we are sending data of physical file to screen design and it is showing no record why?

1 Answers   NTT Data,


is this a rpg channel?

0 Answers   IBM,


How can you determine the number of characters in a variable?

3 Answers  


How can we access Interactive job LDA in Batch Job?. and How we can access a file in interactive QTEMP lib in Batch job?.

4 Answers   IBM,


steps involved in debugging and types of debugging modes?

1 Answers  


what is a rpg?

0 Answers   IBM,


suppose we have 10 members in physical file and i have to use 4 out of 10 so how can we read this in RPG

3 Answers   TCS,


1.How you will find the program is batch or online in cl pgm? 2.How you will end the batch pgm when the job runs? write an logic? 3.In wich command the option *drop is used?

2 Answers   TCS,


What are the types of identifiers?

0 Answers  


Categories