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

I have a PF(ABC)with no key fields. PF(ABC)have 2 fields (cusno and cusname). Please let me know how can i read the cusno = 1150 directly from PF in CL and RPG program(Without creating the LF and without reading the complete file and then compare 1150)

3 Answers   Opus,


what is the use of sflnxtchg?

0 Answers   IBM,


Job is in MSGW while reading the input file and writing a new record / updating a reacod due to Duplicate data error. What action would you take ( C D I R )...?

4 Answers  


In how many ways a session/device error occurs,,, and what is the remedy for it?

3 Answers  


How do you proceed in case your active AS400 session has got disconnected suddenly, how can you get back to your session ? Is it possible??

1 Answers  






What is the purpose of Panel Groups?

4 Answers  


1.How to read a subfile in out put mode? 2.what are the keywords used to share same file? 3.using composite key which rpg code used?

3 Answers   HSBC,


give an eg of ACQ-(ACQUIRE),BIT OFF,BIT ON,DEALLOC,DUMP,FEOD,FORCE,MHHZO,MHLZO,MHLLZO,MLHZO,REL,RESET,TESTZ,TESTB,TESTN----GIVE SMALL EXAMPLE TO THE OPCODES...TO UNDERSTAND FUNCTIONING...........

0 Answers   CTS,


how we retrieve records without using key field (ex:name) from Physical File through RPG in as/400?

8 Answers  


how does the rpg element work?

0 Answers   IBM,


what is the rpg system?

0 Answers   IBM,


IN RLU what are the record level keyword is used?

5 Answers   iGate, TCS,


Categories