PARMEVAL (RPGLE)

Parameter Evaluation
Details ....

Copybooks  

PARMEVAL_H
Parameter Evaluation Prototype

Procedures  

evalParmexported
Parameter Evaluation

Detailed Description  

Compressing Selection

Most people are familiar with this concept when it comes to unix / linux / IFS file permissions. Each permission has its own number.

Now all, some or no permissions can be put — compressed — to one value. For example:

# create file
touch /tmp/my_file.txt

# set permissions:
# 7 = all for owner
# 5 = read/execute for group
# 5 = read/execute for other

chmod 755 /tmp/my_file.txt

Passing multiple selections

The i5/OS API Retrieve Job Information can be used to retrieve the library list of the job. The library list is divided in various sections: System, Product, Current, User. If a procedure should return all or only some parts of the library list then multiple selections may be passed to that procedure. These selections could be coded as constants.

Such a procedure call would look like this:

 
D SYSTEM_LIBS...
D C 1
D PRODUCT_LIBS...
D C 2
D CURRENT_LIB...
D C 4
D USER_LIBS...
D C 8

/free
...

listJobLibraryList(qualified_job_name : SYSTEM_LIBS + USER_LIBS);

...
/end-free

Much easier to read and understand.

Selection Evaluation

Now that procedure has to know what part of the library list the calling program wants to have retrieved. A data structure with the possible selections is created with an overlay alpha field.

 
DlistSections...
D DS qualified
D system N
D product N
D current N
D user N
D allSections 4A overlay(listSections)

With the procedure evalParm the data structure gets filled with the following call:

 
/free
...

// userSelection contains the value SYSTEM + USER = 9
// evalParm returns : '1001'
listSections.allSections = evalParm(userSelection);

...
/end-free

Keep in mind that the constants (and parameter for the evalParm procedure) value must be a number of the power of 2 (1, 2, 4, 8, 16, 32, 64, ...).

Author:
Mihael Schmidt
Links:
http://www.rpgnextgen.com
http://www.gnu.org/licenses/lgpl.html
http://www.rpgnextgen.com/downloads/parm01.rpgle

Procedure Documentation  

evalParm  

characterevalParm(integer)
This procedure checks the passed number which combination of power of 2 numbers are added. It iterates through all numbers which may be inside the passed number and returns for each a 1 or 0.

Example: 13
  • 1 = 1
  • 2 = 0
  • 4 = 1
  • 8 = 1
For 13 it would return the string '1011'.
Parameter:
numeric (integer) (10)   constCombination of power of 2 numbers
Return value:
character (100)Evaluated parameter string (as varying)
Exported.
Author:
Mihael Schmidt
Date:
21.04.2008