Hi Ron,
I don't know whether I forgot or never really knew, but I was mistaken about this situation with regard to dynamic calls to primary and secondary entry points. If you dynamically call both the primary and secondary entry points, you in effect get two instances of the module, including working-storage, which is why you see the call-switch showing INITIAL both times. SFSMAIN shows with a system use count of 2 as a result of the calls and the RENT bind.
If you really want a single instance working-storage along with dynamic linkage and multiple entry points, you need to build and call the module as a DLL. This can be done with some workarounds in COBOL 4.2, but is relatively straight forward in COBOL 6.2 and onwards with the >>CALLINTERFACE directive.
Bernie
This documentation could be improved...
Calling alternate entry points
https://www.ibm.com/docs/en/cobol-zos/6.3?topic=pointers-calling-alternate-entry-pointsDynamic calls to alternate entry points require the following elements:
* Either explicitly specified NAME or ALIAS binder (linkage-editor)
control statements, or use of the NAME compiler option which generates
them automatically.
* An intervening CANCEL for any dynamic call to the same module at a
different entry point. CANCEL causes the program to be invoked in
initial state when it is called at a new entry point.
------------------------------
Bernie Rataj
Senior Software Developer
IBM Canada Ltd.
Markham ON Canada
https://www.ibm.com/marketplace/ibm-compilers------------------------------
Original Message:
Sent: Thu June 03, 2021 12:38 PM
From: Ron Mascarenhas
Subject: COBOL WORKING-STORAGE reloaded at ENTRY statement
Hi Bernie,
I have the COBOL compile with RENT and the Linkedit with RENT, but still the Working-Storage has the initial values at the ENTRY statement.
Here are the snippets of a sample program which also has this issue.
Compile options
RENT
RMODE(AUTO)
CBL DATA(31),RENT
Program
000001 ID DIVISION.
000002 PROGRAM-ID. SFSMAIN.
000003 ENVIRONMENT DIVISION.
000004 CONFIGURATION SECTION.
000005 SOURCE-COMPUTER. IBM-Z13.
000006 INPUT-OUTPUT SECTION.
000007 DATA DIVISION.
000008 FILE SECTION.
000009 WORKING-STORAGE SECTION.
000010 01 CALL-SWITCH PIC X(7) VALUE 'INITIAL'.
000011 PROCEDURE DIVISION.
000012 MOVE 'FIRST ' TO CALL-SWITCH.
000013 DISPLAY 'CALL SWITCH ON MAIN CALL=' CALL-SWITCH.
000014 EXIT PROGRAM.
000015 ENTRY 'SFSALIAS'
000016 DISPLAY 'CALL SWITCH ON ENTRY CALL =' CALL-SWITCH.
000017 EXIT PROGRAM.
In the above program I am expecting the CALL-SWITCH at the ENTRY statement to show 'FIRST' but it always shows INITIAL
LINKEDIT OPTIONS
1z/OS V2 R2 BINDER 18:45:54 THURSDAY JUNE 3, 2021
BATCH EMULATOR JOB(TSDJIMS1) STEP( ) PGM= IEWL
IEW2278I B352 INVOCATION PARAMETERS - XREF,LET,LIST,MAP,RENT
IEW2322I 1220 1 INCLUDE SYSLMOD(SFSMAIN)
IEW2322I 1220 2 ENTRY SFSMAIN
IEW2322I 1220 3 ALIAS SFSALIAS
IEW2322I 1220 4 NAME SFSMAIN(R)
1SAVE MODULE ATTRIBUTES:
AC 000
AMODE 31
REFR NO
RENT YES
REUS YES
RMODE ANY
1 ENTRY POINT AND ALIAS SUMMARY:
NAME: ENTRY TYPE AMODE C_OFFSET CLASS NAME STATUS
SFSMAIN MAIN_EP 31 00000000 B_TEXT
SFSALIAS ALTERNATE 31 000003A4 B_TEXT ADDED
------------------------------
Ron Mascarenhas
Original Message:
Sent: Tue June 01, 2021 03:44 PM
From: Bernie Rataj
Subject: COBOL WORKING-STORAGE reloaded at ENTRY statement
Hi Ron,
The program needs to be compiled and bound RENT so you get the same working-storage image each time a call is made. And of course don't use the IS INITIAL phrase, because that will refresh working-storage items with a VALUE clause each time you enter the program.
Bernie
------------------------------
Bernie Rataj
Senior Software Developer
IBM Canada Ltd.
Canada
https://www.ibm.com/marketplace/ibm-compilers
Original Message:
Sent: Tue June 01, 2021 02:42 PM
From: Ron Mascarenhas
Subject: COBOL WORKING-STORAGE reloaded at ENTRY statement
I have a COBOL program which has a table in the WORKING-STORAGE which is updated within the same program. The program also has an ENTRY statement . Everytime another program calls the program by the ENTRY name, the table in WORKING-is presented in it's initial state instead of the updated one. I have also tried the REUS linkedit parm but no change.
------------------------------
Ron Mascarenhas
------------------------------