Example of DFHNCTR calls with null parameters
If you omit an optional parameter on a DFHNCTR call, ensure that the parameter list is built with a null address for the missing parameter. The example that follows illustrates how to issue, from a COBOL program, an NC_CREATE request with some parameters set to null addresses.
DFHNCTR call with null addresses for omitted
parameters:
In this example, the parameters that are
used on the call are defined in the WORKING-STORAGE SECTION, as follows:
| Call parameter | COBOL variable | Field definition |
|---|---|---|
| function | 01 NC-FUNCTION | PIC S9(8) COMP VALUE +1. |
| return_code | 01 NC-RETURN-CODE. | PIC S9(8) COMP VALUE +0. |
| pool_selector | 01 NC-POOL-SELECTOR | PIC X(8). |
| counter_name | 01 NC-COUNTER-NAME | PIC X(16). |
| value_length | 01 NC-VALUE-LENGTH | PIC S9(8) COMP VALUE +4. |
| current_value | 01 NC-CURRENT-VALUE | PIC S9(8) VALUE +0. |
| minimum_value | 01 NC-MIN-VALUE | PIC S9(8) VALUE +0. |
| maximum_value | 01 NC-MAX-VALUE | PIC S9(8) VALUE -1. |
| counter_options | 01 NC-OPTIONS | PIC S9(8) COMP VALUE +0. |
| update_value | 01 NC-UPDATE-VALUE | PIC S9(8) VALUE +1. |
| compare_min | 01 NC-COMP-MIN | PIC S9(8) VALUE +0. |
| compare_max | 01 NC-COMP-MAX | PIC S9(8) VALUE +0. |
The variable that is used for the null address is defined in the LINKAGE SECTION, as follows:
LINKAGE SECTION.
01 NULL-PTR USAGE IS POINTER.
01 NULL-PTR USAGE IS POINTER.
Using the data names that are specified in the WORKING-STORAGE
SECTION as described, and the NULL-PTR name as described in the
LINKAGE
SECTION, the following example illustrates a call to a named counter-server
where
value_length, current_value, minimum_value
and
counter_options
are
the only optional parameters specified. The others are allowed to
default, or, in the case of trailing optional parameters, omitted
altogether.
NAMED-COUNTER SECTION.
*
SET ADDRESS OF NULL-PTR TO NULLS.
*
MOVE 1 TO NC-FUNCTION.
MOVE 100 TO NC-MIN-VALUE NC-CURRENT-VALUE.
MOVE NC-WRAP TO NC-OPTIONS.
MOVE "DFHNC001" TO NC-POOL-SELECTOR.
MOVE "CUSTOMER_NUMBER" TO NC-COUNTER-NAME.
CALL 'DFHNCTR' USING NC-FUNCTION NC-RETURN-CODE NC-POOL-SELECTOR
NC-COUNTER-NAME NC-VALUE-LENGTH NC-CURRENT-VALUE
NC-MIN-VALUE NULL-PTR NC-OPTIONS.
If
you want to use DCOUNTER instead of COUNTER with DFHNCTR, then you
need to change the NC-CURRENT-VALUE, and the NC-MIN-VALUE and
NC-MAX-VALUE
definitions from signed decimal values (as previously listed) to unsigned
doubleword binary definitions, for example PIC 9(16) COMP. Also,
MOVE
8 to NC-VALUE-LENGTH.