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?



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

purpose of pannel group??/

2 Answers   CTS,


Can anybody tell me that why we use option(*nodebugio)in H- Spec?

3 Answers  


1.Suppose my file has 10 fields and I want to make the 2nd field Zeros in all records. And assume I have millions of records and I dont want to read each record and update the desired field with 0. Any other way to do this in one step operation? 2. Assume my file has 100 records and I want to see only first 10 records. Is this possible through LF? 3.I have 3 jobs A B and C. I want to submit B after successful completion of A and want to submit C after successful completion of B. Without using job scheduler or job queue, how can i do that through CL program? 4.What is difference between Bind by copy and bind by reference?

4 Answers   Virtusa,


If record-format name in an externally-described file has already been defined as a file-name.how to solve this?

2 Answers   CTS,


I have one cl program which calls two rpg programs named a & b. I am loading a run time array in Pgm A and the control comes back to cl pgm. i call pgmb and I want to read the runtime array in pgmb which was loaded in pgma. How it can be acheived. I should not use any intermediate file or dataarea to store the loaded values.

2 Answers  


list down and describe the sub systems vailable

5 Answers   IBM,


How can we receive values from a called procedure in RPG?

1 Answers  


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

1 Answers  


what do you mean by SESSION/DEVOCE ERROR?

1 Answers   IBM,


How can we make use of SETLL operation in CL?

11 Answers  


how to find whether a date format is valid or not in RPG400 not in RPGILE.Can you please write the coding for this sir,i'm new to AS400.Please help.

1 Answers  


how can we can we the data decimal error?how can we open such file in support

1 Answers  


Categories