View previous topic :: View next topic
|
Author |
Message |
balubhat
New User
Joined: 04 Oct 2005 Posts: 19 Location: Singapore
|
|
|
|
Hi
Please clarify my below doubt:
1. In a Called program , I get the input data via linkage section. Now usually we use these input data from linkage section in procedure division like
PROCEDURE DIVISION USING WS-VAR1.
where WS-VAR1 is defined in the linkage section.
Now my question is can I use these linkage section variables directly in the procedure division without coding
PROCEDURE DIVISION USING WS-VAR1 ?
2. Suppose program A is calling program B. So program B will have the linkage section to receive the input data from program A. But if program A wants to receive some output data from program B, should program A also needs to have Linkage section? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
1. this questions displays the fact that you have made no effort to read a COBOL application programming guide. read it...
2. If program A has a Procedure Division Using ..., the ... can be passed to Program B via CALL PGM B USING ....
If program A has no linkage, then Program A working storage can be passed via CALL PGM B USING ...
either way, upon return from PGM B, Pgm A can reference any of the data passed by CALL PGM B USING ... that was populated by PGM B.
linkage is a method whereby you can reference data areas defined in another module which calls you USING ... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Define the data area to be "2-way". In the calling module define an 01 that has all of the data fields to be used by the called module and then the fields to be "returned" from the called module. Or use 2 level 01 entries (and the CALL would use both, the linkage section would define both, and the USINGs would name both).
Keep in mind that the data is not really going anywhere - the linkage section refers to memory in the calling module. Between the CALL USING, the LINKAGE SECTION, and the USING in the called module, addressability is established.
Care must be taken to use the same type variables on both sides of the CALL. |
|
Back to top |
|
|
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
Quote: |
Now my question is can I use these linkage section variables directly in the procedure division without coding
PROCEDURE DIVISION USING WS-VAR1 ? |
I guess you'll get a S0C4 if you reference these. |
|
Back to top |
|
|
|