Passing vlaues to Linkage Section and abend.

All sort of Mainframes Interview Questions.
Post Reply
Vijay Chikala
New Member
Posts: 8
Joined: Tue Jan 13, 2015 3:26 pm

Passing vlaues to Linkage Section and abend.

Post 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?
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Passing vlaues to Linkage Section and abend.

Post 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.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Passing vlaues to Linkage Section and abend.

Post 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.
Vijay Chikala
New Member
Posts: 8
Joined: Tue Jan 13, 2015 3:26 pm

Re: Passing vlaues to Linkage Section and abend.

Post 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?
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Passing vlaues to Linkage Section and abend.

Post 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.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “Interview Questions.”