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

Query regarding array


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

New User


Joined: 10 May 2010
Posts: 32
Location: Mumbai

PostPosted: Wed Aug 11, 2010 7:22 pm
Reply with quote

Hello All,

I have a query regarding an array. Below mentioned is my requirement..

I have an array which is defined like this:
Code:
07 SPECIAL-CODES OCCURS 7.     
  09 CODE           PIC X(1).           
                       
  09 CODE-DATE  PIC X(8).   



if suppose there are values in the above array as in:

7 SPECIAL-CODES(1) OCCURS 7 TIMES

9 CODE (1) 1/AN A

9 CODE-DATE(1) 8/AN 20071128

7 SPECIAL-CODES(2)

9 CODE(2) 1/AN 3

9 CODE-DATE(2) 8/AN 20081225

7 SPECIAL-CODES(3)

9 CODE(3) 1/AN 2

9 CODE-DATE(3) 8/AN 20081224



i need to move the code with the most recent code- date in one variable say A

and other two codes with their respective code-dates in other variables say B and C.

Kindly let me know how can i do this with the help of an array or if there is an alternative way to do it!

Thanks & regards,
Shweta.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Aug 11, 2010 8:10 pm
Reply with quote

Quote:
i need to move the code with the most recent code- date in one variable say A

and other two codes with their respective code-dates in other variables say B and C.

Kindly let me know how can i do this with the help of an array or if there is an alternative way to do it!
You are not clear here. Move the data where? Move the latest or all of them -- you stated latest but you also talk about the other two values?

Also, please learn to use the Code button in submitting posts -- I edited your post to do this.

Did you not learn how to process an array in your classwork?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Aug 11, 2010 8:13 pm
Reply with quote

there are host-arrays for db2 and there are cobol internal tables

what you have is a cobol internal table.

so the largest code-date(n) should go to A
Code:

move spaces to A, B, C
perform varying subscript from 1 by 1 until subscript > 7
  evaluate true
      when code-date(subscript) > A
           move B to C
           move A to B
           move code-date(subscript) to A
      when code-date(subscript) > B
           move B to C
           move code-date(subscript) to B
      when code-date(subscript) > C
           move code-date(subscript) to C
      when other
           continue
  end-evaluate
end-perform
Back to top
View user's profile Send private message
Shweta12j

New User


Joined: 10 May 2010
Posts: 32
Location: Mumbai

PostPosted: Wed Aug 11, 2010 8:48 pm
Reply with quote

Hi Robert,

Thanks for reminding of code button. Will take care of it next time onwards.
Yes i did learn to use an array but in above secnario was not able to make it out.

Dick thanks for your promt response.
I will try the above code at my end.

Kind Regards,
Shweta
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 RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top