IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

OOPS concept in COBOL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
amiya_mf

New User


Joined: 01 Mar 2005
Posts: 18

PostPosted: Fri Apr 13, 2007 5:27 pm
Reply with quote

hI,

Can anybody help me to develop a object oriented program in cobol. i tried but could not sucessed.

Regards,
Amiya
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Fri Apr 13, 2007 5:30 pm
Reply with quote

Post what you tried and what problem you faced?
then we may be able to offer some suggestions.
Back to top
View user's profile Send private message
amiya_mf

New User


Joined: 01 Mar 2005
Posts: 18

PostPosted: Mon Apr 16, 2007 5:49 pm
Reply with quote

Hi Abhijit,

Following is the program i am trying but getting compilation error...

Could you please suggest and let me know what should i do ?

Code:
*************************** Top of Data ******************
 IDENTIFICATION DIVISION.                                 
*                                                         
* ORDERS IS THE NAME OF THE CLASS                         
* ORDERS INHERITS FROM SOMOBJECT (SOM BASE CLASS)         
*                                                         
 CLASS-ID. Orders INHERITS SOMObject.                     
/                                                         
 ENVIRONMENT DIVISION.                                   
 CONFIGURATION SECTION.                                   
 REPOSITORY.                                             
     CLASS SOMObject IS 'SOMObject'                       
     CLASS Orders IS 'Orders'.                           
/                                                         
 DATA DIVISION.                                           
 WORKING-STORAGE SECTION.                                 
*                                                         
* INSTANCE DATA FOR ORDERS CLASS                         
*                                                         
 01  ORDER-NUMBER PIC 9(5).                               
 01  ORDER-DATE PIC X(8).                                 
 01  ORDER-COUNT PIC 99.                                 
 01  ORDER-TABLE.                                         
     02  ORDER-ENTRY OCCURS 10 TIMES.                     
         03  ORDER-ITEM PIC X(5).                         
/                                                         
 PROCEDURE DIVISION.                                     
*                                                         
* METHOD DEFINITIONS IN HERE                             
 IDENTIFICATION DIVISION.                                 
 METHOD-ID. 'somInit' OVERRIDE.                           
 PROCEDURE DIVISION.                                     
*                                                         
     MOVE FUNCTION CURRENT-DATE(1:8) TO order-date.       
     COMPUTE order-number = FUNCTION RANDOM ( 99999 ).   
     MOVE 0 TO order-count.                               
     INITIALIZE order-table.                             
     EXIT METHOD.                                         
 END METHOD 'somInit'.   
* Method to add an item to an order 
 IDENTIFICATION DIVISION.                                 
 METHOD-ID. AddItem.                                       
 DATA DIVISION.                                           
* Use LOCAL-STORAGE for items that should be allocated     
* and initialized for each invocation of the method       
 LOCAL-STORAGE SECTION.                                   
 77 sub PIC 99.                                           
 01  found-flag PIC 9 VALUE 1.                             
     88 found VALUE 0.                                     
 LINKAGE SECTION.                                         
 01 in-item PIC X(5).                                     
 01 add-flag PIC 9.                                       
 PROCEDURE DIVISION USING in-item RETURNING add-flag.     
     MOVE 1 TO add-flag.                                   
     PERFORM VARYING sub FROM 1 BY 1                       
       UNTIL (sub > 10) OR (found)                         
        IF order-item (sub) = SPACES                       
           MOVE in-item TO order-item (sub)               
           ADD 1 TO order-count                           
           MOVE 0 TO add-flag                             
           SET found TO TRUE                               
        END-IF                                             
     END-PERFORM.                                         
     EXIT METHOD.                                         
 END METHOD AddItem.                                       
 END CLASS Orders.                                         
*********************************************


agkshirsagar wrote:
Post what you tried and what problem you faced?
then we may be able to offer some suggestions.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Apr 18, 2007 12:54 am
Reply with quote

Hello,

You should also post the output messages from the copiler.

For starters (if this is a single program) you have multiple identification division statements. This is not allowed. How much COBOL experience have you?

If you don't already have one, you might want to create a non-OO version of the program to prove the logic works.
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Wed Apr 18, 2007 10:33 am
Reply with quote

Amiya,

Are you trying to write a cobol nested program? As pointed out by dick, you have multiple id division statements in the program.
Back to top
View user's profile Send private message
vinila

New User


Joined: 23 Feb 2007
Posts: 4
Location: Mumbai

PostPosted: Wed Apr 18, 2007 12:36 pm
Reply with quote

Cobol is not a Object Oriented programming language
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Wed Apr 18, 2007 12:50 pm
Reply with quote

Vinila,

Quote:
Cobol is not a Object Oriented programming language


Are you sure about this?
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Wed Apr 18, 2007 1:06 pm
Reply with quote

Dick,
Multiple Procedure divisions are allowed, in this case each procedure division belongs to one mehod. methods can have their own Procedure divisions.

Amiya,
I need some time to play with it. BTW ,have you tried googling about OO features of COBOL.
paste the error messages which you got.
Code:

Cobol is not a Object Oriented programming language

It is not object oriented language but it has Object Oriented features.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Apr 18, 2007 7:09 pm
Reply with quote

Hello,

Yes, but i didn't mention procedure division. I don't recall multiple identification divisions being allowed. . .

Vinala - this is not complete accurate
Quote:
Cobol is not a Object Oriented programming language

While the language is not know as an OO language, it does support OO methods.
Back to top
View user's profile Send private message
amiya_mf

New User


Joined: 01 Mar 2005
Posts: 18

PostPosted: Thu Apr 19, 2007 5:45 pm
Reply with quote

Hi Dick,

Are u really aware of OOPS concept in Enterprise COBOL. If yes you would not ask me about my experience in cobol. First gothrough the ibm reference pdf then reply to such types of mails.

Sorry, its just to maintain decipline in the room. Asking how much experience to a member is not a good behaviour.

For your kind information multiple IDENTIFICATION DIVISION is allowed in entprise cobol Version - 3 and Release 4.

If you have any sample program then send me across.

Regards,
Amiya

dick scherrer wrote:
Hello,

You should also post the output messages from the copiler.

For starters (if this is a single program) you have multiple identification division statements. This is not allowed. How much COBOL experience have you?

If you don't already have one, you might want to create a non-OO version of the program to prove the logic works.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Apr 19, 2007 8:07 pm
Reply with quote

Hello Amiya,

I believe you are quite mistaken with this
Quote:
Sorry, its just to maintain decipline in the room. Asking how much experience to a member is not a good behaviour.


First, you are not yet in a position to "maintain discipline". Second, it is quite appropriate to know the technical level of the person we are trying to provide information for. The forum has many people who are working in the mainframe environment for their first time. There are also many who are not comfortable with COBOL and the other "standard" mainframe tools/concepts. Knowing the experience level of the requestor often guides us on how to word a response. If you are upset that your level of experience was questioned, sorry 'bout that - get over it.

People with some depth of experience know how to post their questions. This
Quote:
Can anybody help me to develop a object oriented program in cobol. i tried but could not sucessed.
pretty much shouts rookie. Someone with any experience at all would initially post what they tried and why it did not work, including compiler messages and/or run-time errors. If you would prefer not to have your experience questioned, improve your presentation method. Also, i don't believe you've yet posted the info requested above. . . Mentioning "but getting compilation error... " provides nothing for anyone to work on.

To answer your question about OO-COBOL on the mainframe - i am aware of it but do not claim proficiency with it - i don't have any client who wants me to spend time using it (yet). The OO things i work with are on UNIX or Win-based systems. The mainframe will follow (maybe even this year) icon_smile.gif

We get many people here with very little experience and are we most willing to help them. There is nothing wrong with being new. We all started fresh at some time icon_smile.gif
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Fri Apr 20, 2007 12:05 am
Reply with quote

Dick,
You really took it cool! icon_wink.gif
(This shows you have a way larger experience than OP icon_smile.gif )

Apart from that-
I could find this link, Technically it is OO program but don't know OP will accept it icon_confused.gif
http://publib.boulder.ibm.com/infocenter/pdthelp/v1r1/index.jsp?topic=/com.ibm.entcobol4.doc/rpooo10e.htm
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Fri Apr 20, 2007 12:13 am
Reply with quote

Well it seems Ameya was doing SOM based cobol but SOM-based object-oriented COBOL applications are no longer supported with Enterprise COBOL. OO COBOL syntax has been retargeted for Java-based object-oriented pogramming to facilitate interoperation of COBOL and Java.

See the link below-
http://publib.boulder.ibm.com/infocenter/pdthelp/v1r1/index.jsp?topic=/com.ibm.entcobol4.doc/rpooo10e.htm

I don't think that I should spend my time on this thread now! icon_cool.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top