Page 1 of 1
Passing vlaues to Linkage Section and abend.
Posted: Thu Nov 19, 2015 11:26 am
by Vijay Chikala
Hi,
One of the question which was tough to answer was, if we are passing X(12) from a program PGM-A to other Program say PGM-B which has X(10) as receving field. If we do so, will it generate an abend? If yes, what abend will you get and if not, what happens to the extra 2 bytes which were passed?
Re: Passing vlaues to Linkage Section and abend.
Posted: Thu Nov 19, 2015 1:01 pm
by William Collins
PGMA A PIC X(12)
PGMB B PIC X(10) (Linkage Section)
No possible abend. Even when B is used as a target.
PGMA A PIC X(10)
PGMB B PIC X(12) (Linkage Section)
No possible abend just in doing it, but if B is used as a target for anything, it could destroy the two bytes immediately following A, which may or may not be significant.
In either case the programs may not be working as expected and in general (unless there is a good specific purpose for the first) it is terrible practice.
Re: Passing vlaues to Linkage Section and abend.
Posted: Thu Nov 19, 2015 6:17 pm
by Robert Sample
To add to William's answer -- nothing happened to the last 2 bytes. They just won't be available or used in the subprogram. When the calling program gets control back, those 2 bytes will still be 2 bytes.
Re: Passing vlaues to Linkage Section and abend.
Posted: Thu Dec 31, 2015 2:39 pm
by Vijay Chikala
William Collins wrote:PGMA A PIC X(10)
PGMB B PIC X(12) (Linkage Section)
No possible abend just in doing it, but if B is used as a target for anything, it could destroy the two bytes immediately following A, which may or may not be significant.
Why it can destroy the 2 bytes? We are passing "smaller area" to "larger area" then the two bytes should not have any data? How will the extra bytes be destroyed? Can you please elaborate?
Re: Passing vlaues to Linkage Section and abend.
Posted: Thu Dec 31, 2015 7:25 pm
by William Collins
What do you think the word "passed" means in this context? It is clear that you are wrong about what it means.
What is "passed" is the address of the storage. Which means if a 10-byte field is "passed" the address of the 10-byte field is passed. If that 10-byte field is then defined in the LINKAGE SECTION as 12 bytes, the surplus two bytes are those immediately after the 10-byte field. If you use that LINKAGE SECTION item as a "target" for something (like MOVE) than you will obliterate the contents of the two bytes following the 10 bytes.