Page 1 of 1

Queries regarding to COBOL and DB2

PostPosted: Sun Jul 31, 2011 7:54 pm
by basith919
I have some queries regarding to COBOL and DB2....i tried to get answer from groups but i didn't get clarity.

Occurs class: Can we use 77 level number in occurs class.

eg;
01 Mdata

02 month occurs 12 times.

77 week x(4) occurs 4times. ....Is it correct or not in 2 dimensional array declaration.

Renames class: when we are using renames class, can we use diff level numbers in elementary data items.

eg: 01 salary

02 basic pic 9(5).

03 hra pic 9(5).

04 pf pic 9(4).

04 sa pic 9(2).

66 Nsal renames hra thru sa.

Is it correct declaration or not.

DB2: Is it possible to retrieve multiple rows from a table with out using cluster, if yes how it is possible.

Diff between index, unique index and cluster index.

Re: COBOL

PostPosted: Sun Jul 31, 2011 8:10 pm
by Robert Sample
First, it is not very smart to place a topic with a title of COBOL in the COBOL forum -- pretty much EVERY topic concerns COBOL!

Second, you need to learn to read manuals -- IBM manuals explain much about COBOL. You can find the manuals for your release of COBOL at http://www.ibm.com and search for COBOL LIBRARY.

From the COBOL Language Reference manual, section 5.3.11:
The OCCURS clause cannot be specified in a data description entry that:

Has a level number of 01, 66, 77, or 88.

Describes a redefined data item. (However, a redefined item can be subordinate to an item that contains an OCCURS clause.) See "REDEFINES clause" in topic 5.3.13.
And since a 77 level is functionally the same as an 01 level (except that 77 cannot be divided the way an 01 can), your posted example makes absolutely no sense.

Your RENAMES example is complete and utter trash as well. You can have group variables in COBOL, or you can have elementary variables in COBOL. You do not have group variables with PICTURE clauses as you have coded. Since your example is total garbage, no statements can be made about your RENAME. However, in general the level numbers of the variables used in the RENAMES clause can be different -- as long as they properly identify an area of memory. Section 5.3.14 of the COBOL Language Reference manual describes some cases of valid and invalid RENAMES clauses.

Re: COBOL

PostPosted: Sun Jul 31, 2011 8:23 pm
by BillyBoyo
Basith919,

When you format your posting to retain the spacing (like for program code), you need to use the Code button.

Please try to make the title more meaningful.

If you have multiple questions, you should start more than one topic, especially when the questions are on different subjects.

With your first questions on Cobol, you really have to get back to a very basic level of understanding.

77's have to be at the start, before any 01 level. If you try to put them after an 01, you will get a compile error.

For your two-dimension table, just use a level number that is greater than the one with the first OCCURS.

01  this-thing.
    05  filler occurs 10.
        10  filler occurs 10.
            15  this-two-dimension-item PIC X.

is one way of deining it.

For your RENAMES example, you have to understand that higher level numbers define the storage for a group item, and a group item cannot therefore have a PICTURE clause.

I have never used RENAMES. I don't suppose you'd genuinely ever need to either.

Re: COBOL

PostPosted: Sun Jul 31, 2011 9:27 pm
by dick scherrer
Hello and welcome to the forums,

Are these interview questions? We have an entire part of the forum for Interview Questions and your topic can easily be moved there.

You need to find a way to get training for both COBOL and DB2. From where you "are" to where you will be able to actually work with these, you need some kind of foundation on which to build, and this foundation has not yet been established. We are not able to provide language/database training. It is simply too big a task for a forum.

d

Re: COBOL

PostPosted: Mon Aug 01, 2011 6:11 pm
by Robert Sample
Just for completeness, compiler output for the code you posted is:
   000013                01  SALARY
   000014                    02  BASIC                   PIC 9(5).

 ==000014==> IGYDS1082-E A period was required.  A period was assumed before "02".

 ==000014==> IGYDS1052-E Group item "BASIC" contained the "PICTURE" clause.  The clause was
                         discarded.

   000015                        03  HRA                 PIC 9(5).

 ==000015==> IGYDS1052-E Group item "HRA" contained the "PICTURE" clause.  The clause was
                         discarded.

   000016                            04  PF              PIC 9(4).

 ==000016==> IGYDS0148-S "PF" is a reserved word related to language not supported by this
                         compiler.  The statement was discarded.

   000017                            04  SA              PIC 9(2).
   000018                66  NSAL RENAMES HRA THRU SA.

 ==000018==> IGYDS0014-S "RENAMES" object "SA" was contained within, or had a common leftmost byte
                         with, object "HRA".  The "RENAMES" clause was discarded.
You have syntax errors, use of reserved words, use of PICTURE with groups, and an invalid RENAMES clause. Correcting your code to compile requires this or something similar:
        01  SALARY.
            02  BASIC.
                03  FILLER              PIC 9(5).
                03  HRA.
                    04  FILLER          PIC 9(5).
                    04  PFX             PIC 9(4).
                03  FILLER.
                    04  SA              PIC 9(2).
        66  NSAL RENAMES HRA THRU SA.

Re: COBOL

PostPosted: Tue Aug 02, 2011 11:42 am
by basith919
thanks to all,i am very new to forum,i understood how to post a query in forum,i won't repeat these mistakes next time.

Re: COBOL

PostPosted: Tue Aug 02, 2011 10:24 pm
by dick scherrer
Not to worry :)

Once upon a time, we all had to learn. . . ;)

d