If this is the code for Main Program why are we using POINTER and in the called program we are using SET ADDRESS OF syntax which i am not able to understand.Called program i have not understood that is why i have not posted it.Please help me why do we need POINTER and ADDRESS of parameters.
Code:
IDENTIFICATION DIVISION.
PROGRAM-ID. TSTCB1.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 TEST1-PTR USAGE IS POINTER.
01 TEST.
05 TEST1-COB PIC X(10).
05 TEST2-COB PIC X(20).
PROCEDURE DIVISION.
0000-MAIN.
MOVE 'ABC' TO TEST1-COB
MOVE 'CBA' TO TEST2-COB
DISPLAY TEST.
CALL 'TSTCB2' USING TEST1-PTR.
GOBACK
.
0000-MAIN-EXIT.
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
Posted: Tue Nov 28, 2006 5:46 pm Post subject:
No wonder you don't understand, only one in that thread did either.
if you have a cobol module - SETPTR:
Code:
IDENTIFICATION DIVISION.
PROGRAM-ID. SETPTR.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
LINKAGE SECTION.
01 PASSED-POINTER USAGE IS POINTER.
01 PASSED-AREA PIC X(01).
PROCEDURE DIVISION USING PASSED-POINTER
PASSED-AREA.
0000-MAIN-SET-POINTER.
SET PASSED-POINTER
TO ADDRESS OF PASSED-AREA
GOBACK
.
0000-EXIT.
EXIT.
you can
Code:
CALL SETPTR USING POINTER-A
AREA-A
where
POINTER-A is any working-storage or linkage POINTER
and
AREA-A is any working-storage or linkage AREA
upon return to your module, the POINTER data-item contains the address of the AREA. Thus you can get around the working-storage/linkage restriction.
why do this?
many large Batch (and ON-LINE COBOL CALLed) COBOL sub-systems - have many modules with many pass-a-long areas (USING list) that are to be shared by the sub-modules.
If your original design includes that all CALL USINGs listing every parm, any future changes - new parm - means that you have to modify the CALL USING code in every existing module (as well as the PROCEDURE DIVISION USINGs!).
But if you original design was for 1 main-program defined 'CONTROL' pass-along which contained a table of POINTER items, then your USING list would be only 1 data area. Each sub-modul would address all linkage items with the appropriate pointer.
Say MOD-A CALLs MOD-B CALLs MOD-C CALLs MOD-D.
USING list is 5 areas. New requirement, MOD-D CALLs MOD-E which needs a new area used also by MOD-D and MOD-B.
This means all the USING lists (CALLs and PROC DIV) have to be changed. MOD-C, which does not use the new area, but still must define it in linkage to pass it to MOD-D (and receive from MOD-B).
With the POINTER approach, just add the new pointer to the 'CONTROL' pass-a-long and modules that need the new area would address it, while those that did not need it would not declare it.
little wordy, hope it helps
Lot of legacy systems had upwards of 20 - 100 USING parms (limit is 256). A real pain to maintain as well as modify when something new had to be added.
to get around having to modify the USING list every time a module required yet a new area to be passed you could have a table containing thousands of POINTERs, each loaded with the address of one of 1000's areas. (thousand is a bit much but do able)
Another reason to use Pointers. Say you have a really large COBOL Table that contains items of 20,000 bytes (you have stowed a vsam file in a COBOL Table to save on I/O'S). This COBOL table is contained in sub-module TABMOD which is CALLed by other modules to get the corresponding table item (vsam record image). If every CALL to TABMOD had a USING ITEM-AREA (an item definition), TABMOD would find the item, MOVE the Table-item(xrg) to ITEM-AREA (linkage) and GOBACK. If you have a large transaction base, 2 million, and each transaction CALLed TABMOD, you would have 2 million moves of 20,000 chars.
To speed it up:
CALLing Program:
Code:
WORKING-STORAGE.
01 ITEM-POINTER USAGE IS POINTER.
01 ITEM-KEY PIC X(20).
LINKAGE SECTION.
01 ITEM-AREA.
(COPYBOOK definition of Table item)
CALL TABMOD USING ITEM-POINTER
ITEM-KEY
SET ADDRESS OF ITEM-AREA
TO ITEM-POINTER
TABMOD:
Code:
...
WORKING-STORAGE SECTION.
01 VSAM-IMAGE-TABLE.
05 VSAM-IMAGE OCCURS 100000 TIMES
INDEXED BY VSAM-XREG.
10 VSAM-IMAGE-KEY PIC X(20).
10 FILLER PIC X(19980)
LINKAGE SECTION.
01 ITEM-POINTER USAGE IS POINTER.
01 ITEM-KEY PIC X(20).
PROCEDURE DIVISION USING ITEM-POINTER
ITEM-KEY.
:::find item...
SET ITEM-POINTER TO ADDRESS OF VSAM-IMAGE(VSAM-XREG)
:::: or CALL SETPTR USING ITEM-POINTER
VSAM-IMAGE(VSAM-XREG)
GOBACK
_________________ Dick Brenholtz
American living in Varel, Germany
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum