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 |
How to define data area in RPG program? In which scenario multi occurrence DS is use in AS400?
Can we journel logical file and access path? Can we use commitment control for non-join L.F?
How can we override a file during runtime in RPG? Without using OVRDBF or calling a CL program
What is journalling and commitment control?
1.I have a Batch job, Running for 4 hours, i want to reduce the executing time to 2 hours what should you do?
i 'm new to as/400.in an interview i was asked this question.give a practical example for passing information or data through local data area. I know only that data area is an object used to store tiny bits of data or it can store one value at a time and it is used to store frequently changing values or datas.thats all i know about data area can any one tell me how local data area and user defined data area are used to pass data between jobs with a example or coding.thanks in advance.
are there any useful c runtime apis that I can call from rpg iv?
Anyone help me for the below question:- If problem/error occur in *PSSR subroutine,how should I handel it in RPG program.
Can we create 300 logical files based on a single physical file using the CRTLF command only once?.
What is the difference between ITER and DO ? I know both are used to execute set of statements repeatedly, but what is the main difference?
What will happen if we r using seton lr after return or vice versa.
Program to read marks of 10 students for 4 subjects and compute and display total marks and status of each student in rpg