Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

how does the rpg element work?

1293


write an RPG program to calculate the marks of 5 students (A,B, C, D, E)in 3 different subjects (eng, math, sci) an display on the screen

1354


What is the diff bw PF/LF Name and their Record format name? what is restriction in record format then file name?

3046


Suppose we have one database file and it is used by 5 programs and in 3 program we have to add some records in datbase file s what is the impact on other program?

1971


If my rpg program has a date field, what extra care I have to take while compiling that rpg program? 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?

1163


how can you display specific subfile page on the screen in unequal subfile?

1200


Program to read marks of 10 students for 4 subjects and compute and display total marks and status of each student in rpg

1204


How to declare the pull button in AS/400..

2385


1. If there are two programs using same file and 2 users are using the file at the same time and what can be done to allow them both to access? 2. How can remove lock from the file for accessing it by both users?

1001


How to create a login screen using a command instead of display file.... intention is to get a password field on a command..... how do you achieve this...

1937


during execution, an rpg/400 program automatically follows a sequence of operations for each record that is processed. The built-in program cycle includes the following logical steps.

1279


What is the purpose of record level identifier?

1169


what is an online rpg?

1321


how do I declare a minor?

1207


What is the difference between copybooks and subprocedures in as400?

1406