i think both are same but only two different way of calling. because in both the cases the address is being passed in between called program and main program.

Inboth cases AN address is being passed, but a different addresses in each case. With the first, the address of the data is passed. With the second,the address of the pointer, which contains the address of the data, is passed.

Using pointers enables you to pass more than 32k in storage to subprogram by not passing actual data but just address of pointer that holds storage address of data.
If you passed data, then you can only pass up to 32k because that is system limitation.

Using pointers enables you to pass more than 32k in storage to subprogram by not passing actual data but just address of pointer that holds storage address of data.
If you passed data, then you can only pass up to 32k because that is system limitation.

Scenario: Program A needs to pass 50,000 bytes of storage to Program B. How do you do this in CICS?

1. Use the CALL statement. Quite simply...

CALL WS-B USING WS-CHUNK

2. Use the LINK statement.

However, the LINK statement imposes a maximum length of 32K. So you cannot pass CHUNK directly. But you could pass it indirectly. Create a POINTER field that lives in the commarea that A passes to B. Note however that this creates an affinity between A and B. A and B must live in the same CICS region in order for this technique to work.

Note that using the CALL statement also creates an affinity between A and B. However, this affinity is far less smelly than the affinity caused by passing a POINTER via the LINK statement.

Consider what would happen if the CICS Configuration people decided to configure A and B in different CICS regions. (Maybe they did this for a valid reason... maybe they made a mistake. It doesn't really matter...)

An attempt by A to CALL B would result in an abend - and that is exactly how I want this event handled. Perfect.

However, an attempt by A to LINK to B will succeed BUT the pointer that A passes to B will become an invalid pointer in the remote CICS region. As they say, unpredictable results. Much more difficult to diagnose.

In other words, if you are going to pass POINTERs around using LINK you've got to take care. One idea is, when setting a pointer, to bundle it with the SYSID of the region it points to. This allows for a check to occur by whoever wants to use the pointer - they can ask "Is this pointer pointing to the CICS region I am running in".

So the best option is use CALL. CALL clearly establishes the affinity between A and B whereas the LINK/POINTER approach can be a time-bomb.

Where I work we have strict rules about avoiding the creation of affinities between certain programs.

Whenever possible avoid the use of POINTERs. Are there legitimate scenarios where POINTERS make sense? Yes. One example: consider a table that typically contains no more than 15 entries for 99% of transactions, but may contain 1000 entries for your big customers. Instead of defining this table in your working storage as OCCURS 1200 you could define it in your LINKAGE SECTION as OCCURS 1 to 1200 and allocate storage dynamically - only as much as you need. To do this you must use pointers.

but i have one more question like... in general call also i.e. without using pointer both calling program and called program is shariing the same memory address as it is call by reference. but in case of call by value different address is being maintained.

so what i am worring like in both the case ( in using pointer and not using) the interfacing is by address only.

so how it is different. or both are same but just two different form.

TG Murphy wrote:

Scenario: Program A needs to pass 50,000 bytes of storage to Program B. How do you do this in CICS?

1. Use the CALL statement. Quite simply...

CALL WS-B USING WS-CHUNK

2. Use the LINK statement.

However, the LINK statement imposes a maximum length of 32K. So you cannot pass CHUNK directly. But you could pass it indirectly. Create a POINTER field that lives in the commarea that A passes to B. Note however that this creates an affinity between A and B. A and B must live in the same CICS region in order for this technique to work.

Note that using the CALL statement also creates an affinity between A and B. However, this affinity is far less smelly than the affinity caused by passing a POINTER via the LINK statement.

Consider what would happen if the CICS Configuration people decided to configure A and B in different CICS regions. (Maybe they did this for a valid reason... maybe they made a mistake. It doesn't really matter...)

An attempt by A to CALL B would result in an abend - and that is exactly how I want this event handled. Perfect.

However, an attempt by A to LINK to B will succeed BUT the pointer that A passes to B will become an invalid pointer in the remote CICS region. As they say, unpredictable results. Much more difficult to diagnose.

In other words, if you are going to pass POINTERs around using LINK you've got to take care. One idea is, when setting a pointer, to bundle it with the SYSID of the region it points to. This allows for a check to occur by whoever wants to use the pointer - they can ask "Is this pointer pointing to the CICS region I am running in".

So the best option is use CALL. CALL clearly establishes the affinity between A and B whereas the LINK/POINTER approach can be a time-bomb.

Where I work we have strict rules about avoiding the creation of affinities between certain programs.

Whenever possible avoid the use of POINTERs. Are there legitimate scenarios where POINTERS make sense? Yes. One example: consider a table that typically contains no more than 15 entries for 99% of transactions, but may contain 1000 entries for your big customers. Instead of defining this table in your working storage as OCCURS 1200 you could define it in your LINKAGE SECTION as OCCURS 1 to 1200 and allocate storage dynamically - only as much as you need. To do this you must use pointers.

Hi,
Can you suggest me what exactly the differce is? in what case pointer is beneficial? as i am not finding any difference.

any reply would be appreciated..

Thanks.

William Thompson wrote:

akswhy wrote:

Using pointers enables you to pass more than 32k in storage to subprogram by not passing actual data but just address of pointer that holds storage address of data.
If you passed data, then you can only pass up to 32k because that is system limitation.

Can you suggest me what exactly the differce is? in what case pointer is beneficial? as i am not finding any difference.

In both cases AN address is being passed, but a different addresses in each case. With the first, the address of the data is passed. With the second,the address of the pointer, which contains the address of the data, is passed.

I am agree this works on two different addresses but both are working on addresses. generally work on addres is better then work on direct value. i am not finding any difference either it is address of pointer or address of data. am i right? what do u suggest?

William Thompson wrote:

amiya_mf wrote:

Can you suggest me what exactly the differce is? in what case pointer is beneficial? as i am not finding any difference.

In both cases AN address is being passed, but a different addresses in each case. With the first, the address of the data is passed. With the second,the address of the pointer, which contains the address of the data, is passed.

I had asked a similar question before, it was promptly moved to 'Off topics' .
I have observed some programs which call 100s of subprograms dynamically.
Now it is quite obvious that they pass huge number variables/structures to other subprograms.
We have to take care while 'aligning' passed parameters in the subprogram.
They should be declared in same order in the subprogram in linkage section.
This becomes cumbersome when there are large number of subprograms.

So by using pointers we pass all variables to every subprogram, now subprogram has the freedom to use it or not.
This appears very appealing when we consider maintainance of the programs in long term.
No problem in adding more subprograms with different data passed.

You are right. In my work area i am also finding the same type of programs. The main benefit here is that you can pass all but use as much you want thats right. but if we will see the address wise processing with pointer or without pointer the address of the data item is being passed between the programs..... am i correct ?

agkshirsagar wrote:

I had asked a similar question before, it was promptly moved to 'Off topics' . :(
I have observed some programs which call 100s of subprograms dynamically.
Now it is quite obvious that they pass huge number variables/structures to other subprograms.
We have to take care while 'aligning' passed parameters in the subprogram.
They should be declared in same order in the subprogram in linkage section.
This becomes cumbersome when there are large number of subprograms.

So by using pointers we pass all variables to every subprogram, now subprogram has the freedom to use it or not.
This appears very appealing when we consider maintainance of the programs in long term.
No problem in adding more subprograms with different data passed.

PROCEDURE DIVISION USING POINTER-ST
SET ADDRESS OF A TO POINTERA
SET ADDRESS OF B TO POINTERB

There is a lot more 'relief' and less possibility of misalignment in the second method. :)
You have access to all data from main program but use what all you need!
But this is all IMHO. (Copyright Dick :lol: )

Please let me know if you think this as an advantage of pointers.
Sorry for lengthy post, but thought it was needed here. :)

You are right. In my work area i am also finding the same type of programs. The main benefit here is that you can pass all but use as much you want thats right. but if we will see the address wise processing with pointer or without pointer the address of the data item is being passed between the programs..... am i correct ?

yes! In both cases address is getting passed through the linkage section.
later approach passes pointer to these pointers. Only one pointer is getting passed (POINTER-ST is a pointer which points to set of pointers under it.)
Suppose
Address(A) = 1000
Now this address of A is stored in PointerA
Therefore content(PointerA) = 1000
and let Address(PointerA) = 4000
Now this 4000 will be passed to the linkage section.

If it creates lot of confusion for it then just leave it. You dont have to bother about the insides about how it works to use it !