Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cobol occurs & index - thru CICS

Status
Not open for further replies.

janikatta

Programmer
Apr 14, 2006
1
US
I have two CICS programs A & B. A calls program B.
B has a occurs clause & indexed by b-indx. The whole table is in linkage section. At the time of second call, the b-indx is set back to 0. How can I restore that value.

Ex; pgm A
..
..
exec cics link('b')
commarea(linkb).

Pgm B
..
..
linkage section
01 table1.
05 tbl occurs 100 times indexed by ws-tbl-indx
10 field1 value pic x(10)
10 field2 value pic x(05).
procedure division.
..
..

Thanks, Jani
 
Indices are never passed as part of a group in a using list. You will have to save the value of the index in another field, and pass that field.
Code:
01  table1.
    05  tbl occurs 100 times indexed by ws-tbl-indx.
        10  field1 value pic x(10).
        10  field2 value pic x(05).

01  save-index index.
. . .
    set save-index to ws-tbl-indx
    call 'pgmb' using table1 save-index
==========================
program-id 'pgmb'.

linkage section.

01  table1.
    05  tbl occurs 100 times indexed by ws-tbl-indx.
        10  field1 value pic x(10).
        10  field2 value pic x(05).

01  save-index index.

procedure division using table1 save-index.
. . .

    set ws-tbl-indx to save-index
 
Despite its declaration in LINKAGE SECTION, an index defined implicitly in the OCCURS clause is local to the program in which it is declared. This is according to the COBOL standard, and webrabbit has provided a reasonable workaround. The following information is offered to aid others understand this somewhat obscure area.

The index within a CALLed program will retain its value between calls provided that the called program is not CANCELed or returned to its inital state upon EXIT PROGRAM due to the INITIAL attribute in the PROGRAM-ID paragraph. Many other things remain in their last used state in an unCANCELed program: file connectors, working-storage data item values, etc. The only thing that the COBOL standard requires to be reinitialized upon an EXIT PROGRAM is that all PERFORM exit points are to be returned to their initial, 'unPERFORMed', state.

Tom Morrison
 
Having seen this (or at least a similar) note in another forum, I just wanted to make certain that the original poster understands that when you say "CALL" a program in a CICS environment, that this means that you are using the COBOL
CALL
statement. If you are using
EXEC CICS LINK / XCTL
then you should not say that you "calling" another program.

Although this does not impact the particular quesiton of "passing" index settings to other programs, it can definitely impact some inter-program semantics.

***

P.S. For Tom,
In the '02 Standard (not the '85 Standard)
LOCAL-STORAGE
items get "pushed and popped" upon EXIT PROGRAM (EXIT METHOD and EXIT FUNCTION). This ties in with the '02 Standard allowing recursion - and simply expands upon your statement that only "perform ranges" MUST be initialized between CALLs (when the subprogram is not placed into initial state).

Bill Klein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top