Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

What is the correct approach to pass address of variable?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CICS
View previous topic :: :: View next topic  
Author Message
bijal.awhad

New User


Joined: 19 Mar 2008
Posts: 51
Location: Pune

PostPosted: Mon Aug 03, 2009 1:27 pm    Post subject: What is the correct approach to pass address of variable?
Reply with quote

Hi All,

My requirement is to pass data of WK-VAR1 from Program A to Program B by passing an address.

WK-VAR1 is defined as below in program A

01 WK-VAR1.
02 WK-FIELD1 PIC X (86).
02 WK-FIELD2 PIC X (172000).
02 WK-VAR1-ADDRESS POINTER.

PROCEDURE DIVISION

SET WK-VAR1-ADDRESS TO ADDRESS OF WK-VAR1 .

EXEC CICS
LINK
PROGRAM (PROGRAM-B)
COMMAREA (WK-VAR1)
LENGTH (LENGTH OF WK-VAR1)
RESP (WK-RESP)
END-EXEC.



PRogram B

Working storage section

01 WK-HEADER.
02 WK-ACT-DATA PIC X (172086).
02 WK-ACT-ADDRESS POINTER.


Linkage section

01 DFHCOMMAREA.
02 LK-DATA PIC X (172086).
02 LK-VAR1-ADDRESS POINTER.

PROCEDURE DIVISION

SET WK-ACT-ADDRESS TO ADDRESS OF LK-VAR1-ADDRESS.

Now can i say whatever data was in WK-VAR1 of program A is in WK-HEADER of program B.

Is this the correct approach to pass huge data from one program to another program by passing an address? If not what is the best approach?



Regards
Bijal
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8055
Location: East Dubuque, Illinois, USA

PostPosted: Mon Aug 03, 2009 4:38 pm    Post subject:
Reply with quote

No, this is not the correct approach. From the CICS Language Reference manual, LINK command syntax, error conditions:
Quote:
LENGERR
RESP2 values:

11
The COMMAREA length is less than 0 or greater than 32767.
If you merely passed a pointer to the address, that's only 4 bytes -- but passing the whole 172,086 bytes won't work.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Mon Aug 03, 2009 4:52 pm    Post subject: Reply to: What is the correct approach to pass address of va
Reply with quote

Also, the LINK must be LOCAL (within the same region), if you plan to pass an ADDRESS.

You CANNOT pass an ADDRESS via a remote LINK (DPL) and expect the address in the remote region to point to the same data.

You run the risk of corrupting whatever data is at this same address in the remote region and cause all sorts of problems.

So, don't do this....

Bill
Back to top
View user's profile Send private message
bijal.awhad

New User


Joined: 19 Mar 2008
Posts: 51
Location: Pune

PostPosted: Mon Aug 03, 2009 6:17 pm    Post subject:
Reply with quote

Hi Robert & Bill

Can you please tell me the correct approach to do this?

Regards
Bijal
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Mon Aug 03, 2009 7:14 pm    Post subject: Reply to: What is the correct approach to pass address of va
Reply with quote

In the LINKED-TO program, specify -

Code:

LINKAGE SECTION.
01  DFHCOMMAREA.
    03  CA-POINTER POINTER.

01  LK-DATA-REC.
    03  LK-DATA-LGTH PIC S9(08) COMP.
    03  LK-DATA PIC X(16777211).

SET ADDRESS OF LK-DATA-REC TO CA-POINTER.

When you pass a length associated with your data, you now have the ability to have a variable-length parameter. So, the binary-fullword (LK-DATA-LGTH) will contain the maximum-length that can be addressed in LK-DATA. LK-DATA-LGTH is populated in the LINKING program.

Note that 16777215 is the maximum length of an 01 level, so this is the reason for the PIC X(16777211).

You'll have to change the LINKING program's WS to allow for a data-lgth followed by the actual data. Note that the picture clause of the actual data does not need to be 16777211. It should be the maximum amount of data that the LINKED-TO program can address.

LINKAGE SECTION definitions don't take up any space/memory until addressability is established.

Note that IBM has always discouraged the passing of addresses for as long as I can recall. But, it's up to you to use this or not.

HTH....

Bill
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8055
Location: East Dubuque, Illinois, USA

PostPosted: Mon Aug 03, 2009 7:27 pm    Post subject:
Reply with quote

From the CICS Programming Guide manual (link at the top of the page):
Quote:
3.6.2.2 Unsafe techniques

The programming techniques in the unsafe category are:

* The use of long-life shared storage:

o The common work area (CWA)

o GETMAIN SHARED storage

o Storage obtained by a LOAD PROGRAM HOLD

* The use of task-lifetime local storage shared by synchronized tasks

It is possible for one task to pass the address of some task-lifetime storage to another task.

It may be safe for the receiving task to use the passed address, provided the owning task does not terminate. It is possible, but ill-advised, to use a CICS task-synchronization technique to allow the receiving task to prevent the sending task from terminating (or freeing the storage in some other way) before the receiver has finished with the address. However, such designs are not robust because there is a danger of the sending task being purged by some outside agency.

See "Sharing task-lifetime storage" in topic 3.6.4.4 for more details.
IBM considers what you are wanting to do to be inherently unsafe. I would strongly recommend a long round of discussion with your peers and management before implementing anything that IBM considers unsafe.
Back to top
View user's profile Send private message
bijal.awhad

New User


Joined: 19 Mar 2008
Posts: 51
Location: Pune

PostPosted: Tue Aug 04, 2009 3:09 pm    Post subject: Re: Reply to: What is the correct approach to pass address o
Reply with quote

Bill O'Boyle wrote:
In the LINKED-TO program, specify -

[code]
LINKAGE SECTION.
01 DFHCOMMAREA.
03 CA-POINTER POINTER.

01 LK-DATA-REC.
03 LK-DATA-LGTH PIC S9(08) COMP.
03 LK-DATA PIC X(16777211).




How the variables will be defined in Program A?
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Aug 04, 2009 3:46 pm    Post subject: Reply to: What is the correct approach to pass address of va
Reply with quote

Example -

Code:

01  WK-VAR-REC.
    03  WK-VAR-LGTH PIC S9(08) COMP.
    03  WK-VAR.
        05  WK-FIELD1 PIC X(86).
        05  WK-FIELD2 PIC X(172000).
01  WK-VAR-MISC.
    03  WK-VAR-POINTER POINTER.

MOVE LENGTH OF WK-VAR TO WK-VAR-LGTH.
SET WK-VAR-POINTER TO ADDRESS OF WK-VAR-REC.

At this point, you would issue the LINK to program "B" using WK-VAR-POINTER as the four-byte commarea.

But remember, IBM discourages passing addresses.

Your mileage may vary.... icon_wink.gif

Bill
Back to top
View user's profile Send private message
bijal.awhad

New User


Joined: 19 Mar 2008
Posts: 51
Location: Pune

PostPosted: Tue Aug 04, 2009 4:17 pm    Post subject:
Reply with quote

Thanks for the information Bill.

I need to call Program-B as below

EXEC CICS LINK
PROGRAM(PROGRAM-B)
COMMAREA(WK-VAR-MISC)
LENGTH(WK-VAR-LENGTH)
RESP(RESP-CD)
END-EXEC.

In this way i will pass address to Program B, right?

Regards
Bijal
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Aug 04, 2009 4:54 pm    Post subject: Reply to: What is the correct approach to pass address of va
Reply with quote

NO, the COMMAREA is WK-VAR-POINTER and the LENGTH is LENGTH OF WK-VAR-POINTER, which is 4.

If you don't supply a LENGTH, the translator will automatically use LENGTH OF WK-VAR-POINTER.

Remember, you are passing the ADDRESS OF WK-VAR-REC, which can be found in WK-VAR-POINTER, as the COMMAREA to Program "B".

If for some reason, Program "B" becomes REMOTE, then this method will not work and you will crash and burn.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CICS All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts RC 20 for Address ISPEXEC "ISRED... pkmurali CLIST & REXX 3 Sun Apr 16, 2017 11:30 pm
No new posts Is the explanation correct? XRST,CHKP Martylin IMS DB/DC 1 Wed Mar 15, 2017 9:26 am
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us