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

Addition of elements in multi dimensional table.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 1208
Location: Bangalore,India

PostPosted: Wed Jan 10, 2007 3:21 pm
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: 3156
Location: Tucson AZ

PostPosted: Wed Jan 10, 2007 3:24 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top