Queries regarding to COBOL and DB2



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Queries regarding to COBOL and DB2

Postby basith919 » Sun Jul 31, 2011 7:54 pm

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.
basith919
 
Posts: 2
Joined: Fri Jul 22, 2011 7:25 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COBOL

Postby Robert Sample » Sun Jul 31, 2011 8:10 pm

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.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: COBOL

Postby BillyBoyo » Sun Jul 31, 2011 8:23 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: COBOL

Postby dick scherrer » Sun Jul 31, 2011 9:27 pm

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
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: COBOL

Postby Robert Sample » Mon Aug 01, 2011 6:11 pm

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.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: COBOL

Postby basith919 » Tue Aug 02, 2011 11:42 am

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.
basith919
 
Posts: 2
Joined: Fri Jul 22, 2011 7:25 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COBOL

Postby dick scherrer » Tue Aug 02, 2011 10:24 pm

Not to worry :)

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

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post