From: Sucky_Programmer on
The book I am using for my class is "COBOL: From Micro to Mainframe
(3rd Edition)." A lot of people didn't seem to like the book
according to the Amazon.com review.

What is the difference between A margin and B margin?

Here is an example of some code:

FD STUDENT-FILE
RECORD CONTAINS 43 CHARACTERS
DATA RECORD IS STUDENT-IN.
01 STUDENT-IN
05 STU-NAME PIC X(25).
05 STU-CREDITS PIC 9(3).
05 STU-MAJOR PIC X(15).

So when it says after the FD 43 characters in what exactly does this
mean? I know it's going to send information from a file into
STUDENT-IN and then I have my variables to hold the values declared.
So when there is 01 in front of STUDENT-IN it means it is processed
first? Why do they have 05 in front of the variable? Does it have to
be 05 all the time? I am guessing this is to order some kind of
precedence of 01 taking place processing before it does 05.

Also I notice when some programs declare PIC it does 9(3) instead of
999. Does it matter? From what I saw when I was reading I remember
when you get to 4 numbers I see them code 9(4). Is there some kind
of standard for this after you get to a certain amount? It gets
confusing because this is not explained very well. Is PIC 9(1) the
same as PIC 9? or say PIC 9999 and PIC 9(4)? It gets confusing when
they don't explain the standards for this.

I will continue to read the book to see what other things I don't
understand but any help would be appreciated.


--
--------------------------------- --- -- -
Posted with NewsLeecher v3.9 Final
Web @ http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -

From: Doug Miller on
In article <4c5cbd5f$0$6096$c3e8da3(a)news.astraweb.com>, Sucky_Programmer <myspywarehelp(a)gmail.com> wrote:
>The book I am using for my class is "COBOL: From Micro to Mainframe
>(3rd Edition)." A lot of people didn't seem to like the book
>according to the Amazon.com review.

You've apparently spent more time reading the reviews on Amazon than you have
reading the book itself.
>
>What is the difference between A margin and B margin?

Isn't that explained in the book?
>
>Here is an example of some code:
>
>FD STUDENT-FILE
> RECORD CONTAINS 43 CHARACTERS
> DATA RECORD IS STUDENT-IN.
>01 STUDENT-IN
> 05 STU-NAME PIC X(25).
> 05 STU-CREDITS PIC 9(3).
> 05 STU-MAJOR PIC X(15).
>
>So when it says after the FD 43 characters in what exactly does this
>mean?

Isn't that explained in the book?

> I know it's going to send information from a file into
>STUDENT-IN and then I have my variables to hold the values declared.
>So when there is 01 in front of STUDENT-IN it means it is processed
>first?

Isn't that explained in the book?

>Why do they have 05 in front of the variable? Does it have to
>be 05 all the time? I am guessing this is to order some kind of
>precedence of 01 taking place processing before it does 05.

You haven't read the book _at all_, have you?
>
>Also I notice when some programs declare PIC it does 9(3) instead of
>999. Does it matter?

No, except to the extent that it's easier to type 999 than 9(3).

>From what I saw when I was reading I remember
>when you get to 4 numbers I see them code 9(4). Is there some kind
>of standard for this after you get to a certain amount?

Ease of typing.

>It gets
>confusing because this is not explained very well. Is PIC 9(1) the
>same as PIC 9?

Yes.

>or say PIC 9999 and PIC 9(4)?

Yes.

> It gets confusing when
>they don't explain the standards for this.

It's markedly less confusing when you read the book.
>
>I will continue

I think you misspelled "begin".

>to read the book to see what other things I don't
>understand but any help would be appreciated.
>
>
From: James Gavan on
Sucky_Programmer wrote:
> The book I am using for my class is "COBOL: From Micro to Mainframe
> (3rd Edition)." A lot of people didn't seem to like the book
> according to the Amazon.com review.

Ahhh. Micro to Mainframe - never read it. Invariably TODAY it is
Mainframe to Micro :-)

Now specifically Micro Focus - try the following on-line manuals (which
shouldn't be dramatically different from what your text is explaining).
Once you've got the current set of manuals up you can go searching
through specific LRMs (Language Reference Manuals), or using the the
overall index which appears on the first web page you see, (in he left
pane), you can select keywords like 'Margin'.

Now it doesn't always work quite simply. I didn't immediately find a
reference to 'Margin', but in addition to that global index, there is a
'Search' as well - it's not exactly swift, because it's searching the
text of ALL the manuals. However with Search it did give a list - and
the first item listed was 'Language Fundamentals' and that took me
straight to a reference to 'Margin'.

You have to be a bit innovative when you don't find what you initially
want, and try some other keywords in the Index or the Search. As regards
how you store or display numbers, again you have to be a bit innovative;
I haven't checked, but I'm sure there are plenty of references to
numbering in the Index without bothering with a Search. Numbering -
check out 'numeric edited' and comp, comp-3, comp-5, comp-x etc. (Just
did it, using the Index; selected the letter 'C' and got 12 entries for
various comp-? entries).

The URL to get to the books :-

http://supportline.microfocus.com/documentation/books/nx51ws01/nx51indx.htm

In case you hadn't realised, the U of Limerick examples are Micro Focus
Net Express. You should be able to do the same thing with IBM - they are
pretty good on supporting their software - check out their LRMs and
examples.

Patience - it will come eventually, and much of what you are asking will
become second nature, but you have to do some initial slogging.

Jimmy, Calgary AB
From: Arnold Trembley on
Comments are interspersed...

On 8/6/2010 8:56 PM, Sucky_Programmer wrote:
> The book I am using for my class is "COBOL: From Micro to Mainframe
> (3rd Edition)." A lot of people didn't seem to like the book
> according to the Amazon.com review.
>
> What is the difference between A margin and B margin?

COBOL source code was originally written on 80 column punch cards, and
is still frequently coded in fixed-length records 80 bytes long. The A
margin begins in column 8 and the B margin begins in column 12. Certain
COBOL reserved words must begin in in the A margin, while most are
reserved words are supposed to appear in the B margin.

For example, "FD" should appear in the A margin, but the "RECORD
CONTAINS" clause must appear in the B Margin. The "01" level indicator
must appear in the A margin, but levels 02 through 99 must appear in the
B margin. It's requirement of standard COBOL in the original
specification for the language.

The standard layout for fixed format COBOL source program is:

Columns 1-6 Line number (may be left blank)
Column 7 Indicator area (an asterisk "*" here marks the
rest of the line as a comment that will not
be compiled).
columns 8-11 Area A
columns 12-72 Area B
columns 73-80 not edited by the COBOL compiler, sometimes used by
text editors for change control level numbers.

>
> Here is an example of some code:
>
> FD STUDENT-FILE
> RECORD CONTAINS 43 CHARACTERS
> DATA RECORD IS STUDENT-IN.
> 01 STUDENT-IN
> 05 STU-NAME PIC X(25).
> 05 STU-CREDITS PIC 9(3).
> 05 STU-MAJOR PIC X(15).
>
> So when it says after the FD 43 characters in what exactly does this
> mean?

The FD file definition is describing a fixed-length file where every
record is 43 bytes (characters) long. COBOL also supports files with
variable-length records.

> I know it's going to send information from a file into
> STUDENT-IN and then I have my variables to hold the values declared.
> So when there is 01 in front of STUDENT-IN it means it is processed
> first? Why do they have 05 in front of the variable? Does it have to
> be 05 all the time? I am guessing this is to order some kind of
> precedence of 01 taking place processing before it does 05.

The 01 and 05 are level numbers and they describe the hierarchy or
structure of the record in outline format. Level 01 always names the
entire record (structure), which in this case consists of three fields
at a lower level: STU-NAME, STU-CREDITS, and STU-MAJOR. The total
length of all three fields is 43 bytes, which is the length of the
record. So we have a record variable named STUDENT-IN that is a
character string 43 bytes long. STUDENT-IN is called a "group item" in
COBOL. The three subfields in this example are COBOL "elementary items"
because in this example they are not further subdivided. 05 is just the
next level down in the structure and is somewhat arbitrary. It could
just as easily have been 03 for all three subfields.

So when a record is read from STUDENT-FILE the entire contents are
stored in the record buffer named STUDENT-IN, and the COBOL program can
immediately refer to any of the three subfields by their variable names,
or refer to the entire STUDENT-IN record by its variable name.

The second level by convention is usually 05. If a variable at level 05
is subdivided, the next level number is 10, then 15, and so forth.

A "Group Item" will never have a PICTURE clause. It has an implied
PICTURE of X(???) and its length is the total length of all lower level
group items and elementary items. So, if you
MOVE STUDENT-IN TO WS-STUDENT
the entire 43 byte record will be moved (assuming the target variable
WS-STUDENT is at least 43 bytes long). When moving a character string,
the data will be truncated if the target field is shorter than the
source field. If the target field is longer than the source field, the
extra character positions will be filled with blank spaces.

>
> Also I notice when some programs declare PIC it does 9(3) instead of
> 999. Does it matter? From what I saw when I was reading I remember
> when you get to 4 numbers I see them code 9(4). Is there some kind
> of standard for this after you get to a certain amount? It gets
> confusing because this is not explained very well. Is PIC 9(1) the
> same as PIC 9? or say PIC 9999 and PIC 9(4)? It gets confusing when
> they don't explain the standards for this.

PIC 9 and PIC 9(1) are equivalent. They both define a field with a
single decimal digit. Similarly, PIC 999 and PIC 9(3) both define
fields with three decimal digits of precision. PIC 9999 and PIC 9(4)
both define fields with four decimal digits. A PIC 9(4) field can hold
unsigned numbers ranging from 0000 to 9999.

Depending on your compiler there may be a limit to the maximum number of
characters in a PICTURE clause string, so it is possible that PIC 9(18)
would be legal but PIC 999999999999999999 might fail as a syntax error.
Generally it's more convenient to write a short PIC clause, like PIC
9(18), and you don't run out of room before column 72, which is the
maximum right-hand margin in COBOL. Newer compilers may support a
"free-form" COBOL source code record layout that has fewer restrictions.

>
> I will continue to read the book to see what other things I don't
> understand but any help would be appreciated.
>
>

Good Luck!

COBOL's primary strength is manipulating data in files and records, and
in processing fixed-point arithmetic for business accounting and
financial applications. That's what it was designed for.

Originally, most data files processed by COBOL programs were on punch
cards, which eventually became tape and disk files with hardly any
changes to the program.

With kindest regards,

--
http://www.arnoldtrembley.com/
From: SkippyPB on
On 07 Aug 2010 01:56:47 GMT, Sucky_Programmer
<myspywarehelp(a)gmail.com> wrote:

>The book I am using for my class is "COBOL: From Micro to Mainframe
>(3rd Edition)." A lot of people didn't seem to like the book
>according to the Amazon.com review.
>
>What is the difference between A margin and B margin?
>

4 columns.

>Here is an example of some code:
>
>FD STUDENT-FILE
> RECORD CONTAINS 43 CHARACTERS
> DATA RECORD IS STUDENT-IN.
>01 STUDENT-IN
> 05 STU-NAME PIC X(25).
> 05 STU-CREDITS PIC 9(3).
> 05 STU-MAJOR PIC X(15).
>
>So when it says after the FD 43 characters in what exactly does this
>mean? I know it's going to send information from a file into
>STUDENT-IN and then I have my variables to hold the values declared.
>So when there is 01 in front of STUDENT-IN it means it is processed
>first? Why do they have 05 in front of the variable? Does it have to
>be 05 all the time? I am guessing this is to order some kind of
>precedence of 01 taking place processing before it does 05.
>

The Internet and Google is a wonderful invention. Just because you
have a sucky Cobol book shouldn't preclude you from trying to look
things up yourself. Here's the answer to your Cobol levels question.

http://publib.boulder.ibm.com/infocenter/iadthelp/v6r0/index.jsp?topic=/com.ibm.etools.iseries.langref.doc/c0925395191.htm


>Also I notice when some programs declare PIC it does 9(3) instead of
>999. Does it matter? From what I saw when I was reading I remember
>when you get to 4 numbers I see them code 9(4). Is there some kind
>of standard for this after you get to a certain amount? It gets
>confusing because this is not explained very well. Is PIC 9(1) the
>same as PIC 9? or say PIC 9999 and PIC 9(4)? It gets confusing when
>they don't explain the standards for this.
>

No difference between PIC 999 and PIC 9(3) or PIC 9(03). It just
takes less typing to type PIC 999 thant PIC 9(3).

>I will continue to read the book to see what other things I don't
>understand but any help would be appreciated.

Regards,
--

////
(o o)
-oOO--(_)--OOo-



"If I held you any closer I would be on the
other side of you."
-- Groucho Marx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Remove nospam to email me.

Steve