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?
Passing vlaues to Linkage Section and abend.
-
- New Member
- Posts: 8
- Joined: Tue Jan 13, 2015 3:26 pm
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Passing vlaues to Linkage Section and abend.
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.
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.
- Robert Sample
- Global Moderator
- Posts: 1891
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Passing vlaues to Linkage Section and abend.
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.
-
- New Member
- Posts: 8
- Joined: Tue Jan 13, 2015 3:26 pm
Re: Passing vlaues to Linkage Section and abend.
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 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.
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Passing vlaues to Linkage Section and abend.
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.
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.
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