Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Why we use s9(04) comp for linkage section variable length ?

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
vyasricha

New User


Joined: 17 Mar 2008
Posts: 27
Location: banaglore

PostPosted: Wed May 25, 2011 2:46 pm    Post subject: Why we use s9(04) comp for linkage section variable length ?
Reply with quote

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
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7251

PostPosted: Wed May 25, 2011 2:56 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7931
Location: Bellevue, IA

PostPosted: Wed May 25, 2011 2:57 pm    Post subject:
Reply with quote

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
View user's profile Send private message
vyasricha

New User


Joined: 17 Mar 2008
Posts: 27
Location: banaglore

PostPosted: Wed May 25, 2011 4:59 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed May 25, 2011 5:05 pm    Post subject: Reply to: Why we use s9(04) comp for linkage section variabl
Reply with quote

Just always define it as S9(04) COMP (a Binary Halfword) and move on, please.... icon_rolleyes.gif

Bill
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Wed May 25, 2011 5:13 pm    Post subject: Reply to: Why we use s9(04) comp for linkage section variabl
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7931
Location: Bellevue, IA

PostPosted: Wed May 25, 2011 5:18 pm    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm
No new posts Joinkeys operation when key1 and key2... Susanta DFSORT/ICETOOL 5 Wed Nov 02, 2016 5:35 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us