PMS Information Systems
Welcome to PMS Information Systems - IBM i (AS/400) Forum !!!

Get Answers for all your queries on IBM i (AS/400).

Name the Indicators - Tip4

View previous topic View next topic Go down

Name the Indicators - Tip4

Post  maran on Thu Feb 09, 2012 12:10 pm

If a subprocedure returns an indicator, we can use it as a simple boolean.

For example, suppose we have a subprocedure that returns an indicator that is true if a transaction is valid. In essence it might look something like this:

p ValidTransaction...
p b
d pi n
d accountNo 5s 0
d transData LikeDS(transDetails)

d validTrans s n inz

/free
// Perform assorted validation tasks and set validTrans true
// if the transaction is valid

Return validTrans;

/End-free

p ValidTransaction...
p e

Since the subprocedure returns an indicator value, we can use it like this:

If ValidTransaction( accountNo : transDetails );
// process transaction
Else;
// issue error message etc.
EndIf;

A knowledge of the way indicators work in RPG IV can make our programming life easier, and our programs easier to understand for those that come after us.
avatar
maran
Admin

Posts : 442
Join date : 2009-07-24

View user profile http://pmsinformationsystem.forumotion.net

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum