can any body correct the following code?
Following a procedure which returns the maximum of two
numbers.Correct the following code.

P GETMAX B
D GETMAX PI
D NUM1 35 0
D NUM2 45 0
C IF NUM1 > NUM2
C RETURN NUM1
C ELSE
C RETURN NUM2
C ENDIF
P GETMAX E



can any body correct the following code? Following a procedure which returns the maximum of two n..

Answer / vijay

to send a return value, you have to defined the return variable in front of PI which actually contain the return value the code should be as follows

P GETMAX B
D GETMAX PI 45 0
D NUM1 35 0
D NUM2 45 0
D rtnfld 45 0
C IF NUM1 > NUM2
C Eval rtnfld = Num1
C ELSE
C Eval rtnfld = Num2
C ENDIF
C Return rntfld
P GETMAX E

Is This Answer Correct ?    7 Yes 1 No

Post New Answer

More RPG400 Interview Questions

How do you code file / field renames in ILE RPG?

4 Answers   Accenture, IBM,


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?

0 Answers  


can i use unique key in LF

3 Answers   TCS,


We have a Physical file, after reading 5 records,it has to read LF of that same Physical file,Will it start reading from Ist record or will start reading from 5th record?

5 Answers   Hexaware,


how can we know running job is batch or intractive ? i need all the possibilites.........plz help me

3 Answers   HSBC, IBM,






difference between 1:%found and %equal built function in detail with example .

6 Answers   Polaris,


I am reading a file in CL program. and MONMSG CPF0864 has arrived means EOF has arrived. Now i want to read this file again. How i can do this?

5 Answers   CitiGroup, Symphony,


1.Where we declare Variables in RPG/400,RPGIV,RPGILE.? 2.When do we use D-spec and I-spec in real time ?.what is difference between them?

1 Answers   HP,


how do I declare a minor?

0 Answers   IBM,


if i have three programs progA,progB and progC .now i call progB from progA. but the progB does not exist . now i want to call progC instead of starting dump. how can we achieve this.

10 Answers   Four soft,


if there is a module object , how to find the program object for this module object.Assume the module object name and program object name is not same.

0 Answers  


i have 1000 records in pf.what are all the ways to read a particular name records in rpg?? ie.. in pf i have a name called demo appeared around 52 times hw will we read this particular records in rpg/400?.

11 Answers   IBM,


Categories