This sample COBOL program contains a CUSTOMERINFO structure
that you can select as the pattern for the input message of your service
interface, and an ACCOUNTINFO structure that you can select as the
pattern for the output message of your service interface.
To create a COBOL file named
queryAccount.cbl from this COBOL program:
- Create an empty text file named queryAccount.cbl.
- Copy and paste the text in Figure 1 into
queryAccount.cbl.
- Save and close queryAccount.cbl.
Figure 1. Part 1
of the text for queryAccount.cbl * (c) Copyright IBM Corp. 2005,2009 All rights reserved.
*
* This sample program is owned by International Business Machines
* Corporation or one of its subsidiaries ("IBM") and is copyrighted
* and licensed, not sold.
*
* You may copy, modify, and distribute this sample program in any
* form without payment to IBM, for any purpose including developing,
* using, marketing or distributing programs that include or are
* derivative works of the sample program.
*
* The sample program is provided to you on an "AS IS" basis, without
* warranty of any kind. IBM HEREBY EXPRESSLY DISCLAIMS ALL WARRANTIES,
* EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
* Some jurisdictions do not allow for the exclusion or limitation of
* implied warranties, so the above limitations or exclusions may not
* apply to you. IBM shall not be liable for any damages you suffer as
* a result of using, modifying or distributing the sample program or
* its derivatives.
*
IDENTIFICATION DIVISION.
PROGRAM-ID. QUERYACC.
Data division.
Working-Storage section.
01 MYVARIABLES.
03 subscript PIC 9.
01 ACCOUNTINFO.
03 userName pic x(10) value spaces.
03 department pic x(10) value spaces.
03 itemNumber pic x(4) value spaces.
03 quantity pic x(4) value spaces.
03 returnCode pic 9(5).
01 CUSTOMERINFO.
03 accountNumber pic x(45).
01 errormsg pic x(31) value
'This is a comm area application'.
Linkage section.
01 DFHCOMMAREA.
03 filler pic x(45).
Figure 2. Part 2
of the text for queryAccount.cbl procedure division.
Mainprogram.
if eibcalen = 0
move eibtrnid to errormsg(1:4)
EXEC CICS SEND TEXT FROM(ERRORMSG) END-EXEC
EXEC CICS RETURN END-EXEC
end-if.
move dfhcommarea to CUSTOMERINFO.
display eibtrnid " account Number '" accountNumber(1:6) "'" .
evaluate accountNumber(1:6)
when '100356'
Move 'cindy' to username
Move 't35' to department
Move '0010' to itemNumber
Move '1' to quantity
Move 0 to returnCode
when '104444'
Move 'user1' to username
Move 't35' to department
Move '0130' to itemNumber
Move '1' to quantity
Move 0 to returnCode
when other
Move 'user2' to username
Move 't35' to department
Move '0020' to itemNumber
Move '1' to quantity
Move 0 to returnCode
end-evaluate.
Move ACCOUNTINFO to dfhcommarea.
EXEC CICS RETURN END-EXEC.
Exit.