Rational Programming Patterns

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 at different levels (relative to the general processing, relative to the Logical View processing, for the logical access, or for the physical access). This page gives you the general principle for inserting special processing. It also indicates the types of values you can enter under REF= on the lines retrieved from the dialog and server models.

Insertion in a general processing

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

Function code
Create a function by entering a code on two free characters (except 80 and 81).
Level
The only possible level for a function is the hierarchical level 05. Subfunctions 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.
Reference
The reference corresponds to all the elements used to position a subfunction. They must be entered in sequence and they must be introduced by REF=. In this context, the reference corresponds to the type of procedure followed by the action type. The reference is displayed in the right column of the Macro structure code view.
It is used to declare or replace a specific procedure in a Business Component and to identify the Logical View impacted. The instructions must be entered on lower hierarchical level. In the program body or in the performed elementary procedure if several blocks with an 05 hierarchical level are generated:
  • Server initialization,
  • Logical View,
  • Server end.
To add specific procedure, you must identify the position of your procedure relative to one of the blocks, either before or'after, or in replacement of.
Action
  • A: before
  • P: after
  • R: in replacement of.
  • Blank: none.
Type of Processing
Table 1.
Processing (function level) Type Actions
Server initialization BS A, P, R
Logical View vulo * A, P, R, blank
Server end ES A, P, R
SQL declare cursor SQ A, P, R, blank
Table 2.
Processing (function level) Type Actions
SQL WHENEVER statement SQLW A, P, R
SQL DECLARE CURSOR statement SQLD vulo A, P, R
Note: vulo= Logical View code
Examples:
  • BS A
  • vulo R
  • SQLW R
  • ES

Insertion in a Logical View processing

In the Logical View block, either in the program body or on the performed elementary levels, you find all the standard procedures related to the implementation of services in the Logical View. Each one of these standard procedures is associated with only one Logical View. A Logical View processing is inserted after a label that is generated automatically or after a condition. This section presents the principles applied to each service. To add specific procedures to a Logical View, you must first identify it. To do so, create a function with the following information:

Function code
Create a function by entering a code on two free characters (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 code on two free characters.
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 higher than 10.
Reference (REF=)
The reference corresponds to all the elements used to position a subfunction.

REF=TypeProcessing Category Service TrtElémentaire

Examples:
  • REF=CHUP CATA SRVL TRAN
  • REF=CHUP CATT SRVM CHCK
  • REF=SELC CATR $1

You find all the standard procedures related to the implementation of the services for this Logical View, and other information related to the type of processing.

Type of processing
The following table gives you the list of the services that can be inserted at the level of a Logical View. It gives you their characteristics and it indicates the other information to be completed.
Table 3. Type of processing for a Logical View
Type of processing Comment Other information to be indicated
BEGV: Logical View beginning   Type of Insertion
CCNX: Connect to database   Type of Insertion
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 Segment code. Data Element code, Category, Type of Insertion
CHUP: Check or update, check, and update The check or update service processing is used to check the user data, to present the information in the Business Component in the specified format. It is also used to refresh the information by the user input, through database updates. If you insert specific code at a level 10, 15, or 20, , it is used for all the check/update services of the Logical View. It is the most generic specific code. Service, Type of Insertion
CLOS: Close   Type of Insertion
DCNX: Disconnect from database   Type of Insertion
ENDV: Logical View ending   Type of Insertion
LOCK: Lock The Lock/Unlock service blocks the update of a set of data to avoid simultaneous updates. It prevents inconsistency. Type of Insertion
OPEN: Open It opens the indexed files in the View. You must indicate the file code (Data Structure code). Type of Insertion
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 processing type, Category, Type of Insertion
TRDT: Transfer View -> Segment For the transfer of data from the Logical View toward the access Segments. Category, Type of Insertion
TRER:Errors transfer Retrieval of errors when calling a second-level Business Component. You must enter the code of the Segment where the error is detected, in the dedicated field. Segment code , Type of Insertion
TRVW: Transfer Segment -> View The second-level Business Component starts the data transfer from the Segment to the Logical View. Category, Type of Insertion
UNLK: Unlock Insertion of an unlock service in the Business Component. Type of Insertion
USER:User service Possibility for a client component to call a special service (called "User service"), other than a selection or check/update service.
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, Type of Insertion
Service
This option is available only for CHUP (Check/update) or SELC (Selection) type of service. "Check and update" are services in reception. They retrieve the data entered in the client component (with the Logical View) and compare it with the data in the database (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 service, 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 on two characters with the following format: $n (n for numbers from 1 to 0 or letters from A to J).
Elementary processing type
The elementary procedures are started by individual PERFORM from the Logical View level. For CHUP (Check/update) or SELC (Selection) type of processing.
The following table identifies the elementary processing availability for each service type:
Table 4. Elementary processing availability
Generated services None: no elementary processing 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 processing selected. You must then enter a code on two characters with the $n format.
File code
This field is available only for an OPEN or CLOS (Close) access commands. You must enter the code of the file, which consists of the first two characters of the Segment in an S type Screen.
Segment code
The Segment code is required only for the error transfers, when you select the TRER processing. 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 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 service processing) of the Logical View. Enter the code of the Data Element which is checked.
Category
For the CHKD (Check data), CHUP (Check and update), TRVW (Transfer Segment -> View), TRDT (Transfer View -> Segment), and SELC (Select) types of service processing. 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 processing can be. This parameter must be on two characters.
Type of insertion
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. Only for these types of processing: CCNX, CHKD, CLOS, SCNX, OPEN, TRDT, TRER, or TRVW.
Before
Before (ante) the label of the standard procedure.
After
After (post) the standard procedure: before the end label if the hierarchical level is higher than that of the standard procedure, 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 processing. It implies the insertion of the User service processing at the level of the Logical View, in any subfunction which depends on a 05 function.

Insertion at the level of a logical access

You can insert specific processing on a logical access to Segments for check, update, and selection services. To do so, you must indicate the following information:
Function code
Create a function by entering a code on two free characters (except 80 and 81).
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 tree, in the structure code view. 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.
    Example : 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 processing. 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.
REF
The reference corresponds to all the elements used to position a subfunction.

REF=TypeProcessing Segment Category TrtElémentaire

Examples:
  • REF=SLCT SS01 CATR ALIM
  • REF=CHCK SS01
Segment code
Enter the code of Segment on four characters.
Type of processing
In a Logical View processing, there are three possible types of service processing:
  • CHCK : Check related 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 elementary 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 processing type
Select a value
Select an elementary processing (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 processing selected in a format $n.
For the CHKD (Check data), CHUP (Check and update), TRVW (Transfer Segment -> View), TRDT (Transfer View -> Segment), and SELC (Select) types of processing. 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 processing can be. You must enter then two characters.
Insertion type
Read the details on the same field in the previous section Insertion in a Logical View processing. 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

You 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 type of access. You must enter the following information:
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.
Reference 'REF='
The reference is entered for all the elements entered to position a subfunction.
  • REF=Segment EX ExtractionMethod
  • Or REF=Segment TypeAccess
Examples:
  • REF=SS11 EX method1
  • REF= SS11 OP
  • REF=SS11 $1
In cases where servers are called, the reference is:
  • REF=Segment TypeGeneralProcessing with
    • TypeGeneralProcessing = R1 forALIM
    • TypeGeneralProcessing = R2 for CALL
    • TypeGeneralProcessing = R3 for RETC
Examples: REF=SS11 R1
Segment code
Enter the code of the accessed Segment in four characters. For customized SQL accesses, it is the code of the relational table Segment.
Extract method
Enter the name of the extraction method (in uppercases) if selection criteria are to be taken into account.
Type of access
To replace a standard subfunction. If the Segment code is followed by the type of access, only the subfunction corresponding to the type of access is replaced. If the type of access is not specified, all the subfunctions with an access to the Segments are replaced.
Select a value
Select a standardly generated type of access, 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
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 type of access, 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 insertion 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)