How MODELRSP uses SPAREA fields

This section explains how MODELRSP uses the return code, status, and message fields. See Appendix F, “The SPAREA” for detailed information on all SPAREA fields.

SPRC

The SPRC (return code) field communicates the success or failure of an RSP command.

NoteYour code should check the SPRC field after issuing any RSP command.

The following MODELRSP code fragment shows how an RSP accesses the SPRC field to get this information:

IF SPRC IS NOT EQUAL TO '000'
 MOVE WS-CLOSPIPE         TO ERROR1-CALL
 PERFORM 9800-PIPE-ERROR-MSG THRU 9800-EXIT
 GO TO 9999-RETURN-TO-CALLER.

SPSTATUS

The SPSTATUS field communicates processing status in the remote database to the RSP. As shown in the following MODELRSP code fragment, the RSP also uses the SPSTATUS field to communicate status on its own processing to the client application.

MOVE ‘OK’ TO SPSTATUS.
CALL ‘STATUS’ USING SPAREA.

SPMSG

The SPMSG field communicates messages back to the client application. Then the SPAREA issues the RSP MESSAGE command as shown in the following modified MODELRSP code fragment:

 MOVE SPRC                    TO ERROR1-SPRC.
     MOVE ERROR1-MSG              TO SPMSG.
     MOVE 'E'                     TO SPSTATUS.
    CALL 'MESSAGE' USING SPAREA.

In this case, the client application receives the error message in SPMSG.

You can issue the MESSAGE command with message text of up to 100 bytes with USING SPAREA:

MOVE 'OK'                      TO SPSTATUS.
MOVE 'THIS IS THE OK MESSAGE'   TO SPMSG.
CALL 'MESSAGE' USING SPAREA.

Refer to Appendix A, “RSP Commands” for detail about the MESSAGE command.