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?
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 ...
Joined: 23 Nov 2006 Posts: 19270 Location: Inside the Matrix
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.