Rational Programming Patterns for System z

Insertion of specific code in a Macro

You can insert specific code in a Macro which is called in a Business Component of server type. To do so, you must open the Macro in a PDP Macro editor in a server model. Then, you can use the insertion wizards which help you insert specific code at different levels of the Business Component (in the general process, in the Logical Views, in the Logical access, and the physical access).

Insertion at the level of a general process

This option corresponds to the insertion relative to the 05 hierarchical level processing

Function code
Create a function by entering two characters for the code, free (except 80 and 81).
Subfunction code
This field is active when you select SQL WHENEVER order ou DECLARE CURSOR order. The code of the subfonction must be entered to implement SQL accesses ain the Business Component. You must enter two characters.
Level
The only possible level for a function is the hierarchical level '05'. Subfonctions have a default level '10'. This field is active for the SQL WHENEVER order or DECLARE CURSEUR order options and if the action type selected is 'Before' or 'After'. In this case, you can enter a level from 06' to '98'.
Block
Check one of the block option:
  • Server initialization,
  • Logical View,
  • Server end.
  • SQL declare cursor.
Server initialization
This block retrieves the information contained in the communication area and carries out initializations.
Logical View
If you check Logical View, you must enter the Segment code to position the procedure in the Logical View.
Server end
This block returns the information to the Services Manager. If you check this option, the Business Component's specific procedure is always inserted at the end of a standard procedure.
SQL declare cursor
This block describes the clauses required for the SQL declarations (WHENEVER and DECLARE CURSOR).
Segment code
This field is active for a Logical View block selected. Enter the code of the Logical View (4 characters maximum) affected by the specific procedure. The code is used to identify the position of your insertion relative to the standard processing.
Traitements (niveau sous fonction)
With relational databases, you can customize SQL accesses in order to add or replace clauses in a standardly generated access or create a new physical access; ot to take into account the selection criteria used by an extraction method. In any case, to implement these types of accesses in the Business Component, you must create a sub-function in function 80. You must enter a code and a hierarchical level for this subfunction. Select SQL WHENEVER order or DECLARE CURSEUR order.
Table code or SQL view
This field is active if you select Ordre DECLARE CURSEUR only. You must enter the code of the relational table Segment or the code of the customized access to be taken into account.
Action type
Specific code must be inserted in the automatic functions, relatively to one of the Block selected in the Block field of the wizard, either before, after, or in replacement of a standard procedure.

Insertion in a Logical View process

The wizard which opens when you select Insertion in a Logical View process is used to insert specific procedures in the elementary procedures called by PERFORM. The insertion of specific procedure is done just after the tag which is automatically generated.

Function code
To add specific procedures to a Logical View, you must first identify it. To do so, create a function by entering: a two character code, free (except 80 and 81).
Subfunction code
You position each specific procedure to be added, relative to a standard procedure of the Logical View. Create a subfunction, defined by a two character code, free.
Level
Indicate a hierarchical level equal to or greater than the level of the standard procedure, necessarily higher than 05 and lower than 99. For a LOCK service, it must be necessarily higher than 10.
Process type
You find all the standard procedures related to the implementation of the services for this Logical View. Select the type of process relative to a standard procedure of the Logical View. Each of these standard procedures is associated with only one Logical View. When you select some of the processes, other fields are activated in the wizard. You must complete the options required for each type of process. The following table gives you the list of the processes which can be inserted at the level of a Logical View. It gives you their characteristics and it indicates the other fields which must be completed.
Table 1. Process type
Process type Comments Other fields to complete
BEGV: Logical View beginning   Insert type
CCNX: Connect to database   Insert type
CHKD: Check data A check service is needed when you want to check only the data entered by the user and to send him/her an error message if the value entered is incorrect. The data in the Logical View is not transferred to the database. The check and update service performs the data transfers from the Segment to the Logical View. The Segment used as reference for the check must be associated with the Logical View, so you must indicate the code of the Segment. Data Element code, Category, Insert type
CHUP: Check or update, check and update The check or update processing is used to check the user data, to present the information in the Business Component in the specified format, and to refresh the information by user input, through database updates. If you insert specific code at this level, it is used for all the check/update services of the Logical View. It is the most generic specific code. Service, Insert type
CLOS: Close   Insert type
DCNX: Disconnect from database   Insert type
ENDV: Logical View ending   Insert type
LOCK: Lock The Lock/Unlock service helps you to prevent the update for a set of data to avoid simultaneous update, that is to avoid inconsistency. Insert type
OPEN: Open Open indexed files in the View. You must indicate the file code (Data Structure code) in the dedicated field of the wizard Insert type, File code
SELC: Selection To replace the selection processing service on the Logical View in the category of your choice. You must also choose the type of service and the type of elementary processing. Service, Elementary process type, Category, Insert type
TRDT: Transfer View -> Segment For the transfer of data from the view toward the access Segments. Category, Insert type
TRER: Errors transfer Retrieval of errors during the call of a second-level Business Component. You can enter the code of the Segment where the error is detected, in the dedicated field. Segment code, Insert type
TRVW: Transfer Segment -> View The second-level Business Component starts the data transfer from the Segment to the Logical View. Category, Insert type
UNLK: Unlock Insertion of a lock service in the Business Component. Insert type
USER: User service Possibility for a client component to call a special service (called 'User service'), other than a selection or check/update service (for example: counter to count the number of customers per day who have issued an order, print service). The Business Component retrieves, through the communication area, the name, and code of the User service called by the client component. User service code, Insert type
Service
This option is available only if you have selected CHUP (Check/update) or SELC (Selection) in the previous field Process type. 'Check and update' are services in reception. They retrieve the data entered in the client component (with the Logical View) and compare it to the data in the base (with a Segment) for check or update.
Select a value
For a check/update service, you can select one of the following services:
  • SRVE: Check service,
  • SRVL: Read service,
  • SRVM : Check/Update* service,
  • SRVT: Check/update/selection service,
  • SRVX : Check/selection service.
* For a Selection process, the only possible service is SRVA: Selection service.
Parameter
You can define a parameter for the service selected to identify this service in several servers for example. You can enter a parameter with a code made of two characters with the following format: $n (n being numbers from 1 to 0 or letters from A to J).
Elementary process type
The elementary procedures are started by individual PERFORM from the ‘Logical View' level. This field is displayed if you have selected CHUP (Check/update) or SELC (Selection) in the previous Process type field .
Select a value
The choices in this field are available only for a CHUP or 'SELECT' process. Moreover, they can be different from one service selected to another for a 'CHUP' process. The following table identifies the elementary process availability for each type of services selected:
Table 2. Elementary process availability
Generated services None: no elementary process INIT: initialization CHCK: check TRAN: transfer UPDT: update DONE: end SELC: selection
SRVE: Check service * * *     *  
SRVL: Read service * * * *   *  
SRVM: Check/update service * * * * * *  
SRVT: check / update and selection service * * * * * *  
SRVX/ Check/selection service * * *     *  
SRVA: Selection service * *   *   * *
None * * *   * *
Parameter
A parameter can be defined for the elementary process selected, you must then enter a code in two characters with the $n format.
File code
This field is available only for an 'OPEN' or 'CLOS' (Close) process. You must enter the code of the file, which consists of the first two characters of the Segment in a 'S' type Screen.
Segment code
The Segment code is required only for the error transfers, when you select the 'TRER' process. You must enter the code of the Segment where the error is detected in four characters.
User service code
This field is available only for a user process (User service). You must enter the code of the User service with a maximum number of 25 characters.
Data Element code
This field must be completed for data check on the Data Elements ('CHKD' process) of the Logical View. Enter the code of the Data Element which is checked.
Category
The choices available in this field are dedicated to the 'CHKD' (Check data), 'CHUP' (Check and update), 'TRVW' (Transfer Segment -> View) and 'TRDT' (Transfer View -> Segment) and SELC (Select) types of process. Select a 'category' among the following ones:
  • Initialization,
  • Iterative, for a multi-occurrence Logical View, the 'category' performs an iterative access to the records.
  • End.
You can however enter a parameter for a 'category' whatever the process can be. You must enter then two characters in the input field associated to the Parameter check box.
Insert type
Then, for each specific procedure to be inserted, you specify the procedure relative to a standard procedure of the Logical View by using a specific structure:
Begin
at the beginning of a standard procedure, just after the beginning tag. This setting is possible for performed procedures only. The choice is available only for the following selected types of process: 'CCNX', 'CHKD', 'CLOS', 'SCNX', 'OPEN', 'TRDT', 'TRER' or 'TRVW'.
Before
Before (ante) the tag of the standard procedure.
After
  • After (post) the standard procedure: before the end tag, if the hierarchical level is higher than standard procedure's,
  • or just after the end tag, if the hierarchical level is equal to that of the standard procedure
Replace
in replacement of the standard procedure.
Insert
This choice is specific to the User service process. It implies the insertion of the User service process at the level of the Logical View, that is to say, in any subfunction which depends on a 05 function.

Insertion at the level of a logical access

Function code
Enter a code in two free characters (except 80 and 81) to create a function.
Subfunction code
Enter the code of the subfunction in two characters. It can be constituted of letters or numbers. This code determines the position of the source lines in the function.
Level
The level is used to set a hierarchy between subfunctions in a function. A subfunction is lower than another one if its level number is higher. The level of a function and a subfunction is identified by a blue number in the Macro tags tree. It is displayed at the level of the function line in the tree. The possible values for each level are the following ones: :
  • 05: default level for all functions.
  • 10: default level for a subfunction.
  • 06 - 98: possible levels for a subfunction. A subfunction is lower than another one if its level number is higher.
    Note: In a function, a subfunction with a level 15 is dependent on the subfunction with a level 06 - 14 which precedes it.
  • 99: this level is dedicated to the elementary processes. It is used to write a condition with no use of creating a subfunction. This level can contain no more than 75 lines. A subfunction is limited to 98 of this level.
A subfunction is run only if all the functions and subfunctions which it depends on are run.
Segment code
Enter the code of Segment in four characters.
Process type
In a Logical View processing, there are three possible process types:
  • CHCK: Check, relative to:
    • the level 10 for check/update service,
    • the level 15 for check/update processing by 'category'
    • the level 20 for check/update processing by 'category' and service type
  • SLCT: Selection relative to:
    • the level 10 for the access to a Segment for data selection,
    • the level 15 for the access to a Segment for data selection by 'category',
    • the level 20 for the access to a Segment for data selection by category and elementary service type.
  • UPDT: Update, relative to:
    • the level 10 for the access to a Segment for data check and update,
    • the level 15 for the access to a Segment for data check and update by 'category',
    • the level 20 for the access to a Segment for data check and update by 'category' and elementary service type.
Elementary process type
Select a value
Select an elementary process (ALIM for key loading, CALL for the call of physical processing, or ERRS for error handling.
Parameter
You can enter a parameter for the elementary process selected in a format $n.
Category
Read the details on the same field in the previous section 'Insertion in a Logical View process'.
Insertion type
Read the details on the same field in the previous section 'Insertion in a Logical View process' The level 10 is not required for 'before' and 'after' types for the logical access to Segments.

Insertion at the level of a physical access

The wizard Insertion at the level of a physical access is used to enter specific code in the Segment logical access. Physical accesses are generated in function 80.
Note: The physical accesses to data make up a third processing level. A physical access is performed for each Segment logical access. The generated physical access depends on the constant data storage structure. Changing the physical storage mode of data does not modify the logical structure of the Business Component.
The function 80 of the Business Component is structured in subfunctions: one subfunction per Segment and per access type.
Function code
The first two characters of the function are 80.
Subfunction code
To create a subfunction 80, enter two non-numerical characters.
Level
Enter a 10 hierarchical level, identical to that of the standardly generated subfunction.
Segment code
Enter the code of the accessed Segment in four characters. For customized SQL accesses, the code is the relational table Segment's.
Extract method
Enter the name of the extraction method (in uppercases) if selection criteria are to be taken into account.
Access type
To replace a standard subfunction, if the Segment code is followed by the access type, only the subfunction corresponding to the access type is replaced. If the access type is not specified, all the access subfunctions to this Segments are replaced.
Select a value
Select a standardly generated access type, if you want to complete it with a customized access. With relational databases, you can customize SQL accesses in order to:
  • Add or replace clauses in a standardly generated access or create a new physical access.
  • take into account the selection criteria used by an extraction method.
Values for calling server
Check the option to be able to select the type of general processing:
  • ALIM: Loading before call, for loading of communication area,
  • CALL: Call server, for the call of Business Component,
  • RETC: Return after call server, for processing at the Business Component return.
Parameter
You can enter a parameter for the access type, to do so, enter two characters in the $n format.
Action type
Specific procedure in function 80 is inserted by relative positioning: with a Replace structure type, to replace a standard subfunction, with an Insert structure type, to complete or create an SQL access.

Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)