View previous topic :: View next topic
|
Author |
Message |
vyasricha
New User
Joined: 17 Mar 2008 Posts: 27 Location: banaglore
|
|
|
|
Hi,
1) I wanted to know why we use only s9(04) comp means 2 bytes for linkage section variable to get the length ? can't we use any other variable .
2) we use this to receive value from jcl but from jcl we can pass only 100 bytes so why we use 2 byte field for getting length ?
Can anybody help me to find out the answer for this ! |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You are excluding a lot from your description, which makes it all unclear.
What you are wondering is why, when receiving a PARM from the JCL, you program has to define COMP PIC S9(4) for the length of the PARM which has a range of 0-100.
The anwser is that that is the way IBM did it when they designed the JCL.
OK, a bit more. The smallest thing you can do binary arithmetic with is a "half-word", which is two bytes. Your PIC S9(4) is two bytes (a half-word).
PIC S9, PIC S99, and PIC S999 (all COMP) are also half-words. For the PARM, you could actually use PIC S999 COMP if you wanted. When using COMP, it is "standard practice" to use the number of 9's that most fill the amount of storage space. So, even for a value of +1, you'll see PIC S9(4) COMP.
Code: |
01 L-PARM-FROM-JCL.
05 L-PFJ-LENGTH-OF-DATA COMP PIC S9(4).
05 L-PFJ-DATA.
10 FILLER OCCURS 1 TO 100 TIMES
DEPENDING ON L-PFJ-LENGTH-OF-DATA.
15 FILLER PIC X.
|
then just
MOVE L-PFJ-DATA to where you want. It will only move the characters you have given it on the PARM with no further messing around, padding receiving field with space if necessary. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
1. I assume you mean for passed parameters from JCL. You use S9(04) COMP because that is how the length field is defined. You could use X(02) or 9(02) or anything you want -- but the results will be unpredictable since you are not using the defined value.
2. Because IBM said so in the manual. You COULD ask IBM why the length field allows 4 bytes but JCL only allows 100 bytes, but you probably won't get an answer -- or if you do, it probably would be "because that is the way it is".
You need to learn -- certain things are the way they are. There may have been an explanation at one point in time but since JCL goes back over 45 years at this point, in some cases the reasons may have been lost in the mists of time, and in other cases the reasons may no longer apply but for compatibility reasons IBM doesn't want to change things. |
|
Back to top |
|
|
vyasricha
New User
Joined: 17 Mar 2008 Posts: 27 Location: banaglore
|
|
|
|
Thanks for your reply !
I do accept we use 2 bytes because it is defined as per IBM standards.
But i am looking for that why it is defined like that ? there should be some reason for that .
We can pass data from jcl that is of 100 bytes means length 3. If i use
S9(4) comp that takes 2 bytes but internally it stores data in 4 nibbles means i can store 3 values in each nibble. that is the reason we give
s9(4) comp. but can we give s9(1) to s(4) comp as they take only 2 bytes 1-4 comp = 2bytes. but i think we can't give x(02) or 9(02) as they don't store the values in each nibbles they store in each byte.
Please let me know is it correct ! |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Just always define it as S9(04) COMP (a Binary Halfword) and move on, please....
Bill |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
One of the reason might be that halfword binary is the smallest <size> for which exist native machine instruction LH,STH,AH,SH,MH
but, who knows really!
that' s why the reason must be asked to the people who designed the whole shebang |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
But i am looking for that why it is defined like that ? there should be some reason for that . |
There might be -- but I don't know it since it's been like that for the 30+ years I've been using JCL. The reason may be as simple as different people within IBM defined the parameter limit and the parameter length field -- or the reason could have been a plan to increase the PARM length at some point. Since I've never worked for IBM, there's no way I could know why such design decisions were made. Unless you find someone who worked on OS/360 back in the early to mid 1960's, I doubt you will ever find the reason.
Since you're asking an unanswerable question, I'm locking the topic. |
|
Back to top |
|
|
|