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
 

 

Addition of elements in multi dimensional table.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
vishalpatel

New User


Joined: 13 Dec 2006
Posts: 4
Location: Baroda

PostPosted: Wed Jan 10, 2007 3:10 pm    Post subject: Addition of elements in multi dimensional table.
Reply with quote

hi,
can any body tell me, how can i do said operation?

Data-division.
Working-storage section.
01 records.
02 student occurs 3 times indexed by i.
03 name pic x(8).
03 roll-no. pic 99.
03 marks pic 999 occurs 2 times indexed by j.
03 total pic 9999.
i want to do addition of
marks(i j) for particular i, and want to move this addition in total(i).
for example
i want to do addition of marks(1) and marks(2) of student 1 and to move this result in total of student1.

i had already done this operation using this syntax but having syntax error.
add marks(i j) to total(i).
Back to top
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Wed Jan 10, 2007 3:21 pm    Post subject:
Reply with quote

HI there,

Code:
PERFORM VARYING I FROM 1 BY 1 UNTIL I> 3

    PERFORM VARYING J FROM 1 BY 1 UNTIL J> 2

      ADD marks(I, J) TO TOTAL(I)
    END-PERFORM
 END-PERFORM.


Hope it should work.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Wed Jan 10, 2007 3:24 pm    Post subject: Re: Addition of elements in multi dimensional table.
Reply with quote

vishalpatel wrote:
hi,
can any body tell me, how can i do said operation?

Code:
Data-division.
Working-storage section.
01 records.
   02 student occurs 3 times indexed by i.
      03 name pic x(8).
      03 roll-no. pic 99.
      03  marks pic 999 occurs 2 times indexed by j.
      03 total pic  9999.
i want to do addition of
marks(i j) for particular i, and want to move this addition in total(i).
for example
i want to do addition of marks(1) and marks(2) of student 1 and to move this result in total of student1.

i had already done this operation using this syntax but having syntax error.
add marks(i j) to total(i).
What exactaly is the syntax error?
If you want both 1 and 2 added, Add marks (i 1) marks (i 2) to total (i) should work....
Back to top
View user's profile Send private message
vishalpatel

New User


Joined: 13 Dec 2006
Posts: 4
Location: Baroda

PostPosted: Wed Jan 10, 2007 3:26 pm    Post subject: thanx a lot.
Reply with quote

hello,

thanx a lot for ur co-operation.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    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 Need Rexx Program to Load in to DB2 T... Hareesh Verma CLIST & REXX 22 Tue Sep 20, 2016 2:59 pm
No new posts Command UNIQUE CONSTRAINT on any tabl... rohanthengal DB2 2 Thu Aug 18, 2016 3:48 pm
No new posts Multi row fetch - "for read only... Nileshkul DB2 3 Sun Aug 14, 2016 12:52 am
No new posts Updating online Db2 table kishpra DB2 3 Fri Aug 12, 2016 2:44 pm
No new posts Reading selected volumes of a multi-v... RickBig JCL & VSAM 6 Wed Jul 13, 2016 7:26 pm


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