Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 21 Coding TIBCO Object Service Broker Access Statements : Coding Considerations

Coding Considerations
When coding your access statements, you must take into account the differences between COBOL and the TIBCO Object Service Broker rules language. For example:
Valid TIBCO Object Service Broker names could be invalid in COBOL. For example, table.field names are invalid in COBOL.
Naming Differences Between TIBCO Object Service Broker and COBOL
The preprocessor creates COBOL names for each field by combining the table and field names with a hyphen. COBOL does not allow special symbols in table, field, and parameter names.
TIBCO Object Service Broker table and field names used in conjunction with a joining period (.) can have a maximum of 33 characters, but COBOL names can have a maximum of only 30 characters. The 30 character limit in COBOL is a result of the way that the preprocessor assigns COBOL names to TIBCO Object Service Broker fields (the TIBCO Object Service Broker identifier is two names and a separator while the COBOL identifier is a single name).
How to Rename TIBCO Object Service Broker Names to Valid COBOL Names
Use the Define Table statement in the Working Storage Section of your program to rename TIBCO Object Service Broker tables, fields, and parameters to valid COBOL names. You must assign valid names to TIBCO Object Service Broker invalid table, field, and parameter names in your table regardless of whether you refer to them or not.
You can assign alternate COBOL names for TIBCO Object Service Broker tables, fields, or parameters even though they are valid in COBOL. For example:
$ Define Table Employee = #ED_EMPLOYEES
$ Parameter USER-ID = USERID,
$ LOCATION-PARM = LOCATION,
$ Field mgrno = MGR#,
$ zipcode = P_CODE;
Coding Conventions
 
Unless the next declaration starts with a keyword such as PARAMETER or FIELD, each declaration must end with a comma (,).
Modifying the Join Character for Table.Field Names
Unlike the rules language, which uses a period (.) as the joining character to identify a table and field specification, TIBCO Object Service Broker access statements use a hyphen (-) to make them usable by COBOL. For example:
Employee.lname
is valid in the rules language, and
Employee-lname
is valid in a TIBCO Object Service Broker access statement.
Use the COBOL form to identify table and field specifications in TIBCO Object Service Broker access statements as well as in COBOL statements. For example, to specify this table and field in the Procedure Division, type:
DISPLAY EMPLOYEE-LNAME.
Checking TIBCO Object Service Broker Runtime Errors
You can check for TIBCO Object Service Broker access errors in the following variables:
Contains 0 if the statement was successful, or 4 if the end of the table was encountered.
An end-of-table is encountered when the FORALL action statement cannot return any more occurrences that satisfy the selection criteria. Any other code indicates an error. Refer to the entry HLL-RETURN-MESSAGE for more information.
Coding Operators and Expressions
In COBOL, blanks must be inserted between an operator or expression and a variable. In TIBCO Object Service Broker, blanks are optional. The following example shows a valid selection in the access statement:
$ Forall Employee(USER-ID-77,LOCATION-77)
$ where mgrno = 84021 :
An expression must be a valid COBOL expression. Since a parameter expression is considered a literal expression in COBOL, you cannot use a parameter with a non-numeric literal with a length of zero. An expression like:
$ GET employee(' ') where salary> 800
is not valid. The following example shows a valid GET statement that you can code in your access statement:
$ GET employee where salary > 400
Embedding TIBCO Object Service Broker Action Statements
You can embed the following TIBCO Object Service Broker action statements in your COBOL program:
In addition, the GETFIRST and GETNEXT statements are also supported. GETFIRST and GETNEXT work together to retrieve occurrences from a table within a COBOL looping structure.
GETFIRST Statement
The GETFIRST statement retrieves the first occurrence of a set of occurrences that meet the selection criteria, if any. The syntax is:
GETFIRST tablespec [ WHERE selection ] [  ORDERED [ ASCENDING / DESCENDING‑] field ] ;
where:
Optional field whose values determine the order of the occurrences. The table can be ordered according to more than one field if you join the ORDERED clauses with the logical operator AND (&).
For example:
GETFIRST #ED_EMPLOYEES WHERE MGRNO = 79912 ORDERED ASCENDING LNAME;
This puts the occurrences in the order of ascending values in the LNAME field, and retrieves the first occurrence where the MGRNO field of the #ED_EMPLOYEES table is 79912. Other occurrences where the MGRNO field is 79912 are held in the same order for the GETNEXT statement.
GETNEXT Statement
The GETNEXT statement retrieves subsequent occurrences of a set of occurrences specified by the GETFIRST statement. The syntax is:
GETNEXT table;
table is the name of the table specified in the GETFIRST statement. You must include parameter values if the table is parameterized. An example of a valid GETNEXT statement is:
GETNEXT #ED_EMPLOYEES;
If this statement appears after the example for GETFIRST, it retrieves the next occurrence from the #ED_EMPLOYEES table where the MGRNO field value is 79912.
See Also
TIBCO Object Service Broker Programming in Rules about the rules language and rules processing behavior.

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved