|
20 | 20 | public class LinkProg2 extends LinkProgCommon { |
21 | 21 |
|
22 | 22 |
|
23 | | - private static final String PROG_NAME = "EDUPGM"; // COBOL program to be invoked |
24 | | - |
25 | | - /** |
26 | | - * Constructor used to pass data to superclass constructor. |
27 | | - * |
28 | | - * @param task - the current CICS task executing this example. |
29 | | - * @param prog - the program reference we will be manipulating in this example. |
30 | | - */ |
31 | | - private LinkProg2(Task task, Program prog) |
32 | | - { |
33 | | - super(task, prog); |
34 | | - |
35 | | - } |
36 | | - |
37 | | - /** |
38 | | - * Main entry point to a CICS OSGi program. |
39 | | - * This can be called via a LINK or a 3270 attach |
40 | | - * |
41 | | - * The fully qualified name of this class should be added to the CICS-MainClass |
42 | | - * entry in the parent OSGi bundle's manifest. |
43 | | - */ |
44 | | - public static void main(String[] args) |
45 | | - { |
46 | | - // Get details about our current CICS task |
47 | | - Task task = Task.getTask(); |
48 | | - task.out.println(" - Starting LinkProg2"); |
49 | | - |
50 | | - // Create a reference to the Program we will invoke |
51 | | - Program prog = new Program(); |
52 | | - |
53 | | - // Specify the properties on the program |
54 | | - prog.setName(PROG_NAME); |
55 | | - // Don't syncpoint between remote links, this is the default |
56 | | - // Setting true ensures each linked program runs in its own UOW and |
57 | | - // allows the a remote server program to use a syncpoint command |
58 | | - prog.setSyncOnReturn(false); |
59 | | - |
60 | | - // Create a new instance of the class |
61 | | - LinkProg2 lp = new LinkProg2(task, prog); |
62 | | - |
63 | | - // build commarea byte array using JZOS record |
64 | | - JZOSCommareaWrapper cw = lp.buildCommarea(); |
65 | | - |
66 | | - // Invoke the LINK to CICS program converting the record to a byte array |
67 | | - lp.linkProg(cw.getByteBuffer()); |
68 | | - |
69 | | - // Get output data from commarea |
70 | | - // Use the getters from the commarea record to access the output fields |
71 | | - // in the returned commarea |
72 | | - String resultStr = cw.getResultText(); |
73 | | - Integer resultCode = cw.getResultCode(); |
74 | | - |
75 | | - // Completion message |
76 | | - String msg = MessageFormat.format |
77 | | - ("Returned from link to {0} with rc({1}) {2}", prog.getName(),resultCode,resultStr); |
78 | | - task.out.println(msg); |
79 | | - } |
80 | | - |
81 | | - |
82 | | - /** |
83 | | - * Link to the CICS COBOL program and catch any errors from CICS |
84 | | - * |
85 | | - * @param commarea - byte array as input and output commarea |
86 | | - */ |
87 | | - // LINK to the CICS program |
88 | | - private void linkProg(byte[] commarea){ |
89 | | - |
90 | | - try { |
91 | | - prog.link(commarea); |
92 | | - } catch (CicsConditionException cce) { |
93 | | - throw new RuntimeException(cce); |
94 | | - } |
95 | | - } |
96 | | - |
97 | | - /** |
98 | | - * Build the commarea using the supplied JZOS wrapper |
99 | | - * and set the input fields as required |
100 | | - * |
101 | | - * @return jzos commarea record for EDUPGM copybook |
102 | | - * |
103 | | - */ |
104 | | - private JZOSCommareaWrapper buildCommarea(){ |
105 | | - |
106 | | - JZOSCommareaWrapper cw = new JZOSCommareaWrapper(); |
107 | | - cw.setBinaryDigit(1); |
108 | | - cw.setCharacterString("hello"); |
109 | | - cw.setNumericString(1234); |
110 | | - cw.setPackedDigit(123456789); |
111 | | - cw.setSignedPacked(-100); |
112 | | - cw.setBool("1"); |
113 | | - return cw; |
114 | | - |
115 | | - } |
116 | | - |
117 | | - |
118 | | - |
| 23 | + private static final String PROG_NAME = "EDUPGM"; // COBOL program to be invoked |
| 24 | + |
| 25 | + /** |
| 26 | + * Constructor used to pass data to superclass constructor. |
| 27 | + * |
| 28 | + * @param task - the current CICS task executing this example. |
| 29 | + * @param prog - the program reference we will be manipulating in this example. |
| 30 | + */ |
| 31 | + private LinkProg2(Task task, Program prog) |
| 32 | + { |
| 33 | + super(task, prog); |
| 34 | + |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * Main entry point to a CICS OSGi program. |
| 39 | + * This can be called via a LINK or a 3270 attach |
| 40 | + * |
| 41 | + * The fully qualified name of this class should be added to the CICS-MainClass |
| 42 | + * entry in the parent OSGi bundle's manifest. |
| 43 | + */ |
| 44 | + public static void main(String[] args) |
| 45 | + { |
| 46 | + // Get details about our current CICS task |
| 47 | + Task task = Task.getTask(); |
| 48 | + task.out.println(" - Starting LinkProg2"); |
| 49 | + |
| 50 | + // Create a reference to the Program we will invoke |
| 51 | + Program prog = new Program(); |
| 52 | + |
| 53 | + // Specify the properties on the program |
| 54 | + prog.setName(PROG_NAME); |
| 55 | + // Don't syncpoint between remote links, this is the default |
| 56 | + // Setting true ensures each linked program runs in its own UOW and |
| 57 | + // allows the a remote server program to use a syncpoint command |
| 58 | + prog.setSyncOnReturn(false); |
| 59 | + |
| 60 | + // Create a new instance of the class |
| 61 | + LinkProg2 lp = new LinkProg2(task, prog); |
| 62 | + |
| 63 | + // build commarea byte array using JZOS record |
| 64 | + JZOSCommareaWrapper cw = lp.buildCommarea(); |
| 65 | + |
| 66 | + // Invoke the LINK to CICS program converting the record to a byte array |
| 67 | + lp.linkProg(cw.getByteBuffer()); |
| 68 | + |
| 69 | + // Get output data from commarea |
| 70 | + // Use the getters from the commarea record to access the output fields |
| 71 | + // in the returned commarea |
| 72 | + String resultStr = cw.getResultText(); |
| 73 | + Integer resultCode = cw.getResultCode(); |
| 74 | + |
| 75 | + // Completion message |
| 76 | + String msg = MessageFormat.format |
| 77 | + ("Returned from link to {0} with rc({1}) {2}", prog.getName(),resultCode,resultStr); |
| 78 | + task.out.println(msg); |
| 79 | + } |
| 80 | + |
| 81 | + |
| 82 | + /** |
| 83 | + * Link to the CICS COBOL program and catch any errors from CICS |
| 84 | + * |
| 85 | + * @param commarea - byte array as input and output commarea |
| 86 | + */ |
| 87 | + // LINK to the CICS program |
| 88 | + private void linkProg(byte[] commarea){ |
| 89 | + |
| 90 | + try { |
| 91 | + prog.link(commarea); |
| 92 | + } catch (CicsConditionException cce) { |
| 93 | + throw new RuntimeException(cce); |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * Build the commarea using the supplied JZOS wrapper |
| 99 | + * and set the input fields as required |
| 100 | + * |
| 101 | + * @return jzos commarea record for EDUPGM copybook |
| 102 | + * |
| 103 | + */ |
| 104 | + private JZOSCommareaWrapper buildCommarea(){ |
| 105 | + |
| 106 | + JZOSCommareaWrapper cw = new JZOSCommareaWrapper(); |
| 107 | + cw.setBinaryDigit(1); |
| 108 | + cw.setCharacterString("hello"); |
| 109 | + cw.setNumericString(1234); |
| 110 | + cw.setPackedDigit(123456789); |
| 111 | + cw.setSignedPacked(-100); |
| 112 | + cw.setBool("1"); |
| 113 | + return cw; |
| 114 | + |
| 115 | + } |
119 | 116 | } |
0 commit comments