(check the CICS link for more informtion on RSP)
LINKAGE SECTION.
01 DFHCOMMAREA.
COPY SPAREAC.
01 LK-INPUT-PIPE PIC X(100).
01 LK-RETURN-PIPE.
05 LK-RPLY-SEND-AREA PIC X(200).
PROCEDURE DIVISION.
PERFORM OPEN-INPUT-PIPE THRU OPEN-EXIT
PERFORM GET-INPUT-PARM THRU GET-INPUT-EXIT
PERFORM OPEN-OUTPUT-PIPE THRU OPEN-OUTPUT-EXIT
PERFORM PROCESS-DATA THRU PROCESS-EXIT
PERFORM CLOSE-PIPE THRU CLOSE-EXIT
PERFORM FREE-STORAGE THRU FREE-EXIT
PERFORM RETURN-TO-FRONT-END.
OPEN-INPUT-PIPE.
MOVE 'OUTPUT' TO SPMODE.
MOVE 'STD' TO SPFORMAT.
MOVE 200 TO SPMAXLEN.
CALL 'OPENPIPE' USING SPAREA.
IF SPRC NOT = '000'
MOVE 'OPEN PIPE ERROR IN DRIVER' TO SPMSG
PERFORM PIPE-ERR-RTN THRU PIPE-EXIT
END-IF.
GET-INPUT-PARM
IF SPVARLEN > 0
SET ADDRESS OF LK-INPUT-PIPE TO SPVARTXT
MOVE LK-INPUT-PIPE TO WS-INPUT-AREA
ELSE
PEROFRM-ERROR-PARA
END-IF.
OPEN-OUTPUT-PIPE.
EXEC CICS GETMAIN
SET (ADDRESS OF LK-RETURN-PIPE)
LENGTH(200)
INITIMG(WS-INITIMG)
RESP (WS-RESP)
END-EXEC
IF WS-RESP = DFHRESP (LENGERR)
MOVE 'CICS LENGTH ERROR IN RETURN AREA'
TO LK-ERR-DESC
END-IF.
PROCESS-DATA
...... PROCESS THE DATA LIKE UPDATE/FETCH WHCH WE GOT FROM FRONT-END
THRU LINKAGE SECTION INTO OUR WS-VARIABLES.
PERFORM RESULT-LINKAGE-OUTPUT
RESULT-LINKAGE-OUTPUT
MOVE WS-OUTPUT-AREA TO LK-RPLY-SEND-AREA
SET SPFROM TO ADDRESS OF LK-RETURN-PIPE
PERFORM PUT-PIPE THRU EXIT.
PUT-PIPE.
CALL 'PUTPIPE' USING SPAREA.
IF SPRC NOT = '000'
MOVE 'PUT-PIPE ERROR ' TO SPMSG
PERFORM PIPE-ERR-RTN
END-IF.
CLOSE-PIPE
CALL 'CLOSPIPE' USING SPAREA.
IF SPRC NOT = '000'
MOVE 'CLOSE-PIPE ERROR' TO SPMSG
END-IF.
MOVE 'OK' TO SPSTATUS
CALL 'STATUS' USING SPAREA.
FREE-STORAGE.
EXEC CICS FREEMAIN
DATA (LK-RETURN-PIPE)
END-EXEC
RETURN-TO-FRONT-END.
EXEC CICS
RETURN
END-EXEC.
Explanation:
First we need to include SPAREAC in LINKAGE SECTION. SPAREAC includes all pointers,codes that the RSP needs to exchange the data with the front end via the Direct connect.It sets the pointer to the communication channel.
CICS put pipe error might come if the pipe is opened properly .Also if the middleware( like Direct connect or somthing) server is down, CICS program can give put pipe error. So we need to initialize the storage pipes properly and remove the put pipe,get pipe error.
(For further clarifications leave ur questions in comments section..)
Structure of SPAREAC::::
STORED PROCEDURE COMMUNICATION AREA
03 SPAREA.
05 SPHEADER PIC X(8).
05 SPRESRVD PIC X(33).
05 SPTRCOPT PIC X(1).
05 SPSTATUS PIC X(2).
05 SPCODE PIC X(8).
05 SPFORMAT PIC X(3).
05 SPMODE PIC X(6).
05 SPRC PIC X(3).
05 SPFROM USAGE IS POINTER.
05 SPINTO REDEFINES SPFROM USAGE IS POINTER.
05 SPSQLDA REDEFINES SPINTO USAGE IS POINTER.
05 SPVARTXT USAGE IS POINTER.
05 SPVARTAB USAGE IS POINTER.
05 SPROWS PIC S9(8) COMP.
05 SPMAXLEN PIC S9(4) COMP.
05 SPRECLEN REDEFINES SPMAXLEN PIC S9(4) COMP.
05 SPVARLEN PIC S9(4) COMP.
05 SPPREFIX PIC X.
05 SPMSG PIC X(100).
05 FILLER PIC X(3).
05 SPSQL USAGE IS POINTER.
05 SPATTACH PIC X(8).
05 SPUSERID PIC X(8).
05 SPPWD PIC X(8).
05 SPCMPOPT PIC X(1).
05 SPIND PIC X(1).
05 SPDATE PIC X(8).
05 SPTIME PIC X(8).
05 SPCONFIG PIC X(4).
05 SPSERVER PIC X(30).
05 FILLER PIC X(32).
The input pipe is opened for communication.In the GETINPUT para, the pointer is set, so that linkage-varibales get the variables passed from front-end via the SPVARTEXT.Then we bring the variables from likage to our WS-VARIABLES for processing. Once processing is over, we move the Result from WS-OUTPUT to linkage-output and then on to FRONT-END.