This article explains how you can indicate Enterprise Server to rollback and return output parameters of the operation in progress
Problem:
A container managed service indicates to Enterprise Server to commit or rollback using the feature Application uses RETURN-CODE to indicate success/failure set in the Settings of the service using Interface Mapping Toolkit. Classically, a container managed service, when it rollbacks, does not return to the client consuming this service the output parameters of the operation in progress and an exception is raised on client side. How do you proceed so a container managed service tells Enterprise Server to rollback AND return output parameters of the operation in progress?
Resolution:
Default behavior of a container managed service when it indicates Enterprise Server to rollback is NOT to return the output parameters of the operation in progress. This article explains how you can indicate Enterprise Server to rollback and return output parameters of the operation in progress.
Use the MF API CBL_SRV_SERVICE_FLAGS_SET (Set service execution flags) to indicate Enterprise Server it will have to rollback when the operation in progress terminates and keep the RETURN-CODE returned below the value of the “Maximum success RETURN-CODE” set in the Settings of the service using Interface Mapping Toolkit.
Functions prototype:
CBL_SRV_SERVICE_FLAGS_SET() – Set service execution flags
call "CBL_SRV_SERVICE_FLAGS_SET" using by value service-flags-mask
by value service-flags
returning status-code.
Parameters:
| Typedef | Picture | 
|---|---|
| service-flags-mask | cblt-x4-comp5 pic x(4) comp-5 | 
| service-flags cblt-x4-comp5 | pic x(4) comp-5 | 
On Entry:
service-flags-mask -- Mask that specifies the bit flags to be changed. Use the same bit settings shown in the description of service-flags.
service-flags -- Service control flags.
| Bit | Value | Meaning | 
| 0 | 0 | |
| 1 | Commit transactional resources during successful service termination. | |
| 1 | 0 | |
| 1 | Rollback transactional resources during successful service termination. | 
| Bit | Value | Meaning | 
| 2 - 30 | Reserved for future use. | |
| 31 | 0 | The service has not dirtied the COBOL container. | 
| 1 | The service has dirtied the COBOL container and will result in the SEP being terminated following service termination. | 
On Exit:
       <nothing>
Function returns:
     0          Success.
     1009    Invalid parameter passed to the API.
     1015    Not running within the COBOL container.
     1016    Can only set commit/rollback flags when container managed.
Remarks:
CBL_SRV_SERVICE_FLAGS_SET() is provided to allow a program running within a COBOL container as part of a service to (un)set one or more the service’s execution characteristics.
Examples:
     copy "cblproto.cpy".
     ...
     78 78-SERVICE-FLAG-COMMIT            value h"00000001".
     78 78-SERVICE-FLAG-ROLLBACK          value h"00000002".
     78 78-SERVICE-FLAG-DIRTY-CONTAINER   value h"80000000".
     01 service-flags        pic x(4) comp-5.
     01 service-flags-mask   pic x(4) comp-5.
     ...
     *>
     *> Clear the "rollback" flag.
     *> Set the "commit" and "dirty container" flags
     *>
     compute service-flags-mask = 78-SERVICE-FLAG-COMMIT b-or
                                                        78-SERVICE-FLAG-ROLLBACK b-or
                                                        78-SERVICE-FLAG-DIRTY-CONTAINER
compute service-flags = 78-SERVICE-FLAG-ROLLBACK b-or
                                        78-SERVICE-FLAG-DIRTY-CONTAINER
call "CBL_SRV_SERVICE_FLAGS_SET" using 
                                                                     by value service-flags-mask
                                                                     by value service-flags
Get service execution flags by calling CBL_SRV_SERVICE_FLAGS_GET using reference to service-flags returning status-code.
Parameters:
                     Typedef                                        Picture
                     service-flags cblt-x4-comp5        pic x(4) comp-5
On Entry:
                     <nothing>
On Exit:
service-flags
| Bit | Value | Meaning | 
| 0 | 0 | |
| 1 | Commit transactional resources during successful service termination. | |
| 1 | 0 | |
| 1 | Rollback transactional resources during successful service termination. | |
| Bit | Value | Meaning | 
| 2 - 30 | Reserved for future use. | |
| 31 | 0 | The service has not dirtied the COBOL container. | 
| 1 | The service has dirtied the COBOL container and will result in the SEP being terminated following service termination. | 
Function returns:
                     0                            Success.
                     1015                      Not running within the COBOL container.
Remarks:
CBL_SRV_SERVICE_FLAGS_GET() is provided to allow a program running within a COBOL container as part of a service to determine the service’s execution characteristics.
Examples:
                    copy "cblproto.cpy".
                    78 78-SERVICE-FLAG-COMMIT value h"00000001".
                    78 78-SERVICE-FLAG-ROLLBACK value h"00000002".
                    78 78-SERVICE-FLAG-DIRTY-CONTAINER value h"80000000".
                     01 service-flags pic x(4) comp-5.
                     ...
call "CBL_SRV_SERVICE_FLAGS_GET" using by reference service-flags
if return-code = 0                                                                                  display "Running as a service" upon console
if service-flags b-and 78-SERVICE-FLAG-COMMIT not = 0              display "Service will commit" 
end-if
if service-flags b-and 78-SERVICE-FLAG-ROLLBACK not = 0         display "Service will rollback"
end-if
       if service-flags b-and 78-SERVICE-FLAG-DIRTY-CONTAINER not = 0        display "Service will dirty the container"
end-if
else
display "Not running as a service" upon console
end-if
...
#EnterpriseServer
#Server
#netexpress
#COBOL
#ServerExpress
#Enterprise

