Sign in

docs ILE Concepts

Binder Language Example 4

Binder Language Example 4

After shipping the updated FINANCIAL service program, you receive a request to create an interest rate based on the following:

  • The current parameters of the Rate procedure
  • The credit history of the applicant

A fifth parameter, called Credit_History, must be added on the call to the Rate procedure. Credit_History updates the Interest_Rate parameter that gets returned from the Rate procedure. Another requirement is that existing ILE programs or service programs that use the FINANCIAL service program must not have to be changed. If the language does not support passing a variable number of parameters, it seems difficult to do both of the following:

  • Update the service program
  • Avoid re-creating all the other objects that use the FINANCIAL service program

Fortunately, however, there is a way to do this. The following binder language supports the updated Rate procedure. It still allows existing ILE programs or service programs that use the FINANCIAL service program to remain unchanged.

FILE: MYLIB/QSRVSRC  MEMBER: FINANCIAL
 
STRPGMEXP  PGMLVL(*CURRENT)
  EXPORT SYMBOL('Term')
  EXPORT SYMBOL('Old_Rate')  /* Original Rate procedure with four parameters */
  EXPORT SYMBOL('Amount')
  EXPORT SYMBOL('Payment')
  EXPORT SYMBOL('OpenAccount')
  EXPORT SYMBOL('CloseAccount')
  EXPORT SYMBOL('Rate')           /* New Rate procedure that supports +
                                     a fifth parameter, Credit_History */
ENDPGMEXP
 
STRPGMEXP  PGMLVL(*PRV)
  EXPORT SYMBOL('Term')
  EXPORT SYMBOL('Rate')
  EXPORT SYMBOL('Amount')
  EXPORT SYMBOL('Payment')
  EXPORT SYMBOL('OpenAccount')
  EXPORT SYMBOL('CloseAccount')
ENDPGMEXP
 
STRPGMEXP  PGMLVL(*PRV)
  EXPORT SYMBOL('Term')
  EXPORT SYMBOL('Rate')
  EXPORT SYMBOL('Amount')
  EXPORT SYMBOL('Payment')

The original symbol Rate was renamed Old_Rate but remains in the same relative position of symbols to be exported. This is important to remember.

A comment is associated with the Old_Rate symbol. A comment is everything between /* and */. The binder ignores comments in the binder language source when creating a service program.

The new procedure Rate, which supports the additional parameter of Credit_History, must also be exported. This updated procedure is added to the end of the list of exports.

The following two ways can deal with the original Rate procedure:

  • Rename the original Rate procedure that supports four parameters as Old_Rate. Duplicate the Old_Rate procedure (calling it Rate). Update the code to support the fifth parameter of Credit_History.

  • Update the original Rate procedure to support the fifth parameter of Credit_History. Create a new procedure called Old_Rate. Old_Rate supports the original four parameters of Rate. It also calls the new updated Rate procedure with a dummy fifth parameter.

    This is the preferred method because maintenance is simpler and the size of the object is smaller.

Using the updated binder language and a new RATES module that supports the procedures Rate, Term, and Old_Rate, you create the following FINANCIAL service program:

Figure 1. Updating a Service Program by Using the Binder Language

The ILE programs and service programs that use the original Rate procedure of the FINANCIAL service program go to slot 2. This directs the call to the Old_Rate procedure, which is advantageous because Old_Rate handles the original four parameters. If any of the ILE programs or service programs that used the original Rate procedure need to be re-created, do one of the following:

  • To continue to use the original four-parameter Rate procedure, call the Old_Rate procedure instead of the Rate procedure.
  • To use the new Rate procedure, add the fifth parameter, Credit_History, to each call to the Rate procedure.

When an update to a service program must meet the following requirements:

  • Support a procedure that changed the number of parameters it can process
  • Allow existing programs and service programs that use the changed service program to remain unchanged

the following steps need to be performed:

  1. Duplicate the STRPGMEXP, ENDPGMEXP block that contains PGMLVL(*CURRENT).

  2. Change the duplicated PGMLVL(*CURRENT) value to PGMLVL(*PRV).

  3. In the STRPGMEXP command that contains PGMLVL(*CURRENT), rename the original procedure name, but leave it in the same relative position.

    In this example, Rate was changed to Old_Rate but left in the same relative position in the list of symbols to be exported.

  4. In the STRPGMEXP command that has PGMLVL(*CURRENT), place the original procedure name at the end of the list that supports a different number of parameters.

    In this example, Rate is added to the end of the list of exported symbols, but this Rate procedure supports the additional parameter Credit_History.

  5. Save the changes to the binder language source file.

  6. In the file containing the source code, enhance the original procedure to support the new parameter.

    In the example, this means changing the existing Rate procedure to support the fifth parameter of Credit_History.

  7. A new procedure is created that handles the original parameters as input and calls the new procedure with a dummy extra parameter.

    In the example, this means adding the Old_Rate procedure that handles the original parameters and calling the new Rate procedure with a dummy fifth parameter.

  8. Save the binder language source code changes.

  9. Create the module objects with the new and changed procedures.

  10. Create the service program from the new and changed modules using the updated binder language.